新增和编辑--验重

This commit is contained in:
zhn
2023-08-28 14:26:22 +08:00
parent b6a5b9eece
commit b82b96c0a2
@@ -31,10 +31,11 @@ public class ProjectRxswinEOServiceImpl extends ServiceImpl<ProjectRxswinEOMappe
@Override
public void add(ProjectRxswinEO projectRxswinEO) {
//判断主题是否已存在
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
LambdaQueryWrapper<ProjectRxswinEO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProjectRxswinEO::getCreateBy,currentUser.getUsername());
wrapper.eq(ProjectRxswinEO::getProjectId,projectRxswinEO.getProjectId());
wrapper.eq(ProjectRxswinEO::getTheme,projectRxswinEO.getTheme());
List<ProjectRxswinEO> rxswinEOList = this.list(wrapper);
if(!rxswinEOList.isEmpty()){
throw new JeroBootException("主题:"+projectRxswinEO.getTheme()+"已存在,请重新添加");
@@ -53,6 +54,17 @@ public class ProjectRxswinEOServiceImpl extends ServiceImpl<ProjectRxswinEOMappe
*/
@Override
public void editById(ProjectRxswinEO projectRxswinEO) {
//判断主题是否存在
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
LambdaQueryWrapper<ProjectRxswinEO> wrapper =new LambdaQueryWrapper<>();
wrapper.eq(ProjectRxswinEO::getCreateBy,currentUser.getUsername());
wrapper.eq(ProjectRxswinEO::getProjectId,projectRxswinEO.getProjectId());
wrapper.eq(ProjectRxswinEO::getTheme,projectRxswinEO.getTheme());
wrapper.ne(ProjectRxswinEO::getId,projectRxswinEO.getId());
List<ProjectRxswinEO> rxswinEOList = this.list(wrapper);
if(!rxswinEOList.isEmpty()){
throw new JeroBootException("主题:"+projectRxswinEO.getTheme()+"已存在,请重新添加");
}
Date now = new Date();
projectRxswinEO.setUpdateTime(now);
saveOrUpdate(projectRxswinEO);