Skip to content

Commit ef27002

Browse files
committed
update 2.9.25
1 parent 7d0b79e commit ef27002

File tree

15 files changed

+171
-8
lines changed

15 files changed

+171
-8
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<groupId>com.codingapi.springboot</groupId>
1717
<artifactId>springboot-parent</artifactId>
18-
<version>2.9.24</version>
18+
<version>2.9.25</version>
1919

2020
<url>https://github.com/codingapi/springboot-framewrok</url>
2121
<name>springboot-parent</name>

springboot-starter-data-authorization/pom.xml

+1-1
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>2.9.24</version>
9+
<version>2.9.25</version>
1010
</parent>
1111

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

springboot-starter-data-fast/pom.xml

+1-1
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>2.9.24</version>
8+
<version>2.9.25</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-flow/pom.xml

+1-1
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>2.9.24</version>
9+
<version>2.9.25</version>
1010
</parent>
1111

1212
<name>springboot-starter-flow</name>

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/em/FlowButtonType.java

+2
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ public enum FlowButtonType {
2626
CUSTOM,
2727
// 前端
2828
VIEW,
29+
// 删除
30+
REMOVE,
2931
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/repository/FlowProcessRepository.java

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ public interface FlowProcessRepository {
1313

1414
FlowWork getFlowWorkByProcessId(String processId);
1515

16+
17+
void deleteByProcessId(String processId);
18+
1619
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/repository/FlowRecordRepository.java

+6
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ public interface FlowRecordRepository {
7171
*/
7272
void delete(List<FlowRecord> childrenRecords);
7373

74+
/**
75+
* 根据流程id删除流程记录
76+
* @param processId 流程id
77+
*/
78+
void deleteByProcessId(String processId);
79+
7480
}

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

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class FlowService {
2222
private final FlowDetailService flowDetailService;
2323
private final FlowCustomEventService flowCustomEventService;
2424
private final FlowRecallService flowRecallService;
25+
private final FlowRemoveService flowRemoveService;
2526
private final FlowSaveService flowSaveService;
2627
private final FlowTransferService flowTransferService;
2728
private final FlowPostponedService flowPostponedService;
@@ -40,6 +41,7 @@ public FlowService(FlowWorkRepository flowWorkRepository,
4041
this.flowDetailService = new FlowDetailService(flowWorkRepository, flowRecordRepository, flowBindDataRepository, flowOperatorRepository, flowProcessRepository);
4142
this.flowCustomEventService = new FlowCustomEventService(flowWorkRepository,flowRecordRepository, flowProcessRepository);
4243
this.flowRecallService = new FlowRecallService(flowWorkRepository,flowRecordRepository, flowProcessRepository);
44+
this.flowRemoveService = new FlowRemoveService(flowWorkRepository,flowRecordRepository, flowProcessRepository);
4345
this.flowSaveService = new FlowSaveService(flowWorkRepository,flowRecordRepository, flowBindDataRepository, flowProcessRepository);
4446
this.flowTransferService = new FlowTransferService(flowWorkRepository,flowRecordRepository, flowBindDataRepository, flowProcessRepository);
4547
this.flowPostponedService = new FlowPostponedService(flowWorkRepository,flowRecordRepository, flowProcessRepository);
@@ -239,4 +241,14 @@ public void recall(long recordId, IFlowOperator currentOperator) {
239241
}
240242

241243

244+
245+
/**
246+
* 删除流程
247+
*
248+
* @param recordId 流程记录id
249+
* @param currentOperator 当前操作者
250+
*/
251+
public void remove(long recordId, IFlowOperator currentOperator) {
252+
flowRemoveService.remove(recordId, currentOperator);
253+
}
242254
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.codingapi.springboot.flow.service.impl;
2+
3+
import com.codingapi.springboot.flow.domain.FlowNode;
4+
import com.codingapi.springboot.flow.domain.FlowWork;
5+
import com.codingapi.springboot.flow.event.FlowApprovalEvent;
6+
import com.codingapi.springboot.flow.record.FlowRecord;
7+
import com.codingapi.springboot.flow.repository.FlowProcessRepository;
8+
import com.codingapi.springboot.flow.repository.FlowRecordRepository;
9+
import com.codingapi.springboot.flow.repository.FlowWorkRepository;
10+
import com.codingapi.springboot.flow.service.FlowRecordVerifyService;
11+
import com.codingapi.springboot.flow.user.IFlowOperator;
12+
import com.codingapi.springboot.framework.event.EventPusher;
13+
import lombok.AllArgsConstructor;
14+
import org.springframework.transaction.annotation.Transactional;
15+
16+
import java.util.Collections;
17+
import java.util.List;
18+
19+
@Transactional
20+
@AllArgsConstructor
21+
public class FlowRemoveService {
22+
23+
private final FlowWorkRepository flowWorkRepository;
24+
private final FlowRecordRepository flowRecordRepository;
25+
private final FlowProcessRepository flowProcessRepository;
26+
27+
28+
/**
29+
* 删除流程
30+
*
31+
* @param recordId 流程记录id
32+
* @param currentOperator 当前操作者
33+
*/
34+
public void remove(long recordId, IFlowOperator currentOperator) {
35+
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(
36+
flowWorkRepository,
37+
flowRecordRepository,
38+
flowProcessRepository,
39+
recordId, currentOperator);
40+
41+
42+
flowRecordVerifyService.verifyFlowRecordCurrentOperator();
43+
flowRecordVerifyService.loadFlowWork();
44+
flowRecordVerifyService.loadFlowNode();
45+
flowRecordVerifyService.verifyFlowRecordNotFinish();
46+
flowRecordVerifyService.verifyFlowRecordIsTodo();
47+
FlowNode flowNode = flowRecordVerifyService.getFlowNode();
48+
FlowRecord flowRecord = flowRecordVerifyService.getFlowRecord();
49+
50+
if(!flowNode.isStartNode()){
51+
throw new IllegalArgumentException("flow record not remove");
52+
}
53+
54+
flowProcessRepository.deleteByProcessId(flowRecord.getProcessId());
55+
56+
flowRecordRepository.deleteByProcessId(flowRecord.getProcessId());
57+
}
58+
}

springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/repository/FlowProcessRepositoryImpl.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ public FlowWork getFlowWorkByProcessId(String processId) {
3535
return flowBackup.resume(userRepository);
3636
}
3737

38-
38+
@Override
39+
public void deleteByProcessId(String processId) {
40+
cache.removeIf(flowProcess -> flowProcess.getProcessId().equals(processId));
41+
}
3942
}

springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/repository/FlowRecordRepositoryImpl.java

+5
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,9 @@ public void finishFlowRecordByProcessId(String processId) {
161161
public void delete(List<FlowRecord> childrenRecords) {
162162
cache.removeAll(childrenRecords);
163163
}
164+
165+
@Override
166+
public void deleteByProcessId(String processId) {
167+
cache.removeIf(record -> record.getProcessId().equals(processId));
168+
}
164169
}

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

+74
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,80 @@ void recallTest1() {
893893
}
894894

895895

896+
897+
/**
898+
* 删除流程测试
899+
*/
900+
@Test
901+
void removeTest1() {
902+
PageRequest pageRequest = PageRequest.of(0, 1000);
903+
904+
User lorne = new User("lorne");
905+
userRepository.save(lorne);
906+
907+
User user = new User("张飞");
908+
userRepository.save(user);
909+
910+
User dept = new User("刘备");
911+
userRepository.save(dept);
912+
913+
User boss = new User("诸葛亮");
914+
userRepository.save(boss);
915+
916+
FlowWork flowWork = FlowWorkBuilder.builder(user)
917+
.title("请假流程")
918+
.nodes()
919+
.node("开始节点", "start", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
920+
.node("部门领导审批", "dept", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(dept.getUserId(),lorne.getUserId()))
921+
.node("总经理审批", "manager", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(boss.getUserId()))
922+
.node("结束节点", "over", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
923+
.relations()
924+
.relation("部门领导审批", "start", "dept")
925+
.relation("总经理审批", "dept", "manager")
926+
.relation("结束节点", "manager", "over")
927+
.build();
928+
929+
flowWorkRepository.save(flowWork);
930+
931+
String workCode = flowWork.getCode();
932+
933+
Leave leave = new Leave("我要出去看看");
934+
leaveRepository.save(leave);
935+
936+
// 创建流程
937+
flowService.startFlow(workCode, user, leave, "发起流程");
938+
939+
// 查看我的待办
940+
List<FlowRecord> userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
941+
assertEquals(1, userTodos.size());
942+
943+
// 提交流程
944+
FlowRecord userTodo = userTodos.get(0);
945+
946+
FlowSubmitResult flowSubmitResult = flowService.trySubmitFlow(userTodo.getId(), user, leave, Opinion.pass("同意"));
947+
assertEquals(flowSubmitResult.getOperators().size(), 2);
948+
assertTrue(flowSubmitResult.getOperators().stream().map(IFlowOperator::getUserId).collect(Collectors.toList()).contains(dept.getUserId()));
949+
assertTrue(flowSubmitResult.getOperators().stream().map(IFlowOperator::getUserId).collect(Collectors.toList()).contains(lorne.getUserId()));
950+
951+
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意").specify(dept.getUserId()));
952+
953+
954+
// 撤销流程
955+
flowService.recall(userTodo.getId(), user);
956+
userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
957+
assertEquals(1, userTodos.size());
958+
959+
List<FlowRecord> records = flowRecordRepository.findAll(pageRequest).getContent();
960+
assertEquals(1, records.size());
961+
962+
flowService.remove(userTodo.getId(), user);
963+
964+
records = flowRecordRepository.findAll(pageRequest).getContent();
965+
assertEquals(0, records.size());
966+
967+
}
968+
969+
896970
/**
897971
* 撤销流程测试
898972
*/

springboot-starter-security/pom.xml

+1-1
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>2.9.24</version>
9+
<version>2.9.25</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security</artifactId>

springboot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>2.9.24</version>
8+
<version>2.9.25</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
------------------------------------------------------
2-
CodingApi SpringBoot-Starter 2.9.24
2+
CodingApi SpringBoot-Starter 2.9.25
33
springboot version (${spring-boot.version})
44
------------------------------------------------------

0 commit comments

Comments
 (0)