Skip to content

Commit 23bac1c

Browse files
authored
Merge pull request #89 from codingapi/dev
Dev
2 parents 15fadb0 + f08c5ba commit 23bac1c

18 files changed

Lines changed: 98 additions & 31 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/form/DataType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
public enum DataType {
44
STRING,
55
NUMBER,
6-
DATE,
76
BOOLEAN
87
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.codingapi.flow.form;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* 附加属性
7+
*/
8+
@Data
9+
public class FieldAttribute {
10+
// 属性key
11+
private String key;
12+
// 属性名称
13+
private String label;
14+
// 属性值
15+
private String value;
16+
}

flow-engine-framework/src/main/java/com/codingapi/flow/form/FlowForm.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,26 @@ public static FlowForm fromMap(Map<String, Object> map) {
6666
fieldMeta.setId((String) field.get("id"));
6767
fieldMeta.setName((String) field.get("name"));
6868
fieldMeta.setCode((String) field.get("code"));
69-
fieldMeta.setType(DataType.valueOf((String) field.get("type")));
69+
fieldMeta.setType((String) field.get("type"));
70+
fieldMeta.setDataType(DataType.valueOf((String) field.get("dataType")));
7071
fieldMeta.setRequired(Boolean.TRUE.equals(field.get("required")));
7172
fieldMeta.setHidden(Boolean.TRUE.equals(field.get("hidden")));
7273
fieldMeta.setDefaultValue((String) field.get("defaultValue"));
7374
fieldMeta.setPlaceholder((String) field.get("placeholder"));
7475
fieldMeta.setTooltip((String) field.get("tooltip"));
7576
fieldMeta.setHelp((String) field.get("help"));
77+
List<Map<String, Object>> attributes = (List<Map<String, Object>>)field.get("attributes");
78+
if(attributes!=null) {
79+
List<FieldAttribute> attributeList = new ArrayList<>();
80+
for (Map<String, Object> attribute : attributes){
81+
FieldAttribute fieldAttribute = new FieldAttribute();
82+
fieldAttribute.setKey((String) attribute.get("key"));
83+
fieldAttribute.setLabel((String) attribute.get("label"));
84+
fieldAttribute.setValue((String) attribute.get("value"));
85+
attributeList.add(fieldAttribute);
86+
}
87+
fieldMeta.setAttributes(attributeList);
88+
}
7689
fieldList.add(fieldMeta);
7790
}
7891
}
@@ -108,10 +121,10 @@ public FormField getField(String fieldName) {
108121
return fields.stream().filter(field -> field.getName().equals(fieldName)).findFirst().orElse(null);
109122
}
110123

111-
private void initFormFieldTypes(FlowForm form, Map<String, DataType> types) {
124+
private void initFormFieldDataTypes(FlowForm form, Map<String, DataType> types) {
112125
for (FormField field : form.getFields()) {
113126
String key = form.getCode() + "." + field.getCode();
114-
DataType type = field.getType();
127+
DataType type = field.getDataType();
115128
types.put(key, type);
116129
}
117130
}
@@ -121,15 +134,15 @@ private void initFormFieldTypes(FlowForm form, Map<String, DataType> types) {
121134
*
122135
* @return 表单字段类型
123136
*/
124-
public Map<String, DataType> loadAllFieldTypeMaps() {
137+
public Map<String, DataType> loadAllFieldDataTypeMaps() {
125138
Map<String, DataType> types = new HashMap<>();
126139
List<FlowForm> forms = this.getSubForms();
127140
if (forms == null) {
128141
forms = new ArrayList<>();
129142
}
130143
forms.add(this);
131144
for (FlowForm subForm : forms) {
132-
this.initFormFieldTypes(subForm, types);
145+
this.initFormFieldDataTypes(subForm, types);
133146
}
134147
return types;
135148
}
@@ -145,7 +158,7 @@ public Map<String, DataType> loadMainFieldTypeMaps() {
145158
List<FlowForm> forms = new ArrayList<>();
146159
forms.add(this);
147160
for (FlowForm subForm : forms) {
148-
this.initFormFieldTypes(subForm, types);
161+
this.initFormFieldDataTypes(subForm, types);
149162
}
150163
return types;
151164
}

flow-engine-framework/src/main/java/com/codingapi/flow/form/FlowFormBuilder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.codingapi.flow.form;
22

33
import java.util.ArrayList;
4+
import java.util.Locale;
45

56
public class FlowFormBuilder {
67

@@ -23,11 +24,12 @@ public FlowFormBuilder code(String code) {
2324
return this;
2425
}
2526

26-
public FlowFormBuilder addField(String name, String code, DataType type) {
27+
public FlowFormBuilder addField(String name, String code, DataType dataType) {
2728
FormField field = new FormField();
2829
field.setName(name);
2930
field.setCode(code);
30-
field.setType(type);
31+
field.setDataType(dataType);
32+
field.setType(dataType.name().toLowerCase(Locale.ROOT));
3133
field.setRequired(true);
3234
field.setDefaultValue(null);
3335
return this.addField(field);

flow-engine-framework/src/main/java/com/codingapi/flow/form/FormField.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.codingapi.flow.utils.RandomUtils;
44
import lombok.Data;
55

6+
import java.util.List;
7+
68
/**
79
* 表单字段元数据
810
*/
@@ -16,7 +18,9 @@ public class FormField {
1618
// 字段编号
1719
private String code;
1820
// 字段类型
19-
private DataType type;
21+
private String type;
22+
// 数据类型
23+
private DataType dataType;
2024
// 是否隐藏
2125
private boolean hidden;
2226
// 是否必填
@@ -29,6 +33,9 @@ public class FormField {
2933
private String tooltip;
3034
// 帮助提示
3135
private String help;
36+
// 附加属性
37+
private List<FieldAttribute> attributes;
38+
3239

3340
public FormField() {
3441
this.id = RandomUtils.generateStringId();

flow-engine-framework/src/main/java/com/codingapi/flow/pojo/response/FlowRecordContent.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public class FlowRecordContent {
1818
/**
1919
* 工作id
2020
*/
21-
private Long workBackupId;
21+
private Long workflowRuntimeId;
22+
/**
23+
* 流程标题
24+
*/
25+
private String workTitle;
2226
/**
2327
* 流程编码
2428
*/
@@ -114,7 +118,7 @@ public class FlowRecordContent {
114118
public static FlowRecordContent convert(FlowRecord record){
115119
FlowRecordContent content = new FlowRecordContent();
116120
content.setProcessId(record.getProcessId());
117-
content.setWorkBackupId(record.getWorkRuntimeId());
121+
content.setWorkflowRuntimeId(record.getWorkRuntimeId());
118122
content.setWorkCode(record.getWorkCode());
119123
content.setNodeId(record.getNodeId());
120124
content.setNodeType(record.getNodeType());
@@ -139,7 +143,7 @@ public static FlowRecordContent convert(FlowRecord record){
139143
public static FlowRecordContent convert(FlowTodoRecord todoRecord){
140144
FlowRecordContent content = new FlowRecordContent();
141145
content.setProcessId(todoRecord.getProcessId());
142-
content.setWorkBackupId(todoRecord.getWorkBackupId());
146+
content.setWorkflowRuntimeId(todoRecord.getWorkflowRuntimeId());
143147
content.setWorkCode(todoRecord.getWorkCode());
144148
content.setNodeId(todoRecord.getNodeId());
145149
content.setNodeType(todoRecord.getNodeType());

flow-engine-framework/src/main/java/com/codingapi/flow/record/FlowRecord.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public class FlowRecord {
4848
* 工作id
4949
*/
5050
private long workRuntimeId;
51+
52+
/**
53+
* 流程名称
54+
*/
55+
private String workTitle;
5156
/**
5257
* 流程编码
5358
*/
@@ -263,7 +268,8 @@ public FlowRecord(FlowSession flowSession, int nodeOrder) {
263268
// 获取转交之后的审批人
264269
IFlowOperator currentOperator = flowSession.loadFinalForwardOperator(sourceOperator);
265270
this.workCode = flowSession.getWorkCode();
266-
this.workRuntimeId = flowSession.getBackupId();
271+
this.workRuntimeId = flowSession.getWorkflowRuntimeId();
272+
this.workTitle = flowSession.getWorkflow().getTitle();
267273
this.nodeId = flowSession.getCurrentNodeId();
268274
this.nodeType = flowSession.getCurrentNodeType();
269275
this.nodeName = flowSession.getCurrentNodeName();

flow-engine-framework/src/main/java/com/codingapi/flow/record/FlowTodoRecord.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ public class FlowTodoRecord {
2626
/**
2727
* 工作id
2828
*/
29-
private long workBackupId;
29+
private long workflowRuntimeId;
30+
31+
/**
32+
* 流程名称
33+
*/
34+
private String workTitle;
3035
/**
3136
* 流程编码
3237
*/
@@ -114,7 +119,8 @@ public FlowTodoRecord(FlowRecord flowRecord) {
114119

115120
public void update(FlowRecord flowRecord) {
116121
this.processId = flowRecord.getProcessId();
117-
this.workBackupId = flowRecord.getWorkRuntimeId();
122+
this.workflowRuntimeId = flowRecord.getWorkRuntimeId();
123+
this.workTitle = flowRecord.getWorkTitle();
118124
this.workCode = flowRecord.getWorkCode();
119125
this.nodeId = flowRecord.getNodeId();
120126
this.nodeType = flowRecord.getNodeType();

flow-engine-framework/src/main/java/com/codingapi/flow/session/FlowSession.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class FlowSession {
6363
/**
6464
* 流程备份id
6565
*/
66-
private final long backupId;
66+
private final long workflowRuntimeId;
6767

6868
/**
6969
* 审批意见
@@ -79,7 +79,7 @@ public FlowSession(IRepositoryHolder repositoryHolder,
7979
FormData formData,
8080
FlowRecord currentRecord,
8181
List<FlowRecord> currentNodeRecords,
82-
long backupId,
82+
long workflowRuntimeId,
8383
FlowAdvice advice) {
8484
this.repositoryHolder = repositoryHolder;
8585
this.currentOperator = currentOperator;
@@ -89,7 +89,7 @@ public FlowSession(IRepositoryHolder repositoryHolder,
8989
this.currentRecord = currentRecord;
9090
this.currentNodeRecords = currentNodeRecords;
9191
this.formData = formData;
92-
this.backupId = backupId;
92+
this.workflowRuntimeId = workflowRuntimeId;
9393
this.advice = advice;
9494
}
9595

@@ -229,7 +229,7 @@ public Object getFormData(String fieldCode) {
229229
* @return 新的会话
230230
*/
231231
public FlowSession updateSession(IFlowNode currentNode) {
232-
return new FlowSession(repositoryHolder,currentOperator, workflow, currentNode, currentAction, formData, currentRecord, currentNodeRecords, backupId, advice);
232+
return new FlowSession(repositoryHolder,currentOperator, workflow, currentNode, currentAction, formData, currentRecord, currentNodeRecords, workflowRuntimeId, advice);
233233
}
234234

235235

@@ -240,7 +240,7 @@ public FlowSession updateSession(IFlowNode currentNode) {
240240
* @return 新的会话
241241
*/
242242
public FlowSession updateSession(IFlowAction currentAction) {
243-
return new FlowSession(repositoryHolder,currentOperator, workflow, currentNode, currentAction, formData, currentRecord, currentNodeRecords, backupId, advice);
243+
return new FlowSession(repositoryHolder,currentOperator, workflow, currentNode, currentAction, formData, currentRecord, currentNodeRecords, workflowRuntimeId, advice);
244244
}
245245

246246
/**
@@ -250,7 +250,7 @@ public FlowSession updateSession(IFlowAction currentAction) {
250250
* @return 新的会话
251251
*/
252252
public FlowSession updateSession(IFlowOperator currentOperator) {
253-
return new FlowSession(repositoryHolder,currentOperator, workflow, currentNode, currentAction, formData, currentRecord, currentNodeRecords, backupId, advice);
253+
return new FlowSession(repositoryHolder,currentOperator, workflow, currentNode, currentAction, formData, currentRecord, currentNodeRecords, workflowRuntimeId, advice);
254254
}
255255

256256
}

flow-engine-framework/src/main/java/com/codingapi/flow/strategy/node/FormFieldPermissionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public FormFieldPermissionStrategy(List<FormFieldPermission> fieldPermissions) {
4444
*/
4545
@Override
4646
public void verifyNode(FlowForm form) {
47-
Map<String, DataType> fieldTypes = form.loadAllFieldTypeMaps();
47+
Map<String, DataType> fieldTypes = form.loadAllFieldDataTypeMaps();
4848
if(fieldPermissions!=null) {
4949
for (FormFieldPermission permission : fieldPermissions) {
5050
String key = permission.getFormCode() + "." + permission.getFieldCode();

0 commit comments

Comments
 (0)