Skip to content

fix #108 #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-leave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.3.69</version>
<version>3.3.70</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>springboot-example</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>

<name>springboot-example</name>
<description>springboot-example project for Spring Boot</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
</parent>

<artifactId>springboot-starter-data-authorization</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-fast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.3.69</version>
<version>3.3.70</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.3.69</version>
<version>3.3.70</version>
</parent>

<name>springboot-starter-flow</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public void loadDefaultBackNode(FlowRecord currentRecord) {
boolean startRemove = false;
for(FlowRecord historyRecord: historyRecords){
if(startRemove){
if(historyRecord.getNodeCode().equals(currentRecord.getNodeCode())){
continue;
}
this.nextNode = flowWork.getNodeByCode(historyRecord.getNodeCode());
this.nextOperator = historyRecord.getCurrentOperator();
this.backOperator = historyRecord.getCurrentOperator();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package com.codingapi.springboot.flow.test;

import com.codingapi.springboot.flow.build.FlowWorkBuilder;
import com.codingapi.springboot.flow.domain.FlowWork;
import com.codingapi.springboot.flow.domain.Opinion;
import com.codingapi.springboot.flow.em.ApprovalType;
import com.codingapi.springboot.flow.flow.Leave;
import com.codingapi.springboot.flow.matcher.OperatorMatcher;
import com.codingapi.springboot.flow.record.FlowRecord;
import com.codingapi.springboot.flow.repository.*;
import com.codingapi.springboot.flow.service.FlowService;
import com.codingapi.springboot.flow.user.User;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.PageRequest;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class FlowTest3 {

private final UserRepository userRepository = new UserRepository();
private final FlowWorkRepository flowWorkRepository = new FlowWorkRepositoryImpl();
private final FlowRecordRepositoryImpl flowRecordRepository = new FlowRecordRepositoryImpl();
private final FlowBindDataRepositoryImpl flowBindDataRepository = new FlowBindDataRepositoryImpl();
private final LeaveRepository leaveRepository = new LeaveRepository();
private final FlowBackupRepository flowBackupRepository = new FlowBackupRepositoryImpl();
private final FlowProcessRepository flowProcessRepository = new FlowProcessRepositoryImpl(flowBackupRepository, userRepository);
private final FlowService flowService = new FlowService(flowWorkRepository, flowRecordRepository, flowBindDataRepository, userRepository, flowProcessRepository, flowBackupRepository);


/**
* 一直退回的测试
*/
@Test
void rejectAllTest() {
PageRequest pageRequest = PageRequest.of(0, 1000);

User user = new User("张飞");
userRepository.save(user);

User dept = new User("刘备");
userRepository.save(dept);

User boss = new User("诸葛亮");
userRepository.save(boss);

FlowWork flowWork = FlowWorkBuilder.builder(user)
.title("请假流程")
.skipIfSameApprover(true)
.nodes()
.node("开始节点", "start", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
.node("部门负责人审批", "dept", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(user.getUserId(), boss.getUserId()))
.node("分管领导审批", "office", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(dept.getUserId()))
.node("总经理审批", "manager", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(boss.getUserId()))
.node("结束节点", "over", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
.relations()
.relation("部门负责人审批", "start", "dept")
.relation("分管领导审批", "dept", "office")
.relation("总经理审批", "office", "manager")
.relation("结束节点", "manager", "over")
.build();

flowWorkRepository.save(flowWork);

String workCode = flowWork.getCode();

Leave leave = new Leave("我要出去看看");
leaveRepository.save(leave);

// 创建流程
flowService.startFlow(workCode, user, leave, "发起流程");

// 查看我的待办
List<FlowRecord> userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
assertEquals(1, userTodos.size());

// 提交流程
FlowRecord userTodo = userTodos.get(0);
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意"));

// 查看部门经理的待办
List<FlowRecord> deptTodos = flowRecordRepository.findTodoByOperatorId(dept.getUserId(), pageRequest).getContent();
assertEquals(1, deptTodos.size());

// 提交部门经理的审批
FlowRecord deptTodo = deptTodos.get(0);
flowService.submitFlow(deptTodo.getId(), dept, leave, Opinion.reject("不同意"));

userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
assertEquals(1, userTodos.size());

// 提交流程
userTodo = userTodos.get(0);
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.reject("不同意"));

List<FlowRecord> records = flowRecordRepository.findAll(pageRequest).getContent();

userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
assertEquals(1, userTodos.size());

userTodo = userTodos.get(0);

System.out.println(userTodo.getNodeCode());

assertEquals("start", userTodo.getNodeCode());

// 提交流程
userTodo = userTodos.get(0);
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意"));

// 查看部门经理的待办
deptTodos = flowRecordRepository.findTodoByOperatorId(dept.getUserId(), pageRequest).getContent();
assertEquals(1, deptTodos.size());

// 提交部门经理的审批
deptTodo = deptTodos.get(0);
flowService.submitFlow(deptTodo.getId(), dept, leave, Opinion.reject("不同意"));


userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
assertEquals(1, userTodos.size());

// 提交流程
userTodo = userTodos.get(0);
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.reject("不同意"));


userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
assertEquals(1, userTodos.size());

userTodo = userTodos.get(0);

System.out.println(userTodo.getNodeCode());

assertEquals("start", userTodo.getNodeCode());

records = flowRecordRepository.findAll(pageRequest).getContent();
assertEquals(11, records.size());


}
}
2 changes: 1 addition & 1 deletion springboot-starter-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.3.69</version>
<version>3.3.70</version>
</parent>

<artifactId>springboot-starter-security</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.3.69</version>
<version>3.3.70</version>
</parent>
<artifactId>springboot-starter</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion springboot-starter/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
------------------------------------------------------
CodingApi SpringBoot-Starter 3.3.69
CodingApi SpringBoot-Starter 3.3.70
springboot version (${spring-boot.version})
------------------------------------------------------