1、静态规则、动态规则、任务批量删除新增id、auditstatus合法性校验

2、Template新增auditstatus属性,修改query返回auditstatus,新增审批方法

(cherry picked from commit 03042f0aff)
This commit is contained in:
PushM
2024-04-29 11:44:15 +08:00
parent 076cb15a09
commit 335c9690ed
17 changed files with 236 additions and 17 deletions

View File

@@ -130,7 +130,7 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
public ResponseResult updateDynamicRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus) {
if (id <= 0 || auditStatus < 0 || auditStatus > 2) {
return new ResponseResult(400, "id or status is invalid")
.setData("staticRule_id", id)
.setData("dynamicRule_id", id)
.setData("success", false);
}
return ResponseResult.ok()

View File

@@ -58,4 +58,6 @@ public interface DynamicRuleMapper {
Boolean updateAuditStatusById(Integer dynamicRuleId, Integer auditStatus);
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);
List<Integer> queryAuditStatusByIds(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idsWithAuditStatusMap);
}

View File

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -211,6 +212,27 @@ public class DynamicRuleService {
}
public Object updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {
//校验id和status是否合法
List<Integer> originalAuditStatusList = dynamicRuleMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
int index = 0;
List<Integer> errorIds = new ArrayList<>();
for(Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
Integer id = entry.getKey();
Integer auditStatus = entry.getValue();
Integer originalAuditStatus = originalAuditStatusList.get(index);
index++;
if (originalAuditStatus == null) {
errorIds.add(id);
}
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
errorIds.add(id);
}
}
if (!errorIds.isEmpty()){
return new IllegalArgumentException("动态规则id不存在或无法修改为对应审核状态, errorIds: " + errorIds);
}
Function<DynamicRuleMapper, Function<Map<Integer, Integer>, Boolean>> updateDynamicRuleAuditStatusFunction =
mapper -> map -> {
if (map == null || map.isEmpty()) {

View File

@@ -50,4 +50,6 @@ public interface StaticRuleMapper {
Integer queryUsedStaticRuleTotalNum();
Integer queryAuditStaticRuleTotalNum(@Param("auditStatus")Integer auditStatus);
List<Integer> queryAuditStatusByIds(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idsWithAuditStatusMap);
}

View File

@@ -235,6 +235,25 @@ public class StaticRuleService {
}
public Object updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {
//校验id和status是否合法
List<Integer> originalAuditStatusList = staticRuleMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
int index = 0;
List<Integer> errorIds = new ArrayList<>();
for(Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {
Integer id = entry.getKey();
Integer auditStatus = entry.getValue();
Integer originalAuditStatus = originalAuditStatusList.get(index);
index++;
if (originalAuditStatus == null) {
errorIds.add(id);
}
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
errorIds.add(id);
}
}
if (!errorIds.isEmpty()){
return new IllegalArgumentException("静态规则id不存在或无法修改为对应审核状态, errorIds: " + errorIds);
}
Function<StaticRuleMapper, Function<Map<Integer, Integer>, Boolean>> updateStaticRuleAuditStatusFunction =
mapper -> map -> {