优化下代码
This commit is contained in:
1 parent
a0e77d7b77
commit
d564749fa7
12 files changed
+15
-253
No files matched your search
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"local": {
|
|
||||||
"baseUrl": "http://127.0.0.1:48081/admin-api",
|
|
||||||
"token": "test1",
|
|
||||||
"adminTenentId": "1",
|
|
||||||
|
|
||||||
"appApi": "http://127.0.0.1:48081/app-api",
|
|
||||||
"appToken": "test247",
|
|
||||||
"appTenentId": "1"
|
|
||||||
},
|
|
||||||
"gateway": {
|
|
||||||
"baseUrl": "http://127.0.0.1:8888/admin-api",
|
|
||||||
"token": "test1",
|
|
||||||
"adminTenentId": "1",
|
|
||||||
|
|
||||||
"appApi": "http://127.0.0.1:8888/app-api",
|
|
||||||
"appToken": "test1",
|
|
||||||
"appTenantId": "1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -377,21 +377,21 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 工作流相关 -->
|
<!-- 工作流相关 -->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>co.yixiang.boot</groupId>
|
<!-- <groupId>co.yixiang.boot</groupId>-->
|
||||||
<artifactId>yshop-spring-boot-starter-flowable</artifactId>
|
<!-- <artifactId>yshop-spring-boot-starter-flowable</artifactId>-->
|
||||||
<version>${revision}</version>
|
<!-- <version>${revision}</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.flowable</groupId>
|
<!-- <groupId>org.flowable</groupId>-->
|
||||||
<artifactId>flowable-spring-boot-starter-process</artifactId>
|
<!-- <artifactId>flowable-spring-boot-starter-process</artifactId>-->
|
||||||
<version>${flowable.version}</version>
|
<!-- <version>${flowable.version}</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.flowable</groupId>
|
<!-- <groupId>org.flowable</groupId>-->
|
||||||
<artifactId>flowable-spring-boot-starter-actuator</artifactId>
|
<!-- <artifactId>flowable-spring-boot-starter-actuator</artifactId>-->
|
||||||
<version>${flowable.version}</version>
|
<!-- <version>${flowable.version}</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<!-- 工作流相关结束 -->
|
<!-- 工作流相关结束 -->
|
||||||
|
|
||||||
<!-- 工具类相关 -->
|
<!-- 工具类相关 -->
|
||||||
|
|||||||
@@ -16,28 +16,22 @@
|
|||||||
<module>yshop-spring-boot-starter-redis</module>
|
<module>yshop-spring-boot-starter-redis</module>
|
||||||
<module>yshop-spring-boot-starter-web</module>
|
<module>yshop-spring-boot-starter-web</module>
|
||||||
<module>yshop-spring-boot-starter-security</module>
|
<module>yshop-spring-boot-starter-security</module>
|
||||||
|
|
||||||
<module>yshop-spring-boot-starter-file</module>
|
<module>yshop-spring-boot-starter-file</module>
|
||||||
<module>yshop-spring-boot-starter-monitor</module>
|
<module>yshop-spring-boot-starter-monitor</module>
|
||||||
<module>yshop-spring-boot-starter-protection</module>
|
<module>yshop-spring-boot-starter-protection</module>
|
||||||
<module>yshop-spring-boot-starter-job</module>
|
<module>yshop-spring-boot-starter-job</module>
|
||||||
<module>yshop-spring-boot-starter-mq</module>
|
<module>yshop-spring-boot-starter-mq</module>
|
||||||
|
|
||||||
<module>yshop-spring-boot-starter-excel</module>
|
<module>yshop-spring-boot-starter-excel</module>
|
||||||
<module>yshop-spring-boot-starter-test</module>
|
<module>yshop-spring-boot-starter-test</module>
|
||||||
|
|
||||||
<module>yshop-spring-boot-starter-biz-operatelog</module>
|
<module>yshop-spring-boot-starter-biz-operatelog</module>
|
||||||
<module>yshop-spring-boot-starter-biz-dict</module>
|
<module>yshop-spring-boot-starter-biz-dict</module>
|
||||||
<module>yshop-spring-boot-starter-biz-sms</module>
|
<module>yshop-spring-boot-starter-biz-sms</module>
|
||||||
|
|
||||||
<module>yshop-spring-boot-starter-biz-weixin</module>
|
<module>yshop-spring-boot-starter-biz-weixin</module>
|
||||||
<module>yshop-spring-boot-starter-biz-social</module>
|
<module>yshop-spring-boot-starter-biz-social</module>
|
||||||
<module>yshop-spring-boot-starter-biz-tenant</module>
|
<module>yshop-spring-boot-starter-biz-tenant</module>
|
||||||
<module>yshop-spring-boot-starter-biz-data-permission</module>
|
<module>yshop-spring-boot-starter-biz-data-permission</module>
|
||||||
<module>yshop-spring-boot-starter-biz-error-code</module>
|
<module>yshop-spring-boot-starter-biz-error-code</module>
|
||||||
<module>yshop-spring-boot-starter-biz-ip</module>
|
<module>yshop-spring-boot-starter-biz-ip</module>
|
||||||
|
|
||||||
<module>yshop-spring-boot-starter-flowable</module>
|
|
||||||
<module>yshop-spring-boot-starter-captcha</module>
|
<module>yshop-spring-boot-starter-captcha</module>
|
||||||
<module>yshop-spring-boot-starter-websocket</module>
|
<module>yshop-spring-boot-starter-websocket</module>
|
||||||
<module>yshop-spring-boot-starter-desensitize</module>
|
<module>yshop-spring-boot-starter-desensitize</module>
|
||||||
|
|||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* 基础的通用类,和框架无关
|
|
||||||
*
|
|
||||||
* 例如说,CommonResult 为通用返回
|
|
||||||
*/
|
|
||||||
package co.yixiang.yshop.framework.common;
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* Banner 用于在 console 控制台,打印开发文档、接口文档等
|
|
||||||
*
|
|
||||||
* @author yshop
|
|
||||||
*/
|
|
||||||
package co.yixiang.yshop.framework.banner;
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>yshop-framework</artifactId>
|
|
||||||
<groupId>co.yixiang.boot</groupId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>yshop-spring-boot-starter-flowable</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>co.yixiang.boot</groupId>
|
|
||||||
<artifactId>yshop-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Web 相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>co.yixiang.boot</groupId>
|
|
||||||
<artifactId>yshop-spring-boot-starter-security</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- flowable 工作流相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.flowable</groupId>
|
|
||||||
<artifactId>flowable-spring-boot-starter-process</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.flowable</groupId>
|
|
||||||
<artifactId>flowable-spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
-43
@@ -1,43 +0,0 @@
|
|||||||
package co.yixiang.yshop.framework.flowable.config;
|
|
||||||
|
|
||||||
import co.yixiang.yshop.framework.common.enums.WebFilterOrderEnum;
|
|
||||||
import co.yixiang.yshop.framework.flowable.core.web.FlowableWebFilter;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
||||||
|
|
||||||
@AutoConfiguration
|
|
||||||
public class YshopFlowableConfiguration {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参考 {@link org.flowable.spring.boot.FlowableJobConfiguration} 类,创建对应的 AsyncListenableTaskExecutor Bean
|
|
||||||
*
|
|
||||||
* 如果不创建,会导致项目启动时,Flowable 报错的问题
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public AsyncListenableTaskExecutor taskExecutor() {
|
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
||||||
executor.setCorePoolSize(8);
|
|
||||||
executor.setMaxPoolSize(8);
|
|
||||||
executor.setQueueCapacity(100);
|
|
||||||
executor.setThreadNamePrefix("flowable-task-Executor-");
|
|
||||||
executor.setAwaitTerminationSeconds(30);
|
|
||||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
|
||||||
executor.setAllowCoreThreadTimeOut(true);
|
|
||||||
executor.initialize();
|
|
||||||
return executor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置 flowable Web 过滤器
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public FilterRegistrationBean<FlowableWebFilter> flowableWebFilter() {
|
|
||||||
FilterRegistrationBean<FlowableWebFilter> registrationBean = new FilterRegistrationBean<>();
|
|
||||||
registrationBean.setFilter(new FlowableWebFilter());
|
|
||||||
registrationBean.setOrder(WebFilterOrderEnum.FLOWABLE_FILTER);
|
|
||||||
return registrationBean;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
package co.yixiang.yshop.framework.flowable.core;
|
|
||||||
-82
@@ -1,82 +0,0 @@
|
|||||||
package co.yixiang.yshop.framework.flowable.core.util;
|
|
||||||
|
|
||||||
import org.flowable.bpmn.converter.BpmnXMLConverter;
|
|
||||||
import org.flowable.bpmn.model.BpmnModel;
|
|
||||||
import org.flowable.bpmn.model.FlowElement;
|
|
||||||
import org.flowable.common.engine.impl.identity.Authentication;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flowable 相关的工具方法
|
|
||||||
*
|
|
||||||
* @author yshop
|
|
||||||
*/
|
|
||||||
public class FlowableUtils {
|
|
||||||
|
|
||||||
// ========== User 相关的工具方法 ==========
|
|
||||||
|
|
||||||
public static void setAuthenticatedUserId(Long userId) {
|
|
||||||
Authentication.setAuthenticatedUserId(String.valueOf(userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearAuthenticatedUserId() {
|
|
||||||
Authentication.setAuthenticatedUserId(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== BPMN 相关的工具方法 ==========
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得 BPMN 流程中,指定的元素们
|
|
||||||
*
|
|
||||||
* @param model
|
|
||||||
* @param clazz 指定元素。例如说,{@link org.flowable.bpmn.model.UserTask}、{@link org.flowable.bpmn.model.Gateway} 等等
|
|
||||||
* @return 元素们
|
|
||||||
*/
|
|
||||||
public static <T extends FlowElement> List<T> getBpmnModelElements(BpmnModel model, Class<T> clazz) {
|
|
||||||
List<T> result = new ArrayList<>();
|
|
||||||
model.getProcesses().forEach(process -> {
|
|
||||||
process.getFlowElements().forEach(flowElement -> {
|
|
||||||
if (flowElement.getClass().isAssignableFrom(clazz)) {
|
|
||||||
result.add((T) flowElement);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 比较 两个bpmnModel 是否相同
|
|
||||||
* @param oldModel 老的bpmn model
|
|
||||||
* @param newModel 新的bpmn model
|
|
||||||
*/
|
|
||||||
public static boolean equals(BpmnModel oldModel, BpmnModel newModel) {
|
|
||||||
// 由于 BpmnModel 未提供 equals 方法,所以只能转成字节数组,进行比较
|
|
||||||
return Arrays.equals(getBpmnBytes(oldModel), getBpmnBytes(newModel));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 把 bpmnModel 转换成 byte[]
|
|
||||||
* @param model bpmnModel
|
|
||||||
*/
|
|
||||||
public static byte[] getBpmnBytes(BpmnModel model) {
|
|
||||||
if (model == null) {
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
BpmnXMLConverter converter = new BpmnXMLConverter();
|
|
||||||
return converter.convertToXML(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== Execution 相关的工具方法 ==========
|
|
||||||
|
|
||||||
public static String formatCollectionVariable(String activityId) {
|
|
||||||
return activityId + "_assignees";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatCollectionElementVariable(String activityId) {
|
|
||||||
return activityId + "_assignee";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
package co.yixiang.yshop.framework.flowable.core.web;
|
|
||||||
|
|
||||||
import co.yixiang.yshop.framework.flowable.core.util.FlowableUtils;
|
|
||||||
import co.yixiang.yshop.framework.security.core.util.SecurityFrameworkUtils;
|
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
|
||||||
|
|
||||||
import javax.servlet.FilterChain;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
/**
|
|
||||||
* flowable Web 过滤器,将 userId 设置到 {@link org.flowable.common.engine.impl.identity.Authentication} 中
|
|
||||||
*
|
|
||||||
* @author jason
|
|
||||||
*/
|
|
||||||
public class FlowableWebFilter extends OncePerRequestFilter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
|
|
||||||
throws ServletException, IOException {
|
|
||||||
try {
|
|
||||||
// 设置工作流的用户
|
|
||||||
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
|
||||||
if (userId != null) {
|
|
||||||
FlowableUtils.setAuthenticatedUserId(userId);
|
|
||||||
}
|
|
||||||
// 过滤
|
|
||||||
chain.doFilter(request, response);
|
|
||||||
} finally {
|
|
||||||
// 清理
|
|
||||||
FlowableUtils.clearAuthenticatedUserId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
package co.yixiang.yshop.framework.flowable;
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
co.yixiang.yshop.framework.flowable.config.YshopFlowableConfiguration
|
|
||||||
Reference in new issue
Block a user