|
|
@@ -77,14 +77,22 @@ public class AgreementController extends BaseController {
|
|
|
@Operation(summary = "协议添加")
|
|
|
@PostMapping("/agreementAdd")
|
|
|
public HttpResult agreementAdd(@Validated @RequestBody AgreementAddParam param) {
|
|
|
-
|
|
|
- boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), null, 0);
|
|
|
- AssertionUtils.isFail(nameExists,"协议名称重复!");
|
|
|
LocalDateTime startDate = param.getStartDate();
|
|
|
LocalDateTime endDate = param.getEndDate();
|
|
|
+ // 1. 时间合法性校验
|
|
|
if(endDate.isBefore(startDate) || startDate.isEqual(endDate)){
|
|
|
AssertionUtils.isFail(false,"协议生效时间不能大于失效时间!");
|
|
|
}
|
|
|
+ // 2. 通用名称+时间查重(内部=0)
|
|
|
+ boolean nameExists = agreementService.checkNameExistsWithDate(
|
|
|
+ param.getAgreementTitle(),
|
|
|
+ null, // 新增传 null
|
|
|
+ 0, // 内部协议
|
|
|
+ startDate
|
|
|
+ );
|
|
|
+ AssertionUtils.isFail(nameExists,"协议名称已存在,请输入其他名称");
|
|
|
+
|
|
|
+ // 3. 执行新增
|
|
|
agreementService.agreementAdd(param);
|
|
|
return HttpResult.ok("新增成功");
|
|
|
}
|
|
|
@@ -98,14 +106,22 @@ public class AgreementController extends BaseController {
|
|
|
@Operation(summary = "协议修改")
|
|
|
@PostMapping("/agreementEdit")
|
|
|
public HttpResult agreementEdit(@Validated @RequestBody AgreementEditParam param) {
|
|
|
-
|
|
|
- boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), param.getId(), 0);
|
|
|
- AssertionUtils.isFail(nameExists,"协议名称重复!");
|
|
|
LocalDateTime startDate = param.getStartDate();
|
|
|
LocalDateTime endDate = param.getEndDate();
|
|
|
+ // 1. 时间合法性校验
|
|
|
if(endDate.isBefore(startDate) || startDate.isEqual(endDate)){
|
|
|
AssertionUtils.isFail(false,"协议生效时间不能大于失效时间!");
|
|
|
}
|
|
|
+ // 2. 通用名称+时间查重(内部=0,编辑排除自身)
|
|
|
+ boolean nameExists = agreementService.checkNameExistsWithDate(
|
|
|
+ param.getAgreementTitle(),
|
|
|
+ param.getId(), // 修改传自身ID
|
|
|
+ 0, // 内部协议
|
|
|
+ startDate
|
|
|
+ );
|
|
|
+ AssertionUtils.isFail(nameExists,"协议名称已存在,请输入其他名称");
|
|
|
+
|
|
|
+ // 3. 执行修改
|
|
|
agreementService.agreementEdit(param);
|
|
|
return HttpResult.ok("修改成功");
|
|
|
}
|
|
|
@@ -205,14 +221,23 @@ public class AgreementController extends BaseController {
|
|
|
@Operation(summary = "外部协议添加")
|
|
|
@PostMapping("/contactAdd")
|
|
|
public HttpResult contactAdd(@Validated @RequestBody AgreementContactAddParam param) {
|
|
|
-
|
|
|
- boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), null,1);
|
|
|
- AssertionUtils.isFail(nameExists,"协议名称重复!");
|
|
|
LocalDateTime startDate = param.getStartDate();
|
|
|
LocalDateTime endDate = param.getEndDate();
|
|
|
+ // 1. 时间合法性校验
|
|
|
if(endDate.isBefore(startDate) || startDate.isEqual(endDate)){
|
|
|
- AssertionUtils.isFail(nameExists,"协议生效时间不能大于失效时间!");
|
|
|
+ AssertionUtils.isFail(false,"协议生效时间不能大于失效时间!");
|
|
|
}
|
|
|
+
|
|
|
+ // 2. 名称+时间双重查重(外部=1)
|
|
|
+ boolean nameExists = agreementService.checkNameExistsWithDate(
|
|
|
+ param.getAgreementTitle(),
|
|
|
+ null, // 新增传null
|
|
|
+ 1, // 外部协议
|
|
|
+ startDate
|
|
|
+ );
|
|
|
+ AssertionUtils.isFail(nameExists,"协议名称已存在,请输入其他名称");
|
|
|
+
|
|
|
+ // 3. 执行保存
|
|
|
agreementService.contactAdd(param);
|
|
|
return HttpResult.ok("新增成功");
|
|
|
}
|
|
|
@@ -226,14 +251,24 @@ public class AgreementController extends BaseController {
|
|
|
@Operation(summary = "外部协议修改")
|
|
|
@PostMapping("/contactEdit")
|
|
|
public HttpResult contactEdit(@Validated @RequestBody AgreementContactEditParam param) {
|
|
|
-
|
|
|
- boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), param.getId(),1);
|
|
|
- AssertionUtils.isFail(nameExists,"协议名称重复!");
|
|
|
LocalDateTime startDate = param.getStartDate();
|
|
|
LocalDateTime endDate = param.getEndDate();
|
|
|
+
|
|
|
+ // 1. 时间合法性校验
|
|
|
if(endDate.isBefore(startDate) || startDate.isEqual(endDate)){
|
|
|
- AssertionUtils.isFail(nameExists,"协议生效时间不能大于失效时间!");
|
|
|
+ AssertionUtils.isFail(false,"协议生效时间不能大于失效时间!");
|
|
|
}
|
|
|
+
|
|
|
+ // 2. 名称+时间双重查重(外部=1,编辑排除自身)
|
|
|
+ boolean nameExists = agreementService.checkNameExistsWithDate(
|
|
|
+ param.getAgreementTitle(),
|
|
|
+ param.getId(), // 编辑传自身ID
|
|
|
+ 1, // 外部协议
|
|
|
+ startDate
|
|
|
+ );
|
|
|
+ AssertionUtils.isFail(nameExists,"协议名称已存在,请输入其他名称");
|
|
|
+
|
|
|
+ // 3. 执行修改
|
|
|
agreementService.contactEdit(param);
|
|
|
return HttpResult.ok("修改成功");
|
|
|
}
|