Skip to content
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

♻️ Decouple project from Spring and MyBatis frameworks for imp… #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 9 additions & 5 deletions demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,51 @@
<parent>
<groupId>com.didiglobal.turbo</groupId>
<artifactId>turbo</artifactId>
<version>1.2.0</version>
<version>${revision}</version>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>demo</artifactId>
<version>1.2.0</version>
<version>${revision}</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>

<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
<turbo.engine.version>1.2.0</turbo.engine.version>
<h2.version>1.4.200</h2.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.didiglobal.turbo</groupId>
<artifactId>engine</artifactId>
<version>${turbo.engine.version}</version>
<artifactId>turbo-spring-boot-starter</artifactId>
<version>${revision}</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.didiglobal.turbo.demo;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.didiglobal.turbo.engine.annotation.EnableTurboEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.didiglobal.turbo.spring.annotation.EnableTurboEngine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
import com.didiglobal.turbo.demo.pojo.response.FlowModuleListResponse;
import com.didiglobal.turbo.demo.pojo.response.FlowModuleResponse;
import com.didiglobal.turbo.engine.common.FlowDeploymentStatus;
import com.didiglobal.turbo.engine.dao.FlowDefinitionDAO;
import com.didiglobal.turbo.engine.dao.FlowDeploymentDAO;
import com.didiglobal.turbo.engine.engine.ProcessEngine;
import com.didiglobal.turbo.engine.entity.FlowDefinitionPO;
import com.didiglobal.turbo.engine.entity.FlowDeploymentPO;
import com.didiglobal.turbo.engine.result.CreateFlowResult;
import com.didiglobal.turbo.engine.result.DeployFlowResult;
import com.didiglobal.turbo.engine.result.FlowModuleResult;
import com.didiglobal.turbo.engine.result.UpdateFlowResult;
import com.didiglobal.turbo.mybatis.dao.impl.FlowDefinitionDAOImpl;
import com.didiglobal.turbo.mybatis.dao.impl.FlowDeploymentDAOImpl;
import com.didiglobal.turbo.mybatis.entity.FlowDefinitionEntity;
import com.didiglobal.turbo.mybatis.entity.FlowDeploymentEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -43,10 +43,10 @@ public class FlowServiceImpl {
private ProcessEngine processEngine;

@Resource
private FlowDefinitionDAO flowDefinitionDAO;
private FlowDefinitionDAOImpl flowDefinitionDAO;

@Resource
private FlowDeploymentDAO flowDeploymentDAO;
private FlowDeploymentDAOImpl flowDeploymentDAO;

/**
* 创建流程
Expand Down Expand Up @@ -96,14 +96,14 @@ public FlowModuleResult getFlowModule(GetFlowModuleRequest getFlowModuleRequest)
*/
public FlowModuleListResponse getFlowModuleList(GetFlowModuleListRequest getFlowModuleListRequest) {

Page<FlowDefinitionPO> page = buildGetFlowModuleListPage(getFlowModuleListRequest);
QueryWrapper<FlowDefinitionPO> queryWrapper = buildGetFlowModuleListQueryWrapper(getFlowModuleListRequest);
IPage<FlowDefinitionPO> pageRes = flowDefinitionDAO.page(page, queryWrapper);
Page<FlowDefinitionEntity> page = buildGetFlowModuleListPage(getFlowModuleListRequest);
QueryWrapper<FlowDefinitionEntity> queryWrapper = buildGetFlowModuleListQueryWrapper(getFlowModuleListRequest);
IPage<FlowDefinitionEntity> pageRes = flowDefinitionDAO.page(page, queryWrapper);
List<FlowModuleResponse> flowModuleList = new ArrayList<>();
for (FlowDefinitionPO flowDefinitionPO : pageRes.getRecords()) {
FlowModuleResponse getFlowModuleResponse = new FlowModuleResponse();
BeanUtils.copyProperties(flowDefinitionPO, getFlowModuleResponse);
QueryWrapper<FlowDeploymentPO> flowDeployQuery = buildCountFlowDeployQueryWrapper(flowDefinitionPO.getFlowModuleId());
QueryWrapper<FlowDeploymentEntity> flowDeployQuery = buildCountFlowDeployQueryWrapper(flowDefinitionPO.getFlowModuleId());
int count = flowDeploymentDAO.count(flowDeployQuery);
if (count >= 1) {
//4 已发布
Expand All @@ -117,17 +117,17 @@ public FlowModuleListResponse getFlowModuleList(GetFlowModuleListRequest getFlow
return flowModuleListResponse;
}

private Page<FlowDefinitionPO> buildGetFlowModuleListPage(GetFlowModuleListRequest getFlowModuleListRequest) {
Page<FlowDefinitionPO> page = new Page<>();
private Page<FlowDefinitionEntity> buildGetFlowModuleListPage(GetFlowModuleListRequest getFlowModuleListRequest) {
Page<FlowDefinitionEntity> page = new Page<>();
if (getFlowModuleListRequest.getSize() != null && getFlowModuleListRequest.getCurrent() != null) {
page.setCurrent(getFlowModuleListRequest.getCurrent());
page.setSize(getFlowModuleListRequest.getSize());
}
return page;
}

private QueryWrapper<FlowDefinitionPO> buildGetFlowModuleListQueryWrapper(GetFlowModuleListRequest getFlowModuleListRequest) {
QueryWrapper<FlowDefinitionPO> queryWrapper = new QueryWrapper<>();
private QueryWrapper<FlowDefinitionEntity> buildGetFlowModuleListQueryWrapper(GetFlowModuleListRequest getFlowModuleListRequest) {
QueryWrapper<FlowDefinitionEntity> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(getFlowModuleListRequest.getFlowModuleId())) {
queryWrapper.eq("flow_module_id", getFlowModuleListRequest.getFlowModuleId());
}
Expand All @@ -141,8 +141,8 @@ private QueryWrapper<FlowDefinitionPO> buildGetFlowModuleListQueryWrapper(GetFlo
return queryWrapper;
}

private QueryWrapper<FlowDeploymentPO> buildCountFlowDeployQueryWrapper(String flowModuleId) {
QueryWrapper<FlowDeploymentPO> flowDeployQuery = new QueryWrapper<>();
private QueryWrapper<FlowDeploymentEntity> buildCountFlowDeployQueryWrapper(String flowModuleId) {
QueryWrapper<FlowDeploymentEntity> flowDeployQuery = new QueryWrapper<>();
flowDeployQuery.eq("flow_module_id", flowModuleId);
flowDeployQuery.eq("status", FlowDeploymentStatus.DEPLOYED);
return flowDeployQuery;
Expand Down
12 changes: 4 additions & 8 deletions demo/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
spring.datasource.dynamic.primary=engine
spring.datasource.dynamic.datasource.engine.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.dynamic.datasource.engine.username=username
spring.datasource.dynamic.datasource.engine.password=password
spring.datasource.dynamic.datasource.engine.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.dynamic.datasource.engine.url=jdbc:mysql://127.0.0.1:3306/t_engine?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&autoReconnect=true

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/t_engine?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&autoReconnect=true
spring.datasource.username=root
spring.datasource.password=art-mysql-password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
mybatis.configuration.map-underscore-to-camel-case=true

logging.config=classpath:logback-spring.xml

Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void createFlow() {
*/
@Test
public void saveFlowModel() {
createFlow();
String flowModel = "{\"flowElementList\":[{\"incoming\":[],\"outgoing\":[\"Flow_3599vu7\"],\"dockers\":[],\"type\":2,\"properties\":{\"name\":\"开始\",\"x\":310,\"y\":200,\"text\":{\"x\":310,\"y\":240,\"value\":\"开始\"}},\"key\":\"Event_0vbtunu\"},{\"incoming\":[\"Flow_3599vu7\"],\"outgoing\":[\"Flow_1f2ei89\"],\"dockers\":[],\"type\":4,\"properties\":{\"name\":\"\",\"x\":520,\"y\":200,\"text\":\"\"},\"key\":\"Activity_0ivtksn\"},{\"incoming\":[\"Flow_1f2ei89\"],\"outgoing\":[\"Flow_1rkk099\"],\"dockers\":[],\"type\":6,\"properties\":{\"name\":\"\",\"x\":730,\"y\":200,\"text\":\"\"},\"key\":\"Gateway_2qj55i1\"},{\"incoming\":[\"Flow_1rkk099\"],\"outgoing\":[],\"dockers\":[],\"type\":3,\"properties\":{\"name\":\"结束\",\"x\":950,\"y\":200,\"text\":{\"x\":950,\"y\":240,\"value\":\"结束\"}},\"key\":\"Event_03pjf39\"},{\"incoming\":[\"Event_0vbtunu\"],\"outgoing\":[\"Activity_0ivtksn\"],\"type\":1,\"dockers\":[],\"properties\":{\"name\":\"\",\"text\":\"\",\"startPoint\":\"{\\\"x\\\":328,\\\"y\\\":200}\",\"endPoint\":\"{\\\"x\\\":470,\\\"y\\\":200}\",\"pointsList\":\"\\\"\\\"\"},\"key\":\"Flow_3599vu7\"},{\"incoming\":[\"Activity_0ivtksn\"],\"outgoing\":[\"Gateway_2qj55i1\"],\"type\":1,\"dockers\":[],\"properties\":{\"name\":\"\",\"text\":\"\",\"startPoint\":\"{\\\"x\\\":570,\\\"y\\\":200}\",\"endPoint\":\"{\\\"x\\\":705,\\\"y\\\":200}\",\"pointsList\":\"\\\"\\\"\"},\"key\":\"Flow_1f2ei89\"},{\"incoming\":[\"Gateway_2qj55i1\"],\"outgoing\":[\"Event_03pjf39\"],\"type\":1,\"dockers\":[],\"properties\":{\"conditionsequenceflow\":\"a==1\",\"name\":\"\",\"text\":\"\",\"startPoint\":\"{\\\"x\\\":755,\\\"y\\\":200}\",\"endPoint\":\"{\\\"x\\\":932,\\\"y\\\":200}\",\"pointsList\":\"\\\"\\\"\"},\"key\":\"Flow_1rkk099\"}]}";
System.out.println(flowModel);
UpdateFlowRequest updateFlowRequest = new UpdateFlowRequest();
Expand All @@ -83,6 +84,7 @@ public void saveFlowModel() {
*/
@Test
public void deployFlow() {
saveFlowModel();
DeployFlowRequest deployFlowRequest = new DeployFlowRequest();
deployFlowRequest.setFlowModuleId(flowModuleId);//模型唯一标识 必需
deployFlowRequest.setTenant("testTenant"); //租户标识 必需
Expand All @@ -103,6 +105,7 @@ public void deployFlow() {
*/
@Test
public void queryFlow() {
deployFlow();
GetFlowModuleRequest getFlowModuleRequest = new GetFlowModuleRequest();
getFlowModuleRequest.setFlowModuleId(flowModuleId);//模型唯一标识 两个参数必须传入一个
getFlowModuleRequest.setFlowDeployId(flowDeployId);//模型一次部署唯一标识 两个参数必须传入一个
Expand All @@ -129,6 +132,7 @@ public void queryFlow() {
*/
@Test
public void queryFlowList() {
deployFlow();
GetFlowModuleListRequest getFlowModuleListRequest = new GetFlowModuleListRequest();
getFlowModuleListRequest.setFlowName("测试流程"); // 模型名称 非必需
getFlowModuleListRequest.setFlowModuleId(null);//模型唯一标识 非必需
Expand Down
22 changes: 0 additions & 22 deletions demo/src/test/resources/application.properties

This file was deleted.

61 changes: 17 additions & 44 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,57 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>engine</artifactId>
<version>1.2.0</version>
<version>${revision}</version>
<packaging>jar</packaging>

<parent>
<artifactId>turbo</artifactId>
<groupId>com.didiglobal.turbo</groupId>
<version>1.2.0</version>
<version>${revision}</version>
</parent>
<properties>
<groovy.version>2.3.7</groovy.version>
<spring-boot-starter.version>1.5.10.RELEASE</spring-boot-starter.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ public class NodeInstance extends ElementInstance {
private Date modifyTime;
private Map<String, Object> properties = new HashMap<>();

@Override
public String getNodeInstanceId() {
return nodeInstanceId;
}

@Override
public void setNodeInstanceId(String nodeInstanceId) {
this.nodeInstanceId = nodeInstanceId;
}
Expand Down

This file was deleted.

Loading