Commit c2a78484 by 李小惠

修改应用模块bug

parent c1549f9e
......@@ -40,6 +40,7 @@ public class UpdatePolicemanReq extends BaseRequest {
/**
* 用户名
*/
@NotBlank(message = "用户名不能为空",groups = {add.class,edit.class})
private String account;
private String password;
......@@ -66,6 +67,7 @@ public class UpdatePolicemanReq extends BaseRequest {
/**
* 0警员,1辅警
*/
@NotBlank(message = "警员类型不能为空",groups = {add.class,edit.class})
private Integer identity;
/**
......@@ -75,10 +77,6 @@ public class UpdatePolicemanReq extends BaseRequest {
//当前登录人的id
private Long createUser;
// /**
// * 人脸照片list
// */
// private List<String> faceInfoList;
/**
* 指纹照片list
*/
......
......@@ -12,7 +12,8 @@ public enum PublicExceptionEnum implements IExceptionEnum {
//设备编号重复
APP_CODE_IS_EXIST(CommonConstant.DEFAULT_USER_ERROR_CODE,"应用代码已存在"),
APP_NAME_IS_EXIST(CommonConstant.DEFAULT_USER_ERROR_CODE,"应用名称已存在")
APP_NAME_IS_EXIST(CommonConstant.DEFAULT_USER_ERROR_CODE,"应用名称已存在"),
APP_IS_NOT_EXIST(CommonConstant.DEFAULT_USER_ERROR_CODE,"应用不存在,请检查应用id是否存在"),
;
/**
......
......@@ -53,28 +53,37 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationMapper, Appli
public String AddOrUpdateCfg(ApplicationReq req) {
Application application = new Application();
BeanPlusUtil.copyProperties(req,application);
List<Application> list = list(new LambdaQueryWrapper<Application>()
.eq(Application::getAppCode, req.getAppCode()).or().eq(Application::getName,req.getName()));
//判断应用代码和应用名称是否重复,如果重复直接抛出异常
if (CollectionUtil.isNotEmpty(list)){
for (Application app:list) {
if (app.getName().equals(req.getName())){
throw new ServiceException(PublicExceptionEnum.APP_NAME_IS_EXIST);
}
if (app.getAppCode().equals(req.getAppCode())){
throw new ServiceException(PublicExceptionEnum.APP_CODE_IS_EXIST);
}
}
}
//判断id是否传递,如果传递则默认他是修改,根据数据库对比id,判断是否id传递错误;如果不传递默认新增
if (req.getId()==null || req.getId().trim().isEmpty()){
//判断应用代码和应用名称是否重复,如果重复直接抛出异常
if (CollectionUtil.isNotEmpty(list)){
for (Application app:list) {
if (app.getName().equals(req.getName())){
throw new ServiceException(PublicExceptionEnum.APP_NAME_IS_EXIST);
}
if (app.getAppCode().equals(req.getAppCode())){
throw new ServiceException(PublicExceptionEnum.APP_CODE_IS_EXIST);
}
}
}
application.setCreateTime(DateTimeUtil.getCurrentDateTime());
save(application);
return application.getId();
}else {
Application app = getById(req);
if (ObjectUtil.isNull(app)){
throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR);
for (Application app:list) {
if (!req.getId().equals(app.getId())){
if (app.getName().equals(req.getName())){
throw new ServiceException(PublicExceptionEnum.APP_NAME_IS_EXIST);
}
if (app.getAppCode().equals(req.getAppCode())){
throw new ServiceException(PublicExceptionEnum.APP_CODE_IS_EXIST);
}
}
}
application.setUpdateTime(DateTimeUtil.getCurrentDateTime());
updateById(application);
......
......@@ -194,6 +194,8 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
policeman.setPassword(sysUser.getPassword());
policeman.setState(1);
policeman.setUserId(sysUser.getUserId());
//如果有照片,将警员照片直接复制一下以防万一
policeman.setPhoto(req.getFaceInfo());
policeman.setCreateTime(DateTimeUtil.getCurrentDateTime());
policeman.setUpdateTime(DateTimeUtil.getCurrentDateTime());
save(policeman);
......@@ -524,6 +526,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS);
}
}
one.setPhoto(req.getFaceInfo());
one.setUpdateTime(DateTimeUtil.getCurrentDateTime());
//修改角色
if (req.getRolesList().size()>0){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论