Commit 69704c58 authored by 竹天卫's avatar 竹天卫

项目编号和项目名称都要校验是否重复

parent 60f319fc
...@@ -84,9 +84,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -84,9 +84,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
} }
QueryWrapper<Project> qw = new QueryWrapper<>(); QueryWrapper<Project> qw = new QueryWrapper<>();
qw.eq("name", query.getName()); qw.eq("name", query.getName());
qw.or();
qw.eq("code", query.getCode());
int count = projectMapper.selectCount(qw); int count = projectMapper.selectCount(qw);
if (count > 0) { if (count > 0) {
return BaseResponse.errorMsg("项目名称已存在!"); return BaseResponse.errorMsg("项目已存在!");
} }
Project create = new Project(); Project create = new Project();
BeanUtils.copyProperties(query, create); BeanUtils.copyProperties(query, create);
...@@ -108,11 +110,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -108,11 +110,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
} }
//判断名字是否重复 //判断名字是否重复
QueryWrapper<Project> qw = new QueryWrapper<>(); QueryWrapper<Project> qw = new QueryWrapper<>();
qw.eq("name", query.getName()); qw.and(arg-> arg.ne("id", query.getId()).eq("name", query.getName()));
qw.ne("id", query.getId()); qw.or(arg-> arg.ne("id", query.getId()).eq("code", query.getCode()));
int count = projectMapper.selectCount(qw); int count = projectMapper.selectCount(qw);
if (count > 0) { if (count > 0) {
return BaseResponse.errorMsg("项目名称已存在!"); return BaseResponse.errorMsg("项目已存在!");
} }
Project update = new Project(); Project update = new Project();
BeanUtils.copyProperties(query, update); BeanUtils.copyProperties(query, update);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment