refactor(gxmu): 审批链层级校验下沉到 Service,删除路径也校验剩余链
- ReviewFlowController 里约 115 行的 validateLevels / validateUpdate /
validateBatchUpdate / validateRemaining / merge 下沉为
ReviewFlowService.validateLevelsOnSave / OnUpdate / OnBatchUpdate / OnRemove,
controller 只在写操作前调用一次
- remove / removeBatch 新增删除后剩余链连续性校验;删除前就已不连续的链跳过校验,
避免存量脏数据变成「永远删不掉」
- 顺手修掉一个真缺陷:merge 会就地改 existing,导致「改名后原链剩余校验」永远不触发
(批量路径同样先取旧标题再合并)
- 模块标题回退三份收敛成 ModuleRegistryService.titleOf(Map, module) 一处,
ReviewFlowConfigServiceImpl / ReviewListServiceImpl 直接调用
- ReviewFlowLevelValidator 的手写 join 换成 Collectors.joining(", ")
- 回填脚本头部补「表名 → 学院文本列」对照表,注明新增表按此表同步 4 处
refs #58
This commit is contained in:
@@ -1,33 +1,26 @@
|
||||
package com.gxwebsoft.gxmu.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.gxmu.service.ReviewFlowLevelValidator;
|
||||
import com.gxwebsoft.gxmu.service.ReviewFlowService;
|
||||
import com.gxwebsoft.gxmu.entity.ReviewFlow;
|
||||
import com.gxwebsoft.gxmu.param.ReviewFlowParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 审核流控制器
|
||||
*
|
||||
* <p>层级连续性(从 1 连续升序)是审批链的业务规则,校验落在
|
||||
* {@link ReviewFlowService#validateLevelsOnSave} 等方法的实现里;controller 只负责在写操作前调用一次。
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-18 10:37:18
|
||||
*/
|
||||
@@ -69,12 +62,7 @@ public class ReviewFlowController extends BaseController {
|
||||
@ApiOperation("添加审核流")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ReviewFlow reviewFlow) {
|
||||
validateLevels(reviewFlow == null ? null : java.util.Collections.singletonList(reviewFlow));
|
||||
// 记录当前登录用户id
|
||||
// ReviewFlow checkByName = reviewFlowService.getByTitle(reviewFlow.getTitle());
|
||||
// if (checkByName != null) {
|
||||
// return fail("该名称已存在");
|
||||
// }
|
||||
reviewFlowService.validateLevelsOnSave(reviewFlow == null ? null : Collections.singletonList(reviewFlow));
|
||||
if (reviewFlowService.save(reviewFlow)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
@@ -84,11 +72,7 @@ public class ReviewFlowController extends BaseController {
|
||||
@ApiOperation("修改审核流")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ReviewFlow reviewFlow) {
|
||||
validateUpdate(reviewFlow);
|
||||
// ReviewFlow checkByName = reviewFlowService.getByTitle(reviewFlow.getTitle());
|
||||
// if (checkByName != null && !Objects.equals(checkByName.getId(), reviewFlow.getId())) {
|
||||
// return fail("该名称已存在");
|
||||
// }
|
||||
reviewFlowService.validateLevelsOnUpdate(reviewFlow);
|
||||
if (reviewFlowService.updateById(reviewFlow)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
@@ -98,6 +82,7 @@ public class ReviewFlowController extends BaseController {
|
||||
@ApiOperation("删除审核流")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
reviewFlowService.validateLevelsOnRemove(Collections.singletonList(id));
|
||||
if (reviewFlowService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
@@ -107,7 +92,7 @@ public class ReviewFlowController extends BaseController {
|
||||
@ApiOperation("批量添加审核流")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ReviewFlow> list) {
|
||||
validateLevels(list);
|
||||
reviewFlowService.validateLevelsOnSave(list);
|
||||
if (reviewFlowService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
@@ -117,145 +102,17 @@ public class ReviewFlowController extends BaseController {
|
||||
@ApiOperation("批量修改审核流")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> updateBatch(@RequestBody BatchParam<ReviewFlow> batchParam) {
|
||||
validateBatchUpdate(batchParam);
|
||||
reviewFlowService.validateLevelsOnBatchUpdate(batchParam);
|
||||
if (batchParam.update(reviewFlowService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验"保存后这条审批链的层级从 1 连续升序"(spec #58 行为约定)。
|
||||
*
|
||||
* <p>管理端是"先删旧节点、再逐级新增",因此单条保存时必须把库里同 title 的已有节点一起看,
|
||||
* 否则逐级保存会被误判为缺级。
|
||||
*/
|
||||
private void validateLevels(List<ReviewFlow> incoming) {
|
||||
if (incoming == null || incoming.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<ReviewFlow> proposed = new ArrayList<>();
|
||||
Set<String> titles = new LinkedHashSet<>();
|
||||
Set<Integer> replacedIds = new LinkedHashSet<>();
|
||||
for (ReviewFlow flow : incoming) {
|
||||
if (flow == null) {
|
||||
continue;
|
||||
}
|
||||
proposed.add(flow);
|
||||
if (flow.getId() != null) {
|
||||
replacedIds.add(flow.getId());
|
||||
}
|
||||
if (flow.getTitle() != null) {
|
||||
titles.add(flow.getTitle().trim());
|
||||
}
|
||||
}
|
||||
for (String title : titles) {
|
||||
List<ReviewFlow> existing = reviewFlowService.listByTitle(title);
|
||||
if (existing == null) {
|
||||
continue;
|
||||
}
|
||||
for (ReviewFlow flow : existing) {
|
||||
if (flow != null && flow.getId() != null && !replacedIds.contains(flow.getId())) {
|
||||
proposed.add(flow);
|
||||
}
|
||||
}
|
||||
}
|
||||
ReviewFlowLevelValidator.validate(proposed);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改单条节点:未传的字段沿用库里原值(MyBatis-Plus 同样忽略 null),再校验受影响链的连续性。
|
||||
*/
|
||||
private void validateUpdate(ReviewFlow reviewFlow) {
|
||||
if (reviewFlow == null) {
|
||||
return;
|
||||
}
|
||||
ReviewFlow existing = reviewFlow.getId() == null ? null : reviewFlowService.getById(reviewFlow.getId());
|
||||
ReviewFlow merged = merge(existing, reviewFlow);
|
||||
validateLevels(java.util.Collections.singletonList(merged));
|
||||
if (existing != null && !sameTitle(existing.getTitle(), merged.getTitle())) {
|
||||
validateRemaining(existing.getTitle(), java.util.Collections.singletonList(reviewFlow.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改:BatchParam 只带一个 data,id 集合里每行都按同样字段更新。
|
||||
*/
|
||||
private void validateBatchUpdate(BatchParam<ReviewFlow> batchParam) {
|
||||
if (batchParam == null || batchParam.getData() == null
|
||||
|| batchParam.getIds() == null || batchParam.getIds().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
for (Serializable id : batchParam.getIds()) {
|
||||
if (id instanceof Number) {
|
||||
ids.add(((Number) id).intValue());
|
||||
}
|
||||
}
|
||||
if (ids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<ReviewFlow> existingRows = reviewFlowService.listByIds(ids);
|
||||
if (existingRows == null || existingRows.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<ReviewFlow> mergedRows = new ArrayList<>();
|
||||
List<String> oldTitles = new ArrayList<>();
|
||||
for (ReviewFlow existing : existingRows) {
|
||||
if (existing == null) {
|
||||
continue;
|
||||
}
|
||||
mergedRows.add(merge(existing, batchParam.getData()));
|
||||
oldTitles.add(existing.getTitle());
|
||||
}
|
||||
validateLevels(mergedRows);
|
||||
Set<String> newTitles = new LinkedHashSet<>();
|
||||
for (ReviewFlow row : mergedRows) {
|
||||
newTitles.add(row.getTitle() == null ? "" : row.getTitle().trim());
|
||||
}
|
||||
for (String oldTitle : oldTitles) {
|
||||
if (!newTitles.contains(oldTitle == null ? "" : oldTitle.trim())) {
|
||||
validateRemaining(oldTitle, ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验改名/移走后原审批链剩下的节点仍连续。
|
||||
*/
|
||||
private void validateRemaining(String title, Collection<Integer> excludedIds) {
|
||||
List<ReviewFlow> remaining = new ArrayList<>();
|
||||
List<ReviewFlow> existing = title == null ? null : reviewFlowService.listByTitle(title);
|
||||
if (existing != null) {
|
||||
for (ReviewFlow flow : existing) {
|
||||
if (flow != null && !excludedIds.contains(flow.getId())) {
|
||||
remaining.add(flow);
|
||||
}
|
||||
}
|
||||
}
|
||||
ReviewFlowLevelValidator.validate(remaining);
|
||||
}
|
||||
|
||||
private ReviewFlow merge(ReviewFlow existing, ReviewFlow incoming) {
|
||||
if (existing == null) {
|
||||
return incoming;
|
||||
}
|
||||
if (incoming.getTitle() != null) {
|
||||
existing.setTitle(incoming.getTitle());
|
||||
}
|
||||
if (incoming.getLevel() != null) {
|
||||
existing.setLevel(incoming.getLevel());
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
private boolean sameTitle(String left, String right) {
|
||||
return Objects.equals(left == null ? null : left.trim(), right == null ? null : right.trim());
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除审核流")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
reviewFlowService.validateLevelsOnRemove(ids);
|
||||
if (reviewFlowService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 审批链层级连续性校验(spec #58 行为约定:层级从 1 连续升序)。
|
||||
@@ -69,13 +70,6 @@ public final class ReviewFlowLevelValidator {
|
||||
}
|
||||
|
||||
private static String join(List<Integer> levels) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int index = 0; index < levels.size(); index++) {
|
||||
if (index > 0) {
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append(levels.get(index));
|
||||
}
|
||||
return builder.toString();
|
||||
return levels.stream().map(String::valueOf).collect(Collectors.joining(", "));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.gxwebsoft.gxmu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.gxmu.entity.ReviewFlow;
|
||||
import com.gxwebsoft.gxmu.param.ReviewFlowParam;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -42,4 +44,40 @@ public interface ReviewFlowService extends IService<ReviewFlow> {
|
||||
ReviewFlow getByTitle(String title);
|
||||
|
||||
List<ReviewFlow> listByTitle(String title);
|
||||
|
||||
/**
|
||||
* 保存前校验:保存后这条审批链的层级必须从 1 连续升序(spec #58 行为约定)。
|
||||
*
|
||||
* <p>管理端是"先删旧节点、再逐级新增",所以单条保存时必须把库里同 title 的已有节点一起看,
|
||||
* 否则逐级保存会被误判为缺级。不合法时抛
|
||||
* {@link com.gxwebsoft.common.core.exception.BusinessException}。
|
||||
*
|
||||
* @param incoming 本次提交的节点(可含多条审批链)
|
||||
*/
|
||||
void validateLevelsOnSave(List<ReviewFlow> incoming);
|
||||
|
||||
/**
|
||||
* 修改单条节点前校验:未传的字段沿用库里原值,再校验受影响链的连续性;
|
||||
* 若改了 title,还要校验原链剩下的节点仍连续。
|
||||
*
|
||||
* @param incoming 提交的节点
|
||||
*/
|
||||
void validateLevelsOnUpdate(ReviewFlow incoming);
|
||||
|
||||
/**
|
||||
* 批量修改前校验:id 集合里每行都按同样字段更新,合并后校验连续性,
|
||||
* 并校验改名后原链剩余部分仍连续。
|
||||
*
|
||||
* @param batchParam 批量参数
|
||||
*/
|
||||
void validateLevelsOnBatchUpdate(BatchParam<ReviewFlow> batchParam);
|
||||
|
||||
/**
|
||||
* 删除前校验:删除后受影响审批链剩下的节点必须仍从 1 连续升序。
|
||||
*
|
||||
* <p>删除前就已经不连续的链不做校验(否则存量脏数据会变成"永远删不掉")。
|
||||
*
|
||||
* @param removedIds 待删除的节点 id
|
||||
*/
|
||||
void validateLevelsOnRemove(Collection<Integer> removedIds);
|
||||
}
|
||||
|
||||
@@ -99,17 +99,9 @@ public class ReviewFlowConfigServiceImpl extends ServiceImpl<ReviewFlowConfigMap
|
||||
Map<String, String> moduleTitleMap = moduleRegistryService.titleMap();
|
||||
for (ReviewFlowConfig item : list) {
|
||||
item.setFlowName(flowNameMap.get(item.getFlowId()));
|
||||
item.setModuleName(moduleTitleOf(moduleTitleMap, item.getModule()));
|
||||
item.setModuleName(ModuleRegistryService.titleOf(moduleTitleMap, item.getModule()));
|
||||
item.setOrganizationName(organizationNameMap.get(item.getOrganizationId()));
|
||||
}
|
||||
}
|
||||
|
||||
private String moduleTitleOf(Map<String, String> moduleTitleMap, String module) {
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
String title = moduleTitleMap.get(module);
|
||||
return title == null || title.isEmpty() ? module : title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@ package com.gxwebsoft.gxmu.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.Organization;
|
||||
import com.gxwebsoft.common.system.service.OrganizationService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.gxmu.mapper.ReviewFlowMapper;
|
||||
import com.gxwebsoft.gxmu.service.ReviewFlowLevelValidator;
|
||||
import com.gxwebsoft.gxmu.service.ReviewFlowService;
|
||||
import com.gxwebsoft.gxmu.entity.ReviewFlow;
|
||||
import com.gxwebsoft.gxmu.param.ReviewFlowParam;
|
||||
@@ -14,7 +16,13 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 审核流Service实现
|
||||
@@ -91,4 +99,180 @@ public class ReviewFlowServiceImpl extends ServiceImpl<ReviewFlowMapper, ReviewF
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// 层级校验:审批链保存/删除的业务规则落在这里,controller 只负责调用
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void validateLevelsOnSave(List<ReviewFlow> incoming) {
|
||||
if (incoming == null || incoming.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<ReviewFlow> proposed = new ArrayList<>();
|
||||
Set<String> titles = new LinkedHashSet<>();
|
||||
Set<Integer> replacedIds = new LinkedHashSet<>();
|
||||
for (ReviewFlow flow : incoming) {
|
||||
if (flow == null) {
|
||||
continue;
|
||||
}
|
||||
proposed.add(flow);
|
||||
if (flow.getId() != null) {
|
||||
replacedIds.add(flow.getId());
|
||||
}
|
||||
if (flow.getTitle() != null) {
|
||||
titles.add(flow.getTitle().trim());
|
||||
}
|
||||
}
|
||||
for (String title : titles) {
|
||||
List<ReviewFlow> existing = listByTitle(title);
|
||||
if (existing == null) {
|
||||
continue;
|
||||
}
|
||||
for (ReviewFlow flow : existing) {
|
||||
if (flow != null && flow.getId() != null && !replacedIds.contains(flow.getId())) {
|
||||
proposed.add(flow);
|
||||
}
|
||||
}
|
||||
}
|
||||
ReviewFlowLevelValidator.validate(proposed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateLevelsOnUpdate(ReviewFlow incoming) {
|
||||
if (incoming == null) {
|
||||
return;
|
||||
}
|
||||
ReviewFlow existing = incoming.getId() == null ? null : getById(incoming.getId());
|
||||
// merge 会就地改 existing,旧标题必须先存下来,否则「改名后原链剩余校验」永远不触发
|
||||
String oldTitle = existing == null ? null : existing.getTitle();
|
||||
ReviewFlow merged = merge(existing, incoming);
|
||||
validateLevelsOnSave(java.util.Collections.singletonList(merged));
|
||||
if (existing != null && !sameTitle(oldTitle, merged.getTitle())) {
|
||||
validateRemaining(oldTitle, java.util.Collections.singletonList(incoming.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateLevelsOnBatchUpdate(BatchParam<ReviewFlow> batchParam) {
|
||||
if (batchParam == null || batchParam.getData() == null
|
||||
|| batchParam.getIds() == null || batchParam.getIds().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
for (Serializable id : batchParam.getIds()) {
|
||||
if (id instanceof Number) {
|
||||
ids.add(((Number) id).intValue());
|
||||
}
|
||||
}
|
||||
if (ids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<ReviewFlow> existingRows = listByIds(ids);
|
||||
if (existingRows == null || existingRows.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<ReviewFlow> mergedRows = new ArrayList<>();
|
||||
List<String> oldTitles = new ArrayList<>();
|
||||
for (ReviewFlow existing : existingRows) {
|
||||
if (existing == null) {
|
||||
continue;
|
||||
}
|
||||
// 同上:merge 就地改 existing,旧标题要先取
|
||||
oldTitles.add(existing.getTitle());
|
||||
mergedRows.add(merge(existing, batchParam.getData()));
|
||||
}
|
||||
validateLevelsOnSave(mergedRows);
|
||||
Set<String> newTitles = new LinkedHashSet<>();
|
||||
for (ReviewFlow row : mergedRows) {
|
||||
newTitles.add(row.getTitle() == null ? "" : row.getTitle().trim());
|
||||
}
|
||||
for (String oldTitle : oldTitles) {
|
||||
if (!newTitles.contains(oldTitle == null ? "" : oldTitle.trim())) {
|
||||
validateRemaining(oldTitle, ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateLevelsOnRemove(Collection<Integer> removedIds) {
|
||||
if (removedIds == null || removedIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
for (Integer id : removedIds) {
|
||||
if (id != null) {
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
if (ids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<ReviewFlow> removed = listByIds(ids);
|
||||
if (removed == null || removed.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Set<String> titles = new LinkedHashSet<>();
|
||||
for (ReviewFlow flow : removed) {
|
||||
if (flow != null && flow.getTitle() != null) {
|
||||
titles.add(flow.getTitle().trim());
|
||||
}
|
||||
}
|
||||
for (String title : titles) {
|
||||
List<ReviewFlow> before = listByTitle(title);
|
||||
if (before == null || before.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (!isContinuous(before)) {
|
||||
// 删除前就已经不连续:不把存量脏数据变成"永远删不掉"
|
||||
continue;
|
||||
}
|
||||
validateRemaining(title, ids);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验改名/移走后原审批链剩下的节点仍连续。
|
||||
*/
|
||||
private void validateRemaining(String title, Collection<Integer> excludedIds) {
|
||||
List<ReviewFlow> remaining = new ArrayList<>();
|
||||
List<ReviewFlow> existing = title == null ? null : listByTitle(title);
|
||||
if (existing != null) {
|
||||
for (ReviewFlow flow : existing) {
|
||||
if (flow != null && !excludedIds.contains(flow.getId())) {
|
||||
remaining.add(flow);
|
||||
}
|
||||
}
|
||||
}
|
||||
ReviewFlowLevelValidator.validate(remaining);
|
||||
}
|
||||
|
||||
/**
|
||||
* 这组节点本身是否已经连续(用于决定要不要在删除前做校验)。
|
||||
*/
|
||||
private boolean isContinuous(List<ReviewFlow> flows) {
|
||||
try {
|
||||
ReviewFlowLevelValidator.validate(flows);
|
||||
return true;
|
||||
} catch (com.gxwebsoft.common.core.exception.BusinessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private ReviewFlow merge(ReviewFlow existing, ReviewFlow incoming) {
|
||||
if (existing == null) {
|
||||
return incoming;
|
||||
}
|
||||
if (incoming.getTitle() != null) {
|
||||
existing.setTitle(incoming.getTitle());
|
||||
}
|
||||
if (incoming.getLevel() != null) {
|
||||
existing.setLevel(incoming.getLevel());
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
private boolean sameTitle(String left, String right) {
|
||||
return Objects.equals(left == null ? null : left.trim(), right == null ? null : right.trim());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,18 +86,10 @@ public class ReviewListServiceImpl extends ServiceImpl<ReviewListMapper, ReviewL
|
||||
// 模块标题以注册表为唯一来源;注册表里查不到的历史 module 回退原串,不让列表报错
|
||||
Map<String, String> moduleTitleMap = moduleRegistryService.titleMap();
|
||||
for (ReviewList item : list) {
|
||||
item.setModuleName(moduleTitleOf(moduleTitleMap, item.getModule()));
|
||||
item.setModuleName(ModuleRegistryService.titleOf(moduleTitleMap, item.getModule()));
|
||||
}
|
||||
}
|
||||
|
||||
private String moduleTitleOf(Map<String, String> moduleTitleMap, String module) {
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
String title = moduleTitleMap.get(module);
|
||||
return title == null || title.isEmpty() ? module : title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReviewList> listByModuleNPK(String module, Integer pk){
|
||||
return list(
|
||||
|
||||
Reference in New Issue
Block a user