Skip to content

Commit 96e7148

Browse files
committed
add save event
1 parent 4cc7b3c commit 96e7148

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

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());

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

Lines changed: 6 additions & 0 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;
@@ -79,6 +81,10 @@ public boolean isTodo() {
7981
return state == STATE_TODO;
8082
}
8183

84+
public boolean isSave() {
85+
return state == STATE_SAVE;
86+
}
87+
8288
public boolean isCreate() {
8389
return state == STATE_CREATE;
8490
}

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);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy