mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-29 18:51:53 +08:00
仿钉钉流程设计- code review 修改
This commit is contained in:
parent
5d390d2d65
commit
cb5cfd31f0
@ -13,10 +13,9 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum BpmFieldPermissionEnum {
|
public enum BpmFieldPermissionEnum {
|
||||||
|
|
||||||
// TODO @jason:改成 WRITE、READ、NONE,更符合权限的感觉哈
|
WRITE(1, "可编辑"),
|
||||||
EDITABLE(1, "可编辑"),
|
READ(2, "只读"),
|
||||||
READONLY(2, "只读"),
|
NONE(3, "隐藏");
|
||||||
HIDE(3, "隐藏");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限
|
* 权限
|
||||||
|
@ -96,6 +96,7 @@ public interface BpmTaskConvert {
|
|||||||
if (form != null) {
|
if (form != null) {
|
||||||
// 测试一下权限处理
|
// 测试一下权限处理
|
||||||
// TODO @jason:这里是不是还没实现完哈?
|
// TODO @jason:这里是不是还没实现完哈?
|
||||||
|
// TODO @芋艿 测试了一下。 暂时注释掉。 前端不知道要怎样改, 可能需要讨论一下如何改
|
||||||
// List<String> afterChangedFields = BpmnFormUtils.changeCreateFormFiledPermissionRule(form.getFields(),
|
// List<String> afterChangedFields = BpmnFormUtils.changeCreateFormFiledPermissionRule(form.getFields(),
|
||||||
// BpmnModelUtils.parseFormFieldsPermission(bpmnModel, task.getTaskDefinitionKey()));
|
// BpmnModelUtils.parseFormFieldsPermission(bpmnModel, task.getTaskDefinitionKey()));
|
||||||
|
|
||||||
|
@ -28,6 +28,21 @@ public interface BpmnModelConstants {
|
|||||||
*/
|
*/
|
||||||
String USER_TASK_CANDIDATE_PARAM = "candidateParam";
|
String USER_TASK_CANDIDATE_PARAM = "candidateParam";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BPMN ExtensionElement 流程表单字段权限元素, 用于标记字段权限
|
||||||
|
*/
|
||||||
|
String FORM_FIELD_PERMISSION_ELEMENT = "fieldsPermission";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BPMN ExtensionElement Attribute, 用于标记表单字段
|
||||||
|
*/
|
||||||
|
String FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE = "field";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BPMN ExtensionElement Attribute, 用于标记表单权限
|
||||||
|
*/
|
||||||
|
String FORM_FIELD_PERMISSION_ELEMENT_PERMISSION_ATTRIBUTE = "permission";
|
||||||
|
|
||||||
// TODO @芋艿:这里后面得关注下;
|
// TODO @芋艿:这里后面得关注下;
|
||||||
/**
|
/**
|
||||||
* BPMN End Event 节点 Id, 用于后端生成 End Event 节点
|
* BPMN End Event 节点 Id, 用于后端生成 End Event 节点
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
|
||||||
|
|
||||||
// TODO @jason:这个类,挪到 BpmnModelConstants 里,会不会好点,因为后续 BPMN 标准也需要使用这些字段哈;
|
|
||||||
/**
|
/**
|
||||||
* 仿钉钉快搭 JSON 常量信息
|
* 仿钉钉快搭 JSON 常量信息
|
||||||
*
|
*
|
||||||
@ -8,20 +7,4 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
|
|||||||
*/
|
*/
|
||||||
public interface SimpleModelConstants {
|
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";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.service.util;
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
@ -13,9 +13,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.FIELD_ATTRIBUTE;
|
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE;
|
||||||
|
|
||||||
|
|
||||||
// TODO @jason:这个类,挪到 framework 那的 util 包下哈;
|
|
||||||
/**
|
/**
|
||||||
* Bpmn 流程表单相关工具方法
|
* Bpmn 流程表单相关工具方法
|
||||||
*
|
*
|
||||||
@ -39,23 +39,23 @@ public class BpmnFormUtils {
|
|||||||
List<String> afterChangedFields = new ArrayList<>(fields.size());
|
List<String> afterChangedFields = new ArrayList<>(fields.size());
|
||||||
fields.forEach( f-> {
|
fields.forEach( f-> {
|
||||||
Map<String, Object> fieldMap = JsonUtils.parseObject(f, new TypeReference<>() {});
|
Map<String, Object> fieldMap = JsonUtils.parseObject(f, new TypeReference<>() {});
|
||||||
String field = ObjUtil.defaultIfNull(fieldMap.get(FIELD_ATTRIBUTE), Object::toString, "");
|
String field = ObjUtil.defaultIfNull(fieldMap.get(FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE), Object::toString, "");
|
||||||
if (StrUtil.isEmpty(field) || !fieldsPermission.containsKey(field)) {
|
if (StrUtil.isEmpty(field) || !fieldsPermission.containsKey(field)) {
|
||||||
afterChangedFields.add(f);
|
afterChangedFields.add(f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BpmFieldPermissionEnum fieldPermission = BpmFieldPermissionEnum.valueOf(fieldsPermission.get(field));
|
BpmFieldPermissionEnum fieldPermission = BpmFieldPermissionEnum.valueOf(fieldsPermission.get(field));
|
||||||
Assert.notNull(fieldPermission, "字段权限不匹配");
|
Assert.notNull(fieldPermission, "字段权限不匹配");
|
||||||
if (BpmFieldPermissionEnum.HIDE == fieldPermission) {
|
if (BpmFieldPermissionEnum.NONE == fieldPermission) {
|
||||||
fieldMap.put(CREATE_FORM_DISPLAY_ATTRIBUTE, Boolean.FALSE);
|
fieldMap.put(CREATE_FORM_DISPLAY_ATTRIBUTE, Boolean.FALSE);
|
||||||
} else if (BpmFieldPermissionEnum.EDITABLE == fieldPermission){
|
} else if (BpmFieldPermissionEnum.WRITE == fieldPermission){
|
||||||
Map<String, Object> props = MapUtil.get(fieldMap, "props", new cn.hutool.core.lang.TypeReference<>() {});
|
Map<String, Object> props = MapUtil.get(fieldMap, "props", new cn.hutool.core.lang.TypeReference<>() {});
|
||||||
if (props == null) {
|
if (props == null) {
|
||||||
props = MapUtil.newHashMap();
|
props = MapUtil.newHashMap();
|
||||||
fieldMap.put("props", props);
|
fieldMap.put("props", props);
|
||||||
}
|
}
|
||||||
props.put(CREATE_FORM_DISABLED_ATTRIBUTE, Boolean.FALSE);
|
props.put(CREATE_FORM_DISABLED_ATTRIBUTE, Boolean.FALSE);
|
||||||
} else if (BpmFieldPermissionEnum.READONLY == fieldPermission) {
|
} else if (BpmFieldPermissionEnum.READ == fieldPermission) {
|
||||||
Map<String, Object> props = MapUtil.get(fieldMap, "props", new cn.hutool.core.lang.TypeReference<>() {});
|
Map<String, Object> props = MapUtil.get(fieldMap, "props", new cn.hutool.core.lang.TypeReference<>() {});
|
||||||
if (props == null) {
|
if (props == null) {
|
||||||
props = MapUtil.newHashMap();
|
props = MapUtil.newHashMap();
|
@ -6,7 +6,6 @@ import cn.hutool.core.util.ArrayUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants;
|
|
||||||
import org.flowable.bpmn.converter.BpmnXMLConverter;
|
import org.flowable.bpmn.converter.BpmnXMLConverter;
|
||||||
import org.flowable.bpmn.model.Process;
|
import org.flowable.bpmn.model.Process;
|
||||||
import org.flowable.bpmn.model.*;
|
import org.flowable.bpmn.model.*;
|
||||||
@ -14,7 +13,7 @@ import org.flowable.common.engine.impl.util.io.BytesStreamSource;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.FIELD_ATTRIBUTE;
|
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.*;
|
||||||
import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_NAMESPACE;
|
import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_NAMESPACE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,8 +27,6 @@ public class BpmnModelUtils {
|
|||||||
// TODO @芋艿 尝试从 ExtensionElement 取. 后续相关扩展是否都可以 存 extensionElement。 如表单权限。 按钮权限
|
// TODO @芋艿 尝试从 ExtensionElement 取. 后续相关扩展是否都可以 存 extensionElement。 如表单权限。 按钮权限
|
||||||
if (candidateStrategy == null) {
|
if (candidateStrategy == null) {
|
||||||
ExtensionElement element = CollUtil.getFirst(userTask.getExtensionElements().get(BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY));
|
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));
|
candidateStrategy = NumberUtils.parseInt(Optional.ofNullable(element).map(ExtensionElement::getElementText).orElse(null));
|
||||||
}
|
}
|
||||||
return candidateStrategy;
|
return candidateStrategy;
|
||||||
@ -45,17 +42,17 @@ public class BpmnModelUtils {
|
|||||||
return candidateParam;
|
return candidateParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @jason:貌似这个没地方调用???
|
// TODO @jason:貌似这个没地方调用??? @芋艿 在 BpmTaskConvert里面。暂时注释掉了。
|
||||||
public static Map<String, Integer> parseFormFieldsPermission(BpmnModel bpmnModel, String flowElementId) {
|
public static Map<String, Integer> parseFormFieldsPermission(BpmnModel bpmnModel, String flowElementId) {
|
||||||
FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId);
|
FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId);
|
||||||
if (flowElement == null) {
|
if (flowElement == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Map<String, Integer> fieldsPermission = MapUtil.newHashMap();
|
Map<String, Integer> fieldsPermission = MapUtil.newHashMap();
|
||||||
List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(SimpleModelConstants.FIELDS_PERMISSION);
|
List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(FORM_FIELD_PERMISSION_ELEMENT);
|
||||||
extensionElements.forEach(element -> {
|
extensionElements.forEach(element -> {
|
||||||
String field = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FIELD_ATTRIBUTE);
|
String field = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE);
|
||||||
String permission = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, SimpleModelConstants.PERMISSION_ATTRIBUTE);
|
String permission = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FORM_FIELD_PERMISSION_ELEMENT_PERMISSION_ATTRIBUTE);
|
||||||
if (StrUtil.isNotEmpty(field) && StrUtil.isNotEmpty(permission)) {
|
if (StrUtil.isNotEmpty(field) && StrUtil.isNotEmpty(permission)) {
|
||||||
fieldsPermission.put(field, Integer.parseInt(permission));
|
fieldsPermission.put(field, Integer.parseInt(permission));
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import org.flowable.bpmn.model.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.FIELDS_PERMISSION;
|
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.FORM_FIELD_PERMISSION_ELEMENT;
|
||||||
import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_NAMESPACE;
|
import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_NAMESPACE;
|
||||||
import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_PREFIX;
|
import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_PREFIX;
|
||||||
|
|
||||||
@ -267,9 +267,9 @@ public class SimpleModelUtils {
|
|||||||
*/
|
*/
|
||||||
private static void addFormFieldsPermission(BpmSimpleModelNodeVO node, FlowElement flowElement) {
|
private static void addFormFieldsPermission(BpmSimpleModelNodeVO node, FlowElement flowElement) {
|
||||||
List<Map<String, String>> fieldsPermissions = MapUtil.get(node.getAttributes(),
|
List<Map<String, String>> fieldsPermissions = MapUtil.get(node.getAttributes(),
|
||||||
FIELDS_PERMISSION, new TypeReference<>() {});
|
FORM_FIELD_PERMISSION_ELEMENT, new TypeReference<>() {});
|
||||||
if (CollUtil.isNotEmpty(fieldsPermissions)) {
|
if (CollUtil.isNotEmpty(fieldsPermissions)) {
|
||||||
fieldsPermissions.forEach(item -> addExtensionElement(flowElement, FIELDS_PERMISSION, item));
|
fieldsPermissions.forEach(item -> addExtensionElement(flowElement, FORM_FIELD_PERMISSION_ELEMENT, item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user