Skip to content

Dev #113

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 2 commits into from
Jun 10, 2025
Merged

Dev #113

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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import com.codingapi.springboot.flow.event.FlowApprovalEvent;
import com.codingapi.springboot.framework.event.IHandler;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@AllArgsConstructor
public class LeaveHandler implements IHandler<FlowApprovalEvent> {
Expand All @@ -15,6 +17,7 @@ public class LeaveHandler implements IHandler<FlowApprovalEvent> {

@Override
public void handler(FlowApprovalEvent event) {
log.info("LeaveHandler: {}", event);
if (event.isFinish() && event.match(LeaveForm.class)) {
LeaveForm form = (LeaveForm) event.getBindData();
leaveService.create(form.toLeave());
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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</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.4.1</version>
<version>3.4.2</version>
</parent>

<name>springboot-starter-flow</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.codingapi.springboot.flow.bind;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;

/**
* 流程绑定Map数据对象,用于分布式服务下的流程对象数据传递能力
* 该对象中,将clazzName 当做了普通的key来使用,
*/
public class FlowMapBindData extends HashMap<String, Object> implements IBindData {


/**
* 获取类名称
*
* @return 类名称
*/
@Override
public String getClazzName() {
return (String) this.get(CLASS_NAME_KEY);
}

/**
* 转化为类对象
*/
@Override
public <T> T toJavaObject(Class<T> clazz) {
return JSONObject.parseObject(toJsonSnapshot(), clazz);
}

public static FlowMapBindData fromJson(String json) {
return JSONObject.parseObject(json, FlowMapBindData.class);
}

public static FlowMapBindData fromObject(Object obj) {
return JSONObject.parseObject(JSONObject.toJSONString(obj), FlowMapBindData.class);
}

public static FlowMapBindData fromJson(JSONObject json) {
return JSONObject.parseObject(json.toJSONString(), FlowMapBindData.class);
}

public boolean match(String matchKey) {
String className = this.getClazzName();
return matchKey.equals(className);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
public interface IBindData {

String CLASS_NAME_KEY = "clazzName";

/**
* 数据快照
*
Expand All @@ -19,9 +21,27 @@ default String toJsonSnapshot() {

/**
* 获取类名称
*
* @return 类名称
*/
default String getClazzName() {
return this.getClass().getName();
}


/**
* 类对象匹配
*/
default boolean match(String dataKey) {
String className = this.getClazzName();
return dataKey.equals(className);
}


/**
* 转化为类对象
*/
default <T> T toJavaObject(Class<T> clazz) {
return (T) this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class FlowApprovalEvent implements ISyncEvent {
public static final int STATE_URGE = 8;
// 抄送
public static final int STATE_CIRCULATE = 9;
// 保存
public static final int STATE_SAVE = 10;


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


public boolean match(Class<?> bindDataClass) {
return bindDataClass.isInstance(bindData);
public boolean match(String matchKey) {
return bindData.match(matchKey);
}

/**
* 匹配类名
* 当前bingData下的clazzName变成了普通的key字段了,推荐使用match(String matchKey)方法
* @param clazz 类名
* @return 是否匹配
*/
@Deprecated
public boolean match(Class<?> clazz) {
return bindData.match(clazz.getName());
}

public <T> T toJavaObject(Class<T> clazz) {
return bindData.toJavaObject(clazz);
}

public boolean isUrge() {
Expand All @@ -64,6 +81,10 @@ public boolean isTodo() {
return state == STATE_TODO;
}

public boolean isSave() {
return state == STATE_SAVE;
}

public boolean isCreate() {
return state == STATE_CREATE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import com.codingapi.springboot.flow.bind.BindDataSnapshot;
import com.codingapi.springboot.flow.bind.IBindData;
import com.codingapi.springboot.flow.domain.FlowWork;
import com.codingapi.springboot.flow.domain.Opinion;
import com.codingapi.springboot.flow.event.FlowApprovalEvent;
import com.codingapi.springboot.flow.record.FlowRecord;
import com.codingapi.springboot.flow.repository.*;
import com.codingapi.springboot.flow.service.FlowRecordVerifyService;
import com.codingapi.springboot.flow.user.IFlowOperator;
import com.codingapi.springboot.framework.event.EventPusher;
import lombok.AllArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

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

flowRecord.setOpinion(opinion);
flowRecordRepository.update(flowRecord);

FlowWork flowWork = flowRecordVerifyService.getFlowWork();

EventPusher.push(new FlowApprovalEvent(FlowApprovalEvent.STATE_SAVE,
flowRecord,
flowRecord.getCurrentOperator(),
flowWork,
snapshot.toBindData()),
true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.codingapi.springboot.flow.em.FlowSourceDirection;
import com.codingapi.springboot.flow.event.FlowApprovalEvent;
import com.codingapi.springboot.flow.pojo.FlowResult;
import com.codingapi.springboot.flow.pojo.FlowSubmitResult;
import com.codingapi.springboot.flow.record.FlowBackup;
import com.codingapi.springboot.flow.record.FlowProcess;
import com.codingapi.springboot.flow.record.FlowRecord;
Expand Down Expand Up @@ -190,6 +189,7 @@ public FlowResult startFlow() {
for (FlowRecord record : records) {
this.pushEvent(FlowApprovalEvent.STATE_CREATE, record);
this.pushEvent(FlowApprovalEvent.STATE_TODO, record);
this.pushEvent(FlowApprovalEvent.STATE_SAVE, record);
}
// 当前的审批记录
return new FlowResult(flowWork, records);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.codingapi.springboot.flow.flow;

import com.codingapi.springboot.flow.bind.IBindData;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Leave implements IBindData {

private long id;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.codingapi.springboot.flow.flow;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class Leave2 {

private long id;
private String title;
private int days;

public Leave2(String title) {
this(title,0);
}

public Leave2(String title, int days) {
this.title = title;
this.days = days;
}

}
Loading