bpm:code review 快搭实现

This commit is contained in:
YunaiV 2024-04-18 12:38:38 +08:00
parent 1e30e4851a
commit 5d390d2d65
8 changed files with 28 additions and 11 deletions

View File

@ -13,14 +13,22 @@ import lombok.Getter;
@AllArgsConstructor
public enum BpmFieldPermissionEnum {
// TODO @jason改成 WRITEREADNONE更符合权限的感觉哈
EDITABLE(1, "可编辑"),
READONLY(2, "只读"),
HIDE(3, "隐藏");
/**
* 权限
*/
private final Integer permission;
/**
* 名字
*/
private final String name;
public static BpmFieldPermissionEnum valueOf(Integer permission) {
return ArrayUtil.firstMatch(item -> item.getPermission().equals(permission), values());
}
}

View File

@ -38,6 +38,7 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
/**
* 判断是否为分支节点
*
* @param type 节点类型
*/
public static boolean isBranchNode(Integer type) {

View File

@ -95,6 +95,7 @@ public interface BpmTaskConvert {
BpmFormDO form = MapUtil.get(formMap, NumberUtils.parseLong(task.getFormKey()), BpmFormDO.class);
if (form != null) {
// 测试一下权限处理
// TODO @jason这里是不是还没实现完哈
// List<String> afterChangedFields = BpmnFormUtils.changeCreateFormFiledPermissionRule(form.getFields(),
// BpmnModelUtils.parseFormFieldsPermission(bpmnModel, task.getTaskDefinitionKey()));

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
// TODO @jason这个类挪到 BpmnModelConstants 会不会好点因为后续 BPMN 标准也需要使用这些字段哈
/**
* 仿钉钉快搭 JSON 常量信息
*
@ -7,18 +8,20 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
*/
public interface SimpleModelConstants {
// TODO @jason改成 FORM_FIELD_PERMISSION_ELEMENT 会不会更精准哈
/**
* 流程表单字段权限, 用于标记字段权限
*/
String FIELDS_PERMISSION = "fieldsPermission";
// TODO @jason改成 FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE 会不会更精准哈
/**
* 字段属性
*/
String FIELD_ATTRIBUTE = "field";
// TODO @jason改成 FORM_FIELD_PERMISSION_ELEMENT_PERMISSION_ATTRIBUTE 会不会更精准哈
/**
* 权限属性
*/
String PERMISSION_ATTRIBUTE = "permission";
}

View File

@ -25,11 +25,12 @@ public class BpmnModelUtils {
public static Integer parseCandidateStrategy(FlowElement userTask) {
Integer candidateStrategy = NumberUtils.parseInt(userTask.getAttributeValue(
BpmnModelConstants.NAMESPACE, BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY));
// @芋艿 尝试从 ExtensionElement . 后续相关扩展是否都可以 extensionElement 如表单权限 按钮权限
// TODO @芋艿 尝试从 ExtensionElement . 后续相关扩展是否都可以 extensionElement 如表单权限 按钮权限
if (candidateStrategy == null) {
ExtensionElement element = CollUtil.getFirst(userTask.getExtensionElements().get(BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY));
// TODO @jason改成下面这样是不是看着更简洁哈
// candidateStrategy = element != null ? NumberUtils.parseInt(element.getElementText()) : null;
candidateStrategy = NumberUtils.parseInt(Optional.ofNullable(element).map(ExtensionElement::getElementText).orElse(null));
}
return candidateStrategy;
}
@ -44,16 +45,17 @@ public class BpmnModelUtils {
return candidateParam;
}
// TODO @jason貌似这个没地方调用
public static Map<String, Integer> parseFormFieldsPermission(BpmnModel bpmnModel, String flowElementId) {
FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId);
if (flowElement == null) {
return null;
}
final HashMap<String, Integer> fieldsPermission = MapUtil.newHashMap();
Map<String, Integer> fieldsPermission = MapUtil.newHashMap();
List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(SimpleModelConstants.FIELDS_PERMISSION);
extensionElements.forEach(el -> {
String field = el.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FIELD_ATTRIBUTE);
String permission = el.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, SimpleModelConstants.PERMISSION_ATTRIBUTE);
extensionElements.forEach(element -> {
String field = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FIELD_ATTRIBUTE);
String permission = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, SimpleModelConstants.PERMISSION_ATTRIBUTE);
if (StrUtil.isNotEmpty(field) && StrUtil.isNotEmpty(permission)) {
fieldsPermission.put(field, Integer.parseInt(permission));
}

View File

@ -207,7 +207,6 @@ public class SimpleModelUtils {
// TODO @jason建议使用 ServiceTask通过 executionListeners 实现
// @芋艿 ServiceTask 就可以了吧 不需要 executionListeners
addCandidateElements(node, serviceTask);
return serviceTask;
}

View File

@ -15,12 +15,14 @@ import java.util.Map;
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.FIELD_ATTRIBUTE;
// TODO @jason这个类挪到 framework 那的 util 包下哈
/**
* Bpmn 流程表单相关工具方法
*
* @author jason
*/
public class BpmnFormUtils {
private static final String CREATE_FORM_DISPLAY_ATTRIBUTE = "display";
private static final String CREATE_FORM_DISABLED_ATTRIBUTE = "disabled";
@ -65,4 +67,5 @@ public class BpmnFormUtils {
});
return afterChangedFields;
}
}