|
@@ -2,7 +2,6 @@ package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -22,9 +21,15 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -159,11 +164,17 @@ public class WmProjectController {
|
|
|
HnqzUser user = SecurityUtils.getUser();
|
|
|
// 当前部门
|
|
|
Integer deptId = user.getDeptId();
|
|
|
- // 判断项目名称projectNumber是否重复
|
|
|
- int extCount = wmProjectService.count(Wrappers.<WmProject>lambdaQuery()
|
|
|
+ // 判断项目编号、项目名称是否重复
|
|
|
+ int projectNumberCount = wmProjectService.count(Wrappers.<WmProject>lambdaQuery()
|
|
|
.eq(WmProject::getDeptId, deptId)
|
|
|
.eq(WmProject::getProjectNumber, wmProject.getProjectNumber()));
|
|
|
- if (extCount > 0) {
|
|
|
+ int projectNameCount = wmProjectService.count(Wrappers.<WmProject>lambdaQuery()
|
|
|
+ .eq(WmProject::getDeptId, deptId)
|
|
|
+ .eq(WmProject::getProjectName, wmProject.getProjectName()));
|
|
|
+ if (projectNumberCount > 0) {
|
|
|
+ return R.failed("项目编号已存在");
|
|
|
+ }
|
|
|
+ if (projectNameCount > 0) {
|
|
|
return R.failed("项目名称已存在");
|
|
|
}
|
|
|
wmProjectService.saveProject(wmProject);
|
|
@@ -191,12 +202,19 @@ public class WmProjectController {
|
|
|
HnqzUser user = SecurityUtils.getUser();
|
|
|
// 当前部门
|
|
|
Integer deptId = user.getDeptId();
|
|
|
- // 判断项目名称projectNumber是否重复
|
|
|
- int extCount = wmProjectService.count(Wrappers.<WmProject>lambdaQuery()
|
|
|
+ // 判断项目编号、项目名称是否重复
|
|
|
+ int projectNumberCount = wmProjectService.count(Wrappers.<WmProject>lambdaQuery()
|
|
|
.eq(WmProject::getDeptId, deptId)
|
|
|
.eq(WmProject::getProjectNumber, wmProject.getProjectNumber())
|
|
|
.ne(WmProject::getId, wmProject.getId()));
|
|
|
- if (extCount > 0) {
|
|
|
+ int projectNameCount = wmProjectService.count(Wrappers.<WmProject>lambdaQuery()
|
|
|
+ .eq(WmProject::getDeptId, deptId)
|
|
|
+ .eq(WmProject::getProjectName, wmProject.getProjectName())
|
|
|
+ .ne(WmProject::getId, wmProject.getId()));
|
|
|
+ if (projectNumberCount > 0) {
|
|
|
+ return R.failed("项目编号已存在");
|
|
|
+ }
|
|
|
+ if (projectNameCount > 0) {
|
|
|
return R.failed("项目名称已存在");
|
|
|
}
|
|
|
// 判断项目编号projectNumber是不是只读,如果只读则不可修改
|