Skip to content

Commit 61f0323

Browse files
authored
Merge pull request #113 from codingapi/dev
Dev
2 parents 2463231 + 96e7148 commit 61f0323

File tree

31 files changed

+288
-24
lines changed

31 files changed

+288
-24
lines changed

example/example-app/example-app-cmd-domain/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-app</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-app/example-app-cmd-meta/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-app</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-app/example-app-query/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-app</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-example</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212
<packaging>pom</packaging>

example/example-domain/example-domain-leave/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-domain</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-domain/example-domain-user/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-domain</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-domain/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-example</artifactId>
8-
<version>3.4.1</version>
8+
<version>3.4.2</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

example/example-infra/example-infra-flow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>example-infra</artifactId>
8-
<version>3.4.1</version>
8+
<version>3.4.2</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

example/example-infra/example-infra-jpa/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>example-infra</artifactId>
8-
<version>3.4.1</version>
8+
<version>3.4.2</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

example/example-infra/example-infra-security/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-infra</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-infra/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-example</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212
<packaging>pom</packaging>

example/example-interface/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-example</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
</parent>
1111

1212
<artifactId>example-interface</artifactId>

example/example-interface/src/main/java/com/codingapi/example/handler/LeaveHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import com.codingapi.springboot.flow.event.FlowApprovalEvent;
66
import com.codingapi.springboot.framework.event.IHandler;
77
import lombok.AllArgsConstructor;
8+
import lombok.extern.slf4j.Slf4j;
89
import org.springframework.stereotype.Service;
910

11+
@Slf4j
1012
@Service
1113
@AllArgsConstructor
1214
public class LeaveHandler implements IHandler<FlowApprovalEvent> {
@@ -15,6 +17,7 @@ public class LeaveHandler implements IHandler<FlowApprovalEvent> {
1517

1618
@Override
1719
public void handler(FlowApprovalEvent event) {
20+
log.info("LeaveHandler: {}", event);
1821
if (event.isFinish() && event.match(LeaveForm.class)) {
1922
LeaveForm form = (LeaveForm) event.getBindData();
2023
leaveService.create(form.toLeave());

example/example-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.4.1</version>
8+
<version>3.4.2</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</parent>
2020

2121
<artifactId>springboot-example</artifactId>
22-
<version>3.4.1</version>
22+
<version>3.4.2</version>
2323

2424
<name>springboot-example</name>
2525
<description>springboot-example project for Spring Boot</description>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.codingapi.springboot</groupId>
1414
<artifactId>springboot-parent</artifactId>
15-
<version>3.4.1</version>
15+
<version>3.4.2</version>
1616

1717
<url>https://github.com/codingapi/springboot-framewrok</url>
1818
<name>springboot-parent</name>

springboot-starter-data-authorization/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-parent</artifactId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-data-authorization</artifactId>

springboot-starter-data-fast/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.4.1</version>
8+
<version>3.4.2</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-flow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>3.4.1</version>
9+
<version>3.4.2</version>
1010
</parent>
1111

1212
<name>springboot-starter-flow</name>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.codingapi.springboot.flow.bind;
2+
3+
import com.alibaba.fastjson.JSONObject;
4+
5+
import java.util.HashMap;
6+
7+
/**
8+
* 流程绑定Map数据对象,用于分布式服务下的流程对象数据传递能力
9+
* 该对象中,将clazzName 当做了普通的key来使用,
10+
*/
11+
public class FlowMapBindData extends HashMap<String, Object> implements IBindData {
12+
13+
14+
/**
15+
* 获取类名称
16+
*
17+
* @return 类名称
18+
*/
19+
@Override
20+
public String getClazzName() {
21+
return (String) this.get(CLASS_NAME_KEY);
22+
}
23+
24+
/**
25+
* 转化为类对象
26+
*/
27+
@Override
28+
public <T> T toJavaObject(Class<T> clazz) {
29+
return JSONObject.parseObject(toJsonSnapshot(), clazz);
30+
}
31+
32+
public static FlowMapBindData fromJson(String json) {
33+
return JSONObject.parseObject(json, FlowMapBindData.class);
34+
}
35+
36+
public static FlowMapBindData fromObject(Object obj) {
37+
return JSONObject.parseObject(JSONObject.toJSONString(obj), FlowMapBindData.class);
38+
}
39+
40+
public static FlowMapBindData fromJson(JSONObject json) {
41+
return JSONObject.parseObject(json.toJSONString(), FlowMapBindData.class);
42+
}
43+
44+
public boolean match(String matchKey) {
45+
String className = this.getClazzName();
46+
return matchKey.equals(className);
47+
}
48+
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/bind/IBindData.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
public interface IBindData {
99

10+
String CLASS_NAME_KEY = "clazzName";
11+
1012
/**
1113
* 数据快照
1214
*
@@ -19,9 +21,27 @@ default String toJsonSnapshot() {
1921

2022
/**
2123
* 获取类名称
24+
*
2225
* @return 类名称
2326
*/
2427
default String getClazzName() {
2528
return this.getClass().getName();
2629
}
30+
31+
32+
/**
33+
* 类对象匹配
34+
*/
35+
default boolean match(String dataKey) {
36+
String className = this.getClazzName();
37+
return dataKey.equals(className);
38+
}
39+
40+
41+
/**
42+
* 转化为类对象
43+
*/
44+
default <T> T toJavaObject(Class<T> clazz) {
45+
return (T) this;
46+
}
2747
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/event/FlowApprovalEvent.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class FlowApprovalEvent implements ISyncEvent {
3434
public static final int STATE_URGE = 8;
3535
// 抄送
3636
public static final int STATE_CIRCULATE = 9;
37+
// 保存
38+
public static final int STATE_SAVE = 10;
3739

3840

3941
private final int state;
@@ -52,8 +54,23 @@ public FlowApprovalEvent(int state, FlowRecord flowRecord, IFlowOperator operato
5254
}
5355

5456

55-
public boolean match(Class<?> bindDataClass) {
56-
return bindDataClass.isInstance(bindData);
57+
public boolean match(String matchKey) {
58+
return bindData.match(matchKey);
59+
}
60+
61+
/**
62+
* 匹配类名
63+
* 当前bingData下的clazzName变成了普通的key字段了,推荐使用match(String matchKey)方法
64+
* @param clazz 类名
65+
* @return 是否匹配
66+
*/
67+
@Deprecated
68+
public boolean match(Class<?> clazz) {
69+
return bindData.match(clazz.getName());
70+
}
71+
72+
public <T> T toJavaObject(Class<T> clazz) {
73+
return bindData.toJavaObject(clazz);
5774
}
5875

5976
public boolean isUrge() {
@@ -64,6 +81,10 @@ public boolean isTodo() {
6481
return state == STATE_TODO;
6582
}
6683

84+
public boolean isSave() {
85+
return state == STATE_SAVE;
86+
}
87+
6788
public boolean isCreate() {
6889
return state == STATE_CREATE;
6990
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/impl/FlowSaveService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import com.codingapi.springboot.flow.bind.BindDataSnapshot;
44
import com.codingapi.springboot.flow.bind.IBindData;
5+
import com.codingapi.springboot.flow.domain.FlowWork;
56
import com.codingapi.springboot.flow.domain.Opinion;
7+
import com.codingapi.springboot.flow.event.FlowApprovalEvent;
68
import com.codingapi.springboot.flow.record.FlowRecord;
79
import com.codingapi.springboot.flow.repository.*;
810
import com.codingapi.springboot.flow.service.FlowRecordVerifyService;
911
import com.codingapi.springboot.flow.user.IFlowOperator;
12+
import com.codingapi.springboot.framework.event.EventPusher;
1013
import lombok.AllArgsConstructor;
1114
import org.springframework.transaction.annotation.Transactional;
1215

@@ -45,6 +48,15 @@ public void save(long recordId, IFlowOperator currentOperator, IBindData bindDat
4548

4649
flowRecord.setOpinion(opinion);
4750
flowRecordRepository.update(flowRecord);
51+
52+
FlowWork flowWork = flowRecordVerifyService.getFlowWork();
53+
54+
EventPusher.push(new FlowApprovalEvent(FlowApprovalEvent.STATE_SAVE,
55+
flowRecord,
56+
flowRecord.getCurrentOperator(),
57+
flowWork,
58+
snapshot.toBindData()),
59+
true);
4860
}
4961

5062
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/impl/FlowStartService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.codingapi.springboot.flow.em.FlowSourceDirection;
99
import com.codingapi.springboot.flow.event.FlowApprovalEvent;
1010
import com.codingapi.springboot.flow.pojo.FlowResult;
11-
import com.codingapi.springboot.flow.pojo.FlowSubmitResult;
1211
import com.codingapi.springboot.flow.record.FlowBackup;
1312
import com.codingapi.springboot.flow.record.FlowProcess;
1413
import com.codingapi.springboot.flow.record.FlowRecord;
@@ -190,6 +189,7 @@ public FlowResult startFlow() {
190189
for (FlowRecord record : records) {
191190
this.pushEvent(FlowApprovalEvent.STATE_CREATE, record);
192191
this.pushEvent(FlowApprovalEvent.STATE_TODO, record);
192+
this.pushEvent(FlowApprovalEvent.STATE_SAVE, record);
193193
}
194194
// 当前的审批记录
195195
return new FlowResult(flowWork, records);

springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/flow/Leave.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.codingapi.springboot.flow.flow;
22

33
import com.codingapi.springboot.flow.bind.IBindData;
4+
import lombok.AllArgsConstructor;
45
import lombok.Getter;
6+
import lombok.NoArgsConstructor;
57
import lombok.Setter;
68

79
@Setter
810
@Getter
11+
@NoArgsConstructor
12+
@AllArgsConstructor
913
public class Leave implements IBindData {
1014

1115
private long id;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.codingapi.springboot.flow.flow;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
@Setter
7+
@Getter
8+
public class Leave2 {
9+
10+
private long id;
11+
private String title;
12+
private int days;
13+
14+
public Leave2(String title) {
15+
this(title,0);
16+
}
17+
18+
public Leave2(String title, int days) {
19+
this.title = title;
20+
this.days = days;
21+
}
22+
23+
}

0 commit comments

Comments
 (0)