diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/application/appAcount/service/impl/SysApplicationAccountServiceImpl.java b/base-service/src/main/java/com/hzya/frame/sysnew/application/appAcount/service/impl/SysApplicationAccountServiceImpl.java index 486e4526..349612d2 100644 --- a/base-service/src/main/java/com/hzya/frame/sysnew/application/appAcount/service/impl/SysApplicationAccountServiceImpl.java +++ b/base-service/src/main/java/com/hzya/frame/sysnew/application/appAcount/service/impl/SysApplicationAccountServiceImpl.java @@ -1,15 +1,21 @@ package com.hzya.frame.sysnew.application.appAcount.service.impl; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.sysnew.application.appAcount.entity.SysApplicationAccountEntity; import com.hzya.frame.sysnew.application.appAcount.dao.ISysApplicationAccountDao; import com.hzya.frame.sysnew.application.appAcount.service.ISysApplicationAccountService; import com.hzya.frame.web.entity.BaseResult; import com.hzya.frame.web.entity.JsonResultEntity; +import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.Resource; import com.hzya.frame.basedao.service.impl.BaseService; + +import java.util.List; + /** * 应用账户表(SysApplicationAccount)表服务实现类 * @@ -41,6 +47,11 @@ public class SysApplicationAccountServiceImpl extends BaseService queryList = queryByName(entity); + if (CollectionUtils.isNotEmpty(queryList) && queryList.size() > 0){ + return BaseResult.getFailureMessageEntity(entity.getName()+"重复"); + } sysApplicationAccountDao.save(entity); return BaseResult.getSuccessMessageEntity("新增成功"); } @@ -53,7 +64,23 @@ public class SysApplicationAccountServiceImpl extends BaseService queryList = queryByName(entity); + if (CollectionUtils.isNotEmpty(queryList) && queryList.size() > 0){ + for (SysApplicationAccountEntity acc : queryList) { + if (!acc.getId().equals(entity.getId())){ + return BaseResult.getFailureMessageEntity(entity.getName()+"重复"); + } + } + } + sysApplicationAccountDao.update(entity); + return BaseResult.getSuccessMessageEntity("更新成功"); } /** @@ -64,7 +91,14 @@ public class SysApplicationAccountServiceImpl extends BaseService queryList = sysApplicationAccountDao.query(entity); + return BaseResult.getSuccessMessageEntity("查询列表成功",queryList); } /** @@ -97,11 +145,43 @@ public class SysApplicationAccountServiceImpl extends BaseService queryByName(SysApplicationAccountEntity entity){ + if (StrUtil.isNotEmpty(entity.getName())){ + SysApplicationAccountEntity account = new SysApplicationAccountEntity(); + account.setName(entity.getName()); + List queryList = sysApplicationAccountDao.query(account); + return queryList; + } + return null; + } //数据检查 private void checkParam(SysApplicationAccountEntity entity,String type){ - + Assert.notNull(entity,"参数不能为空"); + if ("save".equals(type)){ + Assert.notEmpty(entity.getAppId(),"appId不能为空"); + Assert.notEmpty(entity.getName(),"账户名称不能为空"); + }else if ("update".equals(type)){ + Assert.notEmpty(entity.getId(),"id不能为空"); + }else if ("delete".equals(type)){ + Assert.notEmpty(entity.getId(),"id不能为空"); + }else if ("get".equals(type)){ + Assert.notEmpty(entity.getId(),"id不能为空"); + }else if ("queryList".equals(type)){ + Assert.notEmpty(entity.getAppId(),"appId不能为空"); + }else if ("queryPaged".equals(type)){ + Assert.notNull(entity.getPageNum(),"pageNum不能为空"); + Assert.notNull(entity.getPageSize(),"pageSize不能为空"); + } } }