Commit 41de0331 by 王志超

feat: 行动项必填项校验

parent ca25c1d0
Pipeline #86381 failed with stages
in 57 seconds
package com.netease.mail.yanxuan.change.biz.biz; package com.netease.mail.yanxuan.change.biz.biz;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.common.util.DateUtils; import com.netease.mail.yanxuan.change.common.util.DateUtils;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord; import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeExecConfigReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeExecConfigReq;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
...@@ -34,30 +30,6 @@ public class ChangeExecRecordBiz { ...@@ -34,30 +30,6 @@ public class ChangeExecRecordBiz {
List<ChangeExecConfigReq> changeExecProjectList, List<ChangeExecConfigReq> changeExecProjectList,
String subFlowId, String subFlowId,
Long subFlowRecordId) { Long subFlowRecordId) {
// 校验列表不为空
if (CollectionUtils.isEmpty(changeExecProjectList)) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项列表不能为空");
}
// 校验每个行动项的必填字段
changeExecProjectList.forEach(c -> {
if (StringUtils.isBlank(c.getChangeExecUser())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人不能为空");
}
if (StringUtils.isBlank(c.getChangeExecUserEmail())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人邮箱不能为空");
}
if (StringUtils.isBlank(c.getChangeRiskDesc())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更风险描述不能为空");
}
if (StringUtils.isBlank(c.getChangeExecProject())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中行动项内容不能为空");
}
if (c.getChangeExecFinishTime() == null || c.getChangeExecFinishTime() <= 0) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更完成时间不能为空");
}
});
return changeExecProjectList.stream().map(c -> { return changeExecProjectList.stream().map(c -> {
ChangeExecRecord changeExecRecord = new ChangeExecRecord(); ChangeExecRecord changeExecRecord = new ChangeExecRecord();
changeExecRecord.setChangeRecordId(changeRecordId); changeExecRecord.setChangeRecordId(changeRecordId);
......
...@@ -249,10 +249,31 @@ public class ChangeFlowBiz { ...@@ -249,10 +249,31 @@ public class ChangeFlowBiz {
changeFlowCreateReq.setChangeDepartment(changeConfig.getChangeDepartment()); changeFlowCreateReq.setChangeDepartment(changeConfig.getChangeDepartment());
// 变更行动项不可为空,最多20项 // 变更行动项不可为空,最多20项
List<ChangeExecConfigReq> changeExecProject = changeFlowCreateReq.getChangeExecProject(); List<ChangeExecConfigReq> changeExecProject = changeFlowCreateReq.getChangeExecProject();
if (CollectionUtils.isEmpty(changeExecProject)) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项列表不能为空");
}
Assert.isTrue(changeExecProject.size() <= appConfig.getChangeExecLimit(), Assert.isTrue(changeExecProject.size() <= appConfig.getChangeExecLimit(),
"变更行动方案配置数超限"); "变更行动方案配置数超限");
// 校验变更行动方案中是否有重复的变更行动人 // 校验变更行动方案中是否有重复的变更行动人
validateDuplicateChangeExecUser(changeExecProject); validateDuplicateChangeExecUser(changeExecProject);
// 校验每个行动项的必填字段
changeExecProject.forEach(c -> {
if (StringUtils.isBlank(c.getChangeExecUser())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人不能为空");
}
if (StringUtils.isBlank(c.getChangeExecUserEmail())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人邮箱不能为空");
}
if (StringUtils.isBlank(c.getChangeRiskDesc())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更风险描述不能为空");
}
if (StringUtils.isBlank(c.getChangeExecProject())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中行动项内容不能为空");
}
if (c.getChangeExecFinishTime() == null || c.getChangeExecFinishTime() <= 0) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更完成时间不能为空");
}
});
// 结束时间不可晚于第二天定时任务执行时间 // 结束时间不可晚于第二天定时任务执行时间
Long tomorrowSpecificTime = DateUtils.getTomorrowSpecificTime("00:00:00"); Long tomorrowSpecificTime = DateUtils.getTomorrowSpecificTime("00:00:00");
Assert.isTrue(changeFlowCreateReq.getChangeConfirmResultTime() >= tomorrowSpecificTime, "时间不可晚于下次执行时间"); Assert.isTrue(changeFlowCreateReq.getChangeConfirmResultTime() >= tomorrowSpecificTime, "时间不可晚于下次执行时间");
......
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