Commit 5d390d2d65fb2213c97f333fb59837874cd62bcf

Authored by YunaiV
1 parent 1e30e485

bpm:code review 快搭实现

yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmFieldPermissionEnum.java
@@ -13,14 +13,22 @@ import lombok.Getter; @@ -13,14 +13,22 @@ import lombok.Getter;
13 @AllArgsConstructor 13 @AllArgsConstructor
14 public enum BpmFieldPermissionEnum { 14 public enum BpmFieldPermissionEnum {
15 15
  16 + // TODO @jason:改成 WRITE、READ、NONE,更符合权限的感觉哈
16 EDITABLE(1, "可编辑"), 17 EDITABLE(1, "可编辑"),
17 READONLY(2, "只读"), 18 READONLY(2, "只读"),
18 HIDE(3, "隐藏"); 19 HIDE(3, "隐藏");
19 20
  21 + /**
  22 + * 权限
  23 + */
20 private final Integer permission; 24 private final Integer permission;
  25 + /**
  26 + * 名字
  27 + */
21 private final String name; 28 private final String name;
22 29
23 public static BpmFieldPermissionEnum valueOf(Integer permission) { 30 public static BpmFieldPermissionEnum valueOf(Integer permission) {
24 return ArrayUtil.firstMatch(item -> item.getPermission().equals(permission), values()); 31 return ArrayUtil.firstMatch(item -> item.getPermission().equals(permission), values());
25 } 32 }
  33 +
26 } 34 }
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmSimpleModelNodeType.java
@@ -38,6 +38,7 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable { @@ -38,6 +38,7 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
38 38
39 /** 39 /**
40 * 判断是否为分支节点 40 * 判断是否为分支节点
  41 + *
41 * @param type 节点类型 42 * @param type 节点类型
42 */ 43 */
43 public static boolean isBranchNode(Integer type) { 44 public static boolean isBranchNode(Integer type) {
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java
@@ -141,7 +141,7 @@ public class BpmTaskController { @@ -141,7 +141,7 @@ public class BpmTaskController {
141 // 获得 BpmnModel 141 // 获得 BpmnModel
142 BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(processInstance.getProcessDefinitionId()); 142 BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(processInstance.getProcessDefinitionId());
143 return success(BpmTaskConvert.INSTANCE.buildTaskListByProcessInstanceId(taskList, processInstance, 143 return success(BpmTaskConvert.INSTANCE.buildTaskListByProcessInstanceId(taskList, processInstance,
144 - formMap, userMap, deptMap,bpmnModel)); 144 + formMap, userMap, deptMap, bpmnModel));
145 } 145 }
146 146
147 @PutMapping("/approve") 147 @PutMapping("/approve")
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
@@ -95,6 +95,7 @@ public interface BpmTaskConvert { @@ -95,6 +95,7 @@ public interface BpmTaskConvert {
95 BpmFormDO form = MapUtil.get(formMap, NumberUtils.parseLong(task.getFormKey()), BpmFormDO.class); 95 BpmFormDO form = MapUtil.get(formMap, NumberUtils.parseLong(task.getFormKey()), BpmFormDO.class);
96 if (form != null) { 96 if (form != null) {
97 // 测试一下权限处理 97 // 测试一下权限处理
  98 + // TODO @jason:这里是不是还没实现完哈?
98 // List<String> afterChangedFields = BpmnFormUtils.changeCreateFormFiledPermissionRule(form.getFields(), 99 // List<String> afterChangedFields = BpmnFormUtils.changeCreateFormFiledPermissionRule(form.getFields(),
99 // BpmnModelUtils.parseFormFieldsPermission(bpmnModel, task.getTaskDefinitionKey())); 100 // BpmnModelUtils.parseFormFieldsPermission(bpmnModel, task.getTaskDefinitionKey()));
100 101
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/SimpleModelConstants.java
1 package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; 1 package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
2 2
  3 +// TODO @jason:这个类,挪到 BpmnModelConstants 里,会不会好点,因为后续 BPMN 标准也需要使用这些字段哈;
3 /** 4 /**
4 * 仿钉钉快搭 JSON 常量信息 5 * 仿钉钉快搭 JSON 常量信息
5 * 6 *
@@ -7,18 +8,20 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; @@ -7,18 +8,20 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
7 */ 8 */
8 public interface SimpleModelConstants { 9 public interface SimpleModelConstants {
9 10
  11 + // TODO @jason:改成 FORM_FIELD_PERMISSION_ELEMENT 会不会更精准哈;
10 /** 12 /**
11 * 流程表单字段权限, 用于标记字段权限 13 * 流程表单字段权限, 用于标记字段权限
12 */ 14 */
13 String FIELDS_PERMISSION = "fieldsPermission"; 15 String FIELDS_PERMISSION = "fieldsPermission";
14 - 16 + // TODO @jason:改成 FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE 会不会更精准哈;
15 /** 17 /**
16 * 字段属性 18 * 字段属性
17 */ 19 */
18 String FIELD_ATTRIBUTE = "field"; 20 String FIELD_ATTRIBUTE = "field";
19 - 21 + // TODO @jason:改成 FORM_FIELD_PERMISSION_ELEMENT_PERMISSION_ATTRIBUTE 会不会更精准哈;
20 /** 22 /**
21 * 权限属性 23 * 权限属性
22 */ 24 */
23 String PERMISSION_ATTRIBUTE = "permission"; 25 String PERMISSION_ATTRIBUTE = "permission";
  26 +
24 } 27 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
@@ -25,11 +25,12 @@ public class BpmnModelUtils { @@ -25,11 +25,12 @@ public class BpmnModelUtils {
25 public static Integer parseCandidateStrategy(FlowElement userTask) { 25 public static Integer parseCandidateStrategy(FlowElement userTask) {
26 Integer candidateStrategy = NumberUtils.parseInt(userTask.getAttributeValue( 26 Integer candidateStrategy = NumberUtils.parseInt(userTask.getAttributeValue(
27 BpmnModelConstants.NAMESPACE, BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY)); 27 BpmnModelConstants.NAMESPACE, BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY));
28 - // @芋艿 尝试从 ExtensionElement 取. 后续相关扩展是否都可以 存 extensionElement。 如表单权限。 按钮权限 28 + // TODO @芋艿 尝试从 ExtensionElement 取. 后续相关扩展是否都可以 存 extensionElement。 如表单权限。 按钮权限
29 if (candidateStrategy == null) { 29 if (candidateStrategy == null) {
30 ExtensionElement element = CollUtil.getFirst(userTask.getExtensionElements().get(BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY)); 30 ExtensionElement element = CollUtil.getFirst(userTask.getExtensionElements().get(BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY));
  31 + // TODO @jason:改成下面这样,是不是看着更简洁哈
  32 +// candidateStrategy = element != null ? NumberUtils.parseInt(element.getElementText()) : null;
31 candidateStrategy = NumberUtils.parseInt(Optional.ofNullable(element).map(ExtensionElement::getElementText).orElse(null)); 33 candidateStrategy = NumberUtils.parseInt(Optional.ofNullable(element).map(ExtensionElement::getElementText).orElse(null));
32 -  
33 } 34 }
34 return candidateStrategy; 35 return candidateStrategy;
35 } 36 }
@@ -44,16 +45,17 @@ public class BpmnModelUtils { @@ -44,16 +45,17 @@ public class BpmnModelUtils {
44 return candidateParam; 45 return candidateParam;
45 } 46 }
46 47
47 - public static Map<String,Integer> parseFormFieldsPermission(BpmnModel bpmnModel, String flowElementId) { 48 + // TODO @jason:貌似这个没地方调用???
  49 + public static Map<String, Integer> parseFormFieldsPermission(BpmnModel bpmnModel, String flowElementId) {
48 FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId); 50 FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId);
49 if (flowElement == null) { 51 if (flowElement == null) {
50 return null; 52 return null;
51 } 53 }
52 - final HashMap<String, Integer> fieldsPermission = MapUtil.newHashMap(); 54 + Map<String, Integer> fieldsPermission = MapUtil.newHashMap();
53 List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(SimpleModelConstants.FIELDS_PERMISSION); 55 List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(SimpleModelConstants.FIELDS_PERMISSION);
54 - extensionElements.forEach(el -> {  
55 - String field = el.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FIELD_ATTRIBUTE);  
56 - String permission = el.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, SimpleModelConstants.PERMISSION_ATTRIBUTE); 56 + extensionElements.forEach(element -> {
  57 + String field = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FIELD_ATTRIBUTE);
  58 + String permission = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, SimpleModelConstants.PERMISSION_ATTRIBUTE);
57 if (StrUtil.isNotEmpty(field) && StrUtil.isNotEmpty(permission)) { 59 if (StrUtil.isNotEmpty(field) && StrUtil.isNotEmpty(permission)) {
58 fieldsPermission.put(field, Integer.parseInt(permission)); 60 fieldsPermission.put(field, Integer.parseInt(permission));
59 } 61 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
@@ -207,7 +207,6 @@ public class SimpleModelUtils { @@ -207,7 +207,6 @@ public class SimpleModelUtils {
207 // TODO @jason:建议使用 ServiceTask,通过 executionListeners 实现; 207 // TODO @jason:建议使用 ServiceTask,通过 executionListeners 实现;
208 // @芋艿 ServiceTask 就可以了吧。 不需要 executionListeners 208 // @芋艿 ServiceTask 就可以了吧。 不需要 executionListeners
209 addCandidateElements(node, serviceTask); 209 addCandidateElements(node, serviceTask);
210 -  
211 return serviceTask; 210 return serviceTask;
212 } 211 }
213 212
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/util/BpmnFormUtils.java
@@ -15,12 +15,14 @@ import java.util.Map; @@ -15,12 +15,14 @@ import java.util.Map;
15 15
16 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.FIELD_ATTRIBUTE; 16 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.FIELD_ATTRIBUTE;
17 17
  18 +// TODO @jason:这个类,挪到 framework 那的 util 包下哈;
18 /** 19 /**
19 * Bpmn 流程表单相关工具方法 20 * Bpmn 流程表单相关工具方法
20 * 21 *
21 * @author jason 22 * @author jason
22 */ 23 */
23 public class BpmnFormUtils { 24 public class BpmnFormUtils {
  25 +
24 private static final String CREATE_FORM_DISPLAY_ATTRIBUTE = "display"; 26 private static final String CREATE_FORM_DISPLAY_ATTRIBUTE = "display";
25 private static final String CREATE_FORM_DISABLED_ATTRIBUTE = "disabled"; 27 private static final String CREATE_FORM_DISABLED_ATTRIBUTE = "disabled";
26 28
@@ -65,4 +67,5 @@ public class BpmnFormUtils { @@ -65,4 +67,5 @@ public class BpmnFormUtils {
65 }); 67 });
66 return afterChangedFields; 68 return afterChangedFields;
67 } 69 }
  70 +
68 } 71 }