Skip to content

Commit c5354f4

Browse files
committed
update entity
1 parent ba27006 commit c5354f4

4 files changed

Lines changed: 73 additions & 42 deletions

File tree

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/convert/FlowRecordConvertor.java

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,53 @@
11
package com.codingapi.flow.infra.convert;
22

33
import com.codingapi.flow.infra.entity.FlowRecordEntity;
4+
import com.codingapi.flow.infra.entity.convert.MapConvertor;
45
import com.codingapi.flow.record.FlowRecord;
56

67
public class FlowRecordConvertor {
78

9+
private final static MapConvertor mapConvertor = new MapConvertor();
810

911
public static FlowRecord convert(FlowRecordEntity entity) {
1012
if (entity == null) {
1113
return null;
1214
}
13-
return new FlowRecord(entity.getId(), entity.getWorkBackupId(), entity.getWorkCode(), entity.getNodeId(), entity.getNodeType(),
14-
entity.getFromId(), entity.getFormData(), entity.getTitle(), entity.getReadTime(), entity.getProcessId(), entity.getActionId(),
15-
entity.getActionType(), entity.getAdvice(), entity.getSignKey(), entity.getCurrentOperatorId(),
16-
entity.getForwardOperatorId(), entity.getReturnNodeId(), entity.getNodeOrder(), entity.getHidden(), entity.getRevoked(),
17-
entity.getNotify(), entity.getRecordState(), entity.getFlowState(), entity.getUpdateTime(), entity.getCreateTime(),
18-
entity.getFinishTime(), entity.getReadable(), entity.getCreateOperatorId(), entity.getErrMessage(),
19-
entity.getTimeoutTime(), entity.getMergeable(), entity.getInterferedOperatorId(), entity.getDelegateId(),
20-
entity.getParallelId(), entity.getParallelBranchNodeId(), entity.getParallelBranchTotal());
15+
return new FlowRecord(entity.getId(),
16+
entity.getWorkBackupId(),
17+
entity.getWorkCode(),
18+
entity.getNodeId(),
19+
entity.getNodeType(),
20+
entity.getFromId(),
21+
mapConvertor.convertToEntityAttribute(entity.getFormData()),
22+
entity.getTitle(),
23+
entity.getReadTime(),
24+
entity.getProcessId(),
25+
entity.getActionId(),
26+
entity.getActionType(),
27+
entity.getAdvice(),
28+
entity.getSignKey(),
29+
entity.getCurrentOperatorId(),
30+
entity.getForwardOperatorId(),
31+
entity.getReturnNodeId(),
32+
entity.getNodeOrder(),
33+
entity.getHidden(),
34+
entity.getRevoked(),
35+
entity.getNotify(),
36+
entity.getRecordState(),
37+
entity.getFlowState(),
38+
entity.getUpdateTime(),
39+
entity.getCreateTime(),
40+
entity.getFinishTime(),
41+
entity.getReadable(),
42+
entity.getCreateOperatorId(),
43+
entity.getErrMessage(),
44+
entity.getTimeoutTime(),
45+
entity.getMergeable(),
46+
entity.getInterferedOperatorId(),
47+
entity.getDelegateId(),
48+
entity.getParallelId(),
49+
entity.getParallelBranchNodeId(),
50+
entity.getParallelBranchTotal());
2151
}
2252

2353
public static FlowRecordEntity convert(FlowRecord record) {
@@ -31,7 +61,7 @@ public static FlowRecordEntity convert(FlowRecord record) {
3161
entity.setNodeId(record.getNodeId());
3262
entity.setNodeType(record.getNodeType());
3363
entity.setFromId(record.getFromId());
34-
entity.setFormData(record.getFormData());
64+
entity.setFormData(mapConvertor.convertToDatabaseColumn(record.getFormData()));
3565
entity.setTitle(record.getTitle());
3666
entity.setReadTime(record.getReadTime());
3767
entity.setProcessId(record.getProcessId());
Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
package com.codingapi.flow.infra.convert;
22

33
import com.codingapi.flow.infra.entity.WorkflowEntity;
4+
import com.codingapi.flow.infra.entity.convert.*;
45
import com.codingapi.flow.workflow.Workflow;
56

67
public class WorkflowConvertor {
78

9+
private final static FlowOperatorConvertor flowOperatorConvertor = new FlowOperatorConvertor();
10+
private final static FlowNodeListConvertor flowNodeListConvertor = new FlowNodeListConvertor();
11+
private final static OperatorMatchScriptConvertor operatorMatchScriptConvertor = new OperatorMatchScriptConvertor();
12+
private final static WorkflowStrategyListConvertor workflowStrategyListConvertor = new WorkflowStrategyListConvertor();
13+
private final static FormMetaConvertor formMetaConvertor = new FormMetaConvertor();
14+
private final static FlowEdgeListConvertor flowEdgeListConvertor = new FlowEdgeListConvertor();
15+
16+
817
public static WorkflowEntity convert(Workflow workflow){
918
if(workflow==null){
1019
return null;
@@ -14,21 +23,32 @@ public static WorkflowEntity convert(Workflow workflow){
1423
entity.setId(workflow.getId());
1524
entity.setCode(workflow.getCode());
1625
entity.setTitle(workflow.getTitle());
17-
entity.setCreatedOperator(workflow.getCreatedOperator());
26+
27+
entity.setCreatedOperator(flowOperatorConvertor.convertToDatabaseColumn(workflow.getCreatedOperator()));
1828
entity.setCreatedTime(workflow.getCreatedTime());
19-
entity.setForm(workflow.getForm());
20-
entity.setOperatorCreateScript(workflow.getOperatorCreateScript());
21-
entity.setNodes(workflow.getNodes());
22-
entity.setEdges(workflow.getEdges());
29+
entity.setForm(formMetaConvertor.convertToDatabaseColumn(workflow.getForm()));
30+
entity.setOperatorCreateScript(operatorMatchScriptConvertor.convertToDatabaseColumn(workflow.getOperatorCreateScript()));
31+
entity.setNodes(flowNodeListConvertor.convertToDatabaseColumn(workflow.getNodes()));
32+
entity.setEdges(flowEdgeListConvertor.convertToDatabaseColumn(workflow.getEdges()));
2333
entity.setSchema(workflow.getSchema());
24-
entity.setStrategies(workflow.getStrategies());
34+
entity.setStrategies(workflowStrategyListConvertor.convertToDatabaseColumn(workflow.getStrategies()));
2535
return entity;
2636
}
2737

2838
public static Workflow convert(WorkflowEntity entity){
2939
if(entity==null){
3040
return null;
3141
}
32-
return new Workflow(entity.getId(), entity.getCode(), entity.getTitle(), entity.getCreatedOperator(), entity.getCreatedTime(), entity.getForm(), entity.getOperatorCreateScript(), entity.getNodes(), entity.getEdges(), entity.getSchema(), entity.getStrategies());
42+
return new Workflow(entity.getId(),
43+
entity.getCode(),
44+
entity.getTitle(),
45+
flowOperatorConvertor.convertToEntityAttribute(entity.getCreatedOperator()),
46+
entity.getCreatedTime(),
47+
formMetaConvertor.convertToEntityAttribute(entity.getForm()),
48+
operatorMatchScriptConvertor.convertToEntityAttribute(entity.getOperatorCreateScript()),
49+
flowNodeListConvertor.convertToEntityAttribute(entity.getNodes()),
50+
flowEdgeListConvertor.convertToEntityAttribute(entity.getEdges()),
51+
entity.getSchema(),
52+
workflowStrategyListConvertor.convertToEntityAttribute(entity.getStrategies()));
3353
}
3454
}

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/entity/FlowRecordEntity.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.codingapi.flow.infra.entity;
22

3-
import com.codingapi.flow.infra.entity.convert.MapConvertor;
43
import jakarta.persistence.*;
54
import lombok.Data;
65

7-
import java.util.Map;
8-
96
@Data
107
@Entity
118
@Table(name = "t_flow_record")
@@ -40,8 +37,7 @@ public class FlowRecordEntity {
4037
* 表单数据
4138
*/
4239
@Lob
43-
@Convert(converter = MapConvertor.class)
44-
private Map<String, Object> formData;
40+
private String formData;
4541
/**
4642
* 消息标题
4743
*/

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/entity/WorkflowEntity.java

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
package com.codingapi.flow.infra.entity;
22

3-
import com.codingapi.flow.edge.FlowEdge;
4-
import com.codingapi.flow.infra.entity.convert.*;
5-
import com.codingapi.flow.form.FormMeta;
6-
import com.codingapi.flow.node.IFlowNode;
7-
import com.codingapi.flow.operator.IFlowOperator;
8-
import com.codingapi.flow.script.node.OperatorMatchScript;
9-
import com.codingapi.flow.strategy.workflow.IWorkflowStrategy;
103
import jakarta.persistence.*;
114
import lombok.Data;
125
import org.hibernate.annotations.DynamicUpdate;
136

14-
import java.util.List;
15-
167
@Data
178
@Entity
189
@Table(name = "t_flow_workflow")
@@ -37,8 +28,7 @@ public class WorkflowEntity {
3728
/**
3829
* 创建者
3930
*/
40-
@Convert(converter = FlowOperatorConvertor.class)
41-
private IFlowOperator createdOperator;
31+
private Long createdOperator;
4232

4333
/**
4434
* 创建时间
@@ -49,29 +39,25 @@ public class WorkflowEntity {
4939
* 流程表单
5040
*/
5141
@Lob
52-
@Convert(converter = FormMetaConvertor.class)
53-
private FormMeta form;
42+
private String form;
5443

5544
/**
5645
* 创建者脚本
5746
*/
5847
@Lob
59-
@Convert(converter = OperatorMatchScriptConvertor.class)
60-
private OperatorMatchScript operatorCreateScript;
48+
private String operatorCreateScript;
6149

6250
/**
6351
* 流程节点
6452
*/
6553
@Lob
66-
@Convert(converter = FlowNodeListConvertor.class)
67-
private List<IFlowNode> nodes;
54+
private String nodes;
6855

6956
/**
7057
* 流程关系
7158
*/
7259
@Lob
73-
@Convert(converter = FlowEdgeListConvertor.class)
74-
private List<FlowEdge> edges;
60+
private String edges;
7561

7662
/**
7763
* 流程设计
@@ -83,6 +69,5 @@ public class WorkflowEntity {
8369
* 流程策略
8470
*/
8571
@Lob
86-
@Convert(converter = WorkflowStrategyListConvertor.class)
87-
private List<IWorkflowStrategy> strategies;
72+
private String strategies;
8873
}

0 commit comments

Comments
 (0)