应用账户
This commit is contained in:
parent
a14706e2a3
commit
c9f3e36482
|
@ -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<SysApplication
|
|||
}catch (Exception e){
|
||||
return BaseResult.getFailureMessageEntity(e.getMessage());
|
||||
}
|
||||
//控制一下名字不能重复
|
||||
List<SysApplicationAccountEntity> 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<SysApplication
|
|||
*/
|
||||
@Override
|
||||
public JsonResultEntity updateAccount(JSONObject object) {
|
||||
return null;
|
||||
SysApplicationAccountEntity entity = getData("jsonStr", object, SysApplicationAccountEntity.class);
|
||||
try {
|
||||
checkParam(entity,"update");
|
||||
}catch (Exception e){
|
||||
return BaseResult.getFailureMessageEntity(e.getMessage());
|
||||
}
|
||||
//检查一下名字不能重复
|
||||
List<SysApplicationAccountEntity> 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<SysApplication
|
|||
*/
|
||||
@Override
|
||||
public JsonResultEntity deleteAccount(JSONObject object) {
|
||||
return null;
|
||||
SysApplicationAccountEntity entity = getData("jsonStr", object, SysApplicationAccountEntity.class);
|
||||
try {
|
||||
checkParam(entity,"delete");
|
||||
}catch (Exception e){
|
||||
return BaseResult.getFailureMessageEntity(e.getMessage());
|
||||
}
|
||||
sysApplicationAccountDao.logicRemove(entity);
|
||||
return BaseResult.getSuccessMessageEntity("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +109,14 @@ public class SysApplicationAccountServiceImpl extends BaseService<SysApplication
|
|||
*/
|
||||
@Override
|
||||
public JsonResultEntity getAccount(JSONObject object) {
|
||||
return null;
|
||||
SysApplicationAccountEntity entity = getData("jsonStr", object, SysApplicationAccountEntity.class);
|
||||
try {
|
||||
checkParam(entity,"get");
|
||||
}catch (Exception e){
|
||||
return BaseResult.getFailureMessageEntity(e.getMessage());
|
||||
}
|
||||
SysApplicationAccountEntity sysApplicationAccountEntity = sysApplicationAccountDao.get(entity.getId());
|
||||
return BaseResult.getSuccessMessageEntity("查询账户详情成功",sysApplicationAccountEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +127,14 @@ public class SysApplicationAccountServiceImpl extends BaseService<SysApplication
|
|||
*/
|
||||
@Override
|
||||
public JsonResultEntity queryAccountList(JSONObject object) {
|
||||
return null;
|
||||
SysApplicationAccountEntity entity = getData("jsonStr", object, SysApplicationAccountEntity.class);
|
||||
try {
|
||||
checkParam(entity,"queryList");
|
||||
}catch (Exception e){
|
||||
return BaseResult.getFailureMessageEntity(e.getMessage());
|
||||
}
|
||||
List<SysApplicationAccountEntity> queryList = sysApplicationAccountDao.query(entity);
|
||||
return BaseResult.getSuccessMessageEntity("查询列表成功",queryList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,11 +145,43 @@ public class SysApplicationAccountServiceImpl extends BaseService<SysApplication
|
|||
*/
|
||||
@Override
|
||||
public JsonResultEntity queryAccountPaged(JSONObject object) {
|
||||
SysApplicationAccountEntity entity = getData("jsonStr", object, SysApplicationAccountEntity.class);
|
||||
try {
|
||||
checkParam(entity,"queryPaged");
|
||||
}catch (Exception e){
|
||||
return BaseResult.getFailureMessageEntity(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//根据账户名称查询
|
||||
private List<SysApplicationAccountEntity> queryByName(SysApplicationAccountEntity entity){
|
||||
if (StrUtil.isNotEmpty(entity.getName())){
|
||||
SysApplicationAccountEntity account = new SysApplicationAccountEntity();
|
||||
account.setName(entity.getName());
|
||||
List<SysApplicationAccountEntity> 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不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue