feat: 将项目改为Starter的结构, 为后续开发做扩展准备

This commit is contained in:
2025-04-21 21:59:31 +08:00
parent bd4c374952
commit 2b2864b8df
111 changed files with 162 additions and 177 deletions

78
metis-applicant/pom.xml Normal file
View File

@@ -0,0 +1,78 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.metis</groupId>
<artifactId>metis</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>metis-applicant</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.metis</groupId>
<artifactId>metis-starter</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<!-- 默认生效的插件 -->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 编译插件 -->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>17</source>-->
<!-- <target>17</target>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- <compilerArgs>-->
<!-- <arg>-parameters</arg>-->
<!-- </compilerArgs>-->
<!-- &lt;!&ndash; 注解静态编译功能 注:仅支持 maven-compiler-plugin 的 version 在3.6.0 以上才生效 &ndash;&gt;-->
<!-- <annotationProcessorPaths>-->
<!-- &lt;!&ndash; 必须配置 lombok 的注解编译,否则会因为配置了(mapstruct-processor)启动了导致 lombok 对内部类的静态编译失效 &ndash;&gt;-->
<!-- <path>-->
<!-- <groupId>org.mapstruct</groupId>-->
<!-- <artifactId>mapstruct-processor</artifactId>-->
<!-- <version>1.6.2</version>-->
<!-- </path>-->
<!-- <path>-->
<!-- <groupId>org.projectlombok</groupId>-->
<!-- <artifactId>lombok</artifactId>-->
<!-- <version>1.18.34</version>-->
<!-- </path>-->
<!-- <path>-->
<!-- <groupId>org.projectlombok</groupId>-->
<!-- <artifactId>lombok-mapstruct-binding</artifactId>-->
<!-- <version>0.2.0</version>-->
<!-- </path>-->
<!-- </annotationProcessorPaths>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>
</project>

View File

@@ -0,0 +1,14 @@
package com.metisapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MetisApplication {
public static void main(String[] args) {
SpringApplication.run(MetisApplication.class, args);
}
}

View File

@@ -0,0 +1,30 @@
package com.metisapp.config;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI customOpenAPI() {
// Contact contact = new Contact();
// contact.setEmail("wlddhj@163.com");
// contact.setName("huangjian");
// contact.setUrl("http://doc.xiaominfo.com");
return new OpenAPI()
// 增加swagger授权请求头配置
// .components(new Components().addSecuritySchemes(CommonConstant.X_ACCESS_TOKEN,
// new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme(CommonConstant.X_ACCESS_TOKEN)))
.info(new Info()
.title("metis 后台服务API接口文档")
.version("1.0")
// .contact(contact)
.description("metis 接口文档")
// .termsOfService("http://doc.xiaominfo.com")
.license(new License().name("Apache 2.0")
.url("http://www.apache.org/licenses/LICENSE-2.0.html")));
}
}

View File

@@ -0,0 +1,43 @@
package com.metisapp.controller;
import com.metis.domain.bo.ProcessBo;
import com.metis.facade.ProcessDefinitionFacade;
import com.metis.flow.domain.entity.App;
import com.metis.result.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@RestController
@RequiredArgsConstructor
@RequestMapping("/process/definition")
public class ProcessDefinitionController {
private final ProcessDefinitionFacade processDefinitionFacade;
@PostMapping("/create")
public Result<Long> create(@RequestBody ProcessBo processBo) {
Long workflowId = processDefinitionFacade.create(processBo);
return Result.ok(workflowId);
}
@PutMapping("/update")
public Result<String> update(@RequestBody ProcessBo processBo) {
processDefinitionFacade.update(processBo);
return Result.ok();
}
@GetMapping("/{deploymentId}")
public Result<App> getByDeploymentId(@PathVariable Long deploymentId) {
App app = processDefinitionFacade.getByDeploymentId(deploymentId);
return Result.ok(app);
}
@DeleteMapping("/{appId}")
public Result<String> delete(@PathVariable Long appId) {
processDefinitionFacade.delete(appId);
return Result.ok();
}
}

View File

@@ -0,0 +1,38 @@
package com.metisapp.controller;
import com.metis.flow.domain.bo.BuildApp;
import com.metis.flow.engine.AppFlowEngineRunnerService;
import com.metis.flow.runner.FlowRunningContext;
import com.metis.flow.runner.RunnerResult;
import com.metis.flow.validator.ValidatorService;
import com.metis.result.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {
private final ValidatorService validatorService;
private final AppFlowEngineRunnerService engineRunnerService;
@PostMapping
public Result<String> test(@RequestBody BuildApp app) {
validatorService.validate(app);
return Result.ok("测试成功");
}
@PostMapping("/run")
public Result<RunnerResult> run(@RequestBody FlowRunningContext context) {
RunnerResult running = engineRunnerService.running(context);
return Result.ok(running);
}
}

View File

@@ -0,0 +1,20 @@
# Spring配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://frp.feashow.cn:39306/metis?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: yyz@2024
data:
redis:
host: frp.feashow.cn
port: 39379
password: yyz@2024
database: 13
timeout: 10s
lettuce:
pool:
min-idle: 0
max-idle: 8
max-active: 8
max-wait: -1ms

View File

@@ -0,0 +1,20 @@
# Spring配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.7.127.190:3306/metis?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: yyz@2024
data:
redis:
host: 10.7.127.190
port: 6379
password: yyz@2024
database: 13
timeout: 10s
lettuce:
pool:
min-idle: 0
max-idle: 8
max-active: 8
max-wait: -1ms

View File

@@ -0,0 +1,57 @@
server:
port: 8080
spring:
application:
name: metis
profiles:
active: dev
# MyBatis Plus 配置
mybatis-plus:
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增", 1:"不操作", 2:"用户输入ID",3:"数字型snowflake", 4:"全局唯一ID UUID", 5:"字符串型snowflake";
id-type: 3
#字段策略
insert-strategy: not_null
update-strategy: not_null
select-strategy: not_null
#驼峰下划线转换
table-underline: true
logic-delete-field: is_deleted # 全局逻辑删除字段名
logic-delete-value: 1 # 逻辑已删除值
logic-not-delete-value: 0 # 逻辑未删除值
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
springdoc:
swagger-ui:
tags-sorter: alpha
group-configs:
- group: bis
display-name: "业务接口文档"
paths-to-match: '/**'
packages-to-scan: org.shi9.module.bis
- group: system
display-name: "系统接口文档"
paths-to-match: '/**'
packages-to-scan: com.metis.controller
default-flat-param-object: true
knife4j:
# 开启增强配置
enable: true
# 开启生产环境屏蔽如果是生产环境需要把下面配置设置true
# production: true
setting:
language: zh_cn
swagger-model-name: 实体类列表
basic: # 开始授权认证
enable: true
username: admin
password: 123456

View File

@@ -0,0 +1,7 @@
{
"appId": "1909636986931470336",
"userId": 1,
"custom": {
"context": "测试内容!"
}
}

View File

@@ -0,0 +1,152 @@
{
"id": 0,
"name": "测试流程",
"description": "测试流程",
"graph": {
"nodes": [
{
"id": "5",
"type": "start",
"dimensions": {
"width": 300,
"height": 300
},
"draggable": true,
"resizing": false,
"selected": true,
"data": {
"label": "开始",
"toolbarPosition": "right",
"config": {
"variables": [
{
"variable": "context",
"label": "段落",
"type": "paragraph",
"maxLength": 48,
"required": true
},
{
"variable": "text",
"label": "文本",
"type": "text-input",
"maxLength": 48,
"required": true,
"options": []
},
{
"variable": "select",
"label": "下拉",
"type": "select",
"maxLength": 48,
"required": true,
"options": [
{
"label": "选型1",
"value": "1"
},
{
"label": "选型2",
"value": "2"
}
]
},
{
"variable": "number",
"label": "数字",
"type": "number",
"maxLength": 48,
"required": true,
"options": []
},
{
"variable": "singlefile",
"label": "singlefile单文件",
"type": "file",
"maxLength": 48,
"required": true,
"options": [],
"allowedFileUploadMethods": [
"local_file",
"remote_url"
],
"allowedFileTypes": [
"image",
"document",
"audio",
"video"
],
"allowedFileExtensions": []
},
{
"variable": "mufile",
"label": "多文件",
"type": "file-list",
"maxLength": 5,
"required": true,
"options": [],
"allowedFileUploadMethods": [
"local_file"
],
"allowedFileTypes": [
"custom"
],
"allowedFileExtensions": [
"docx",
"aaa"
]
}
],
"parent": "234"
},
"handles": [
{
"id": "7",
"position": "right",
"type": "source",
"connectable": true
}
]
},
"position": { "x": 0, "y": 300 }
},
{
"id": "6",
"type": "end",
"selected": false,
"data": {
"label": "结束",
"toolbarPosition": "right",
"handles": [
{
"id": "8",
"position": "left",
"type": "target",
"connectable": true
}
]
},
"position": { "x": 500, "y": 300 }
}
],
"edges": [
{
"id": "6",
"type": "default",
"source": "5",
"target": "6",
"sourceHandle": "7",
"animated": true,
"targetHandle": "8",
"label": "线标签",
"markerEnd": "none",
"markerStart": "none",
"updatable": true,
"selectable": true,
"deletable": true
}
]
}
}

View File

@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SSE Demo</title>
</head>
<body>
<h1>SSE 连接示例</h1>
<div id="messages"></div>
<script> // 创建一个新的EventSource对象连接到SSE服务
const eventSource = new EventSource('http://localhost:8081/sse');
// 监听服务器发送的消息事件
eventSource.onmessage = function(event) {
const message = document.createElement('p');
message.textContent = '收到消息: ' + event.data;
document.getElementById('messages').appendChild(message);
};
// 监听自定义事件(如果有)
eventSource.addEventListener('customEvent', function(event) {
const message = document.createElement('p');
message.textContent = '收到自定义事件: ' + event.data;
document.getElementById('messages').appendChild(message);
});
// 监听连接打开事件
eventSource.onopen = function(event) {
const message = document.createElement('p');
message.textContent = 'SSE连接已建立';
document.getElementById('messages').appendChild(message);
};
// 监听错误事件
eventSource.onerror = function(event) {
const message = document.createElement('p');
message.textContent = 'SSE连接发生错误';
document.getElementById('messages').appendChild(message);
// 在这里处理错误,例如尝试重新连接
};
</script>
</body>
</html>