commit
8bd1a9cf95
@ -0,0 +1,21 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
# 空格替代Tab缩进在各种编辑工具下效果一致
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.java]
|
||||
indent_style = tab
|
||||
|
||||
[*.{json,yml}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="nenghui-uat" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel target="17" />
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="nenghui-uat" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="bladex" />
|
||||
<option name="name" value="BladeX Release Repository" />
|
||||
<option name="url" value="https://center.javablade.com/api/packages/blade/maven" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="aliyun-repos" />
|
||||
<option name="name" value="Aliyun Public Repository" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
@ -0,0 +1,88 @@
|
||||
#./bin/bash
|
||||
# 定义颜色
|
||||
BLUE_COLOR="\033[36m"
|
||||
RED_COLOR="\033[31m"
|
||||
GREEN_COLOR="\033[32m"
|
||||
VIOLET_COLOR="\033[35m"
|
||||
RES="\033[0m"
|
||||
|
||||
echo -e "${BLUE_COLOR}# ######################################################################${RES}"
|
||||
echo -e "${BLUE_COLOR}# Docker ELK Deploy Script #${RES}"
|
||||
echo -e "${BLUE_COLOR}# ######################################################################${RES}"
|
||||
|
||||
# 创建目录
|
||||
echo -e "${BLUE_COLOR}---> create [elasticsearch]directory start.${RES}"
|
||||
if [ ! -d "./elasticsearch/" ]; then
|
||||
mkdir -p ./elasticsearch/master/conf ./elasticsearch/master/data ./elasticsearch/master/logs \
|
||||
./elasticsearch/slave1/conf ./elasticsearch/slave1/data ./elasticsearch/slave1/logs \
|
||||
./elasticsearch/slave2/conf ./elasticsearch/slave2/data ./elasticsearch/slave2/logs
|
||||
fi
|
||||
|
||||
echo -e "${RED_COLOR}---> create [kibana]directory start.${RES}"
|
||||
if [ ! -d "./kibana/" ]; then
|
||||
mkdir -p ./kibana/conf ./kibana/logs
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_COLOR}---> create [logstash]directory start.${RES}"
|
||||
if [ ! -d "./logstash/" ]; then
|
||||
mkdir -p ./logstash/conf ./logstash/logs
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_COLOR}---> create [filebeat]directory start.${RES}"
|
||||
if [ ! -d "./filebeat/" ]; then
|
||||
mkdir -p ./filebeat/conf ./filebeat/logs ./filebeat/data
|
||||
fi
|
||||
|
||||
echo -e "${VIOLET_COLOR}---> create [nginx]directory start.${RES}"
|
||||
if [ ! -d "./nginx/" ]; then
|
||||
mkdir -p ./nginx/conf ./nginx/logs ./nginx/www
|
||||
fi
|
||||
echo -e "${BLUE_COLOR}===> create directory success.${RES}"
|
||||
|
||||
# 目录授权(data/logs 都要授读/写权限)
|
||||
echo -e "${BLUE_COLOR}---> directory authorize start.${RES}"
|
||||
if [ -d "./elasticsearch/" ]; then
|
||||
chmod 777 ./elasticsearch/master/data/ ./elasticsearch/master/logs/ \
|
||||
./elasticsearch/slave1/data/ ./elasticsearch/slave1/logs/ \
|
||||
./elasticsearch/slave2/data/ ./elasticsearch/slave2/logs
|
||||
fi
|
||||
|
||||
if [ -d "./filebeat/" ]; then
|
||||
chmod 777 ./filebeat/data/ ./filebeat/logs/
|
||||
fi
|
||||
echo -e "${BLUE_COLOR}===> directory authorize success.${RES}"
|
||||
|
||||
# 移动配置文件
|
||||
echo -e "${BLUE_COLOR}---> move [elasticsearch]config file start.${RES}"
|
||||
if [ -f "./es-master.yml" ] && [ -f "./es-slave1.yml" ] && [ -f "./es-slave2.yml" ]; then
|
||||
mv ./es-master.yml ./elasticsearch/master/conf
|
||||
mv ./es-slave1.yml ./elasticsearch/slave1/conf
|
||||
mv ./es-slave2.yml ./elasticsearch/slave2/conf
|
||||
fi
|
||||
|
||||
echo -e "${RED_COLOR}---> move [kibana]config file start.${RES}"
|
||||
if [ -f "./kibana.yml" ]; then
|
||||
mv ./kibana.yml ./kibana/conf
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_COLOR}---> move [logstash]config file start.${RES}"
|
||||
if [ -f "./logstash.yml" ] && [ -f "./logstash-filebeat.conf" ]; then
|
||||
mv ./logstash-filebeat.conf ./logstash/conf
|
||||
mv ./logstash.yml ./logstash/conf
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_COLOR}---> move [filebeat]config file start.${RES}"
|
||||
if [ -f "./filebeat.yml" ]; then
|
||||
mv ./filebeat.yml ./filebeat/conf
|
||||
fi
|
||||
|
||||
echo -e "${VIOLET_COLOR}---> move [nginx]config file start.${RES}"
|
||||
if [ -f "./nginx.conf" ]; then
|
||||
mv ./nginx.conf ./nginx/conf
|
||||
fi
|
||||
echo -e "${BLUE_COLOR}===> move config files success.${RES}"
|
||||
echo -e "${GREEN_COLOR}>>>>>>>>>>>>>>>>>> The End <<<<<<<<<<<<<<<<<<${RES}"
|
||||
|
||||
# 部署项目
|
||||
echo -e "${BLUE_COLOR}==================> Docker deploy Start <==================${RES}"
|
||||
docker-compose up --build -d
|
@ -0,0 +1,37 @@
|
||||
filebeat.inputs:
|
||||
- type: log
|
||||
enabled: true
|
||||
paths:
|
||||
# 当前目录下的所有.log文件
|
||||
- /home/project/elk/logs/*.log
|
||||
multiline.pattern: ^\[
|
||||
multiline.negate: true
|
||||
multiline.match: after
|
||||
- type: tcp
|
||||
enabled: true
|
||||
max_message_size: 10MiB
|
||||
host: "0.0.0.0:9000"
|
||||
|
||||
filebeat.config.modules:
|
||||
path: ${path.config}/modules.d/*.yml
|
||||
reload.enabled: false
|
||||
|
||||
setup.template.settings:
|
||||
index.number_of_shards: 1
|
||||
|
||||
setup.dashboards.enabled: false
|
||||
|
||||
setup.kibana:
|
||||
host: "http://kibana:5601"
|
||||
|
||||
# 不直接传输至ES
|
||||
#output.elasticsearch:
|
||||
# hosts: ["http://es-master:9200"]
|
||||
# index: "filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"
|
||||
|
||||
output.logstash:
|
||||
hosts: ["logstash:5044"]
|
||||
|
||||
processors:
|
||||
- add_host_metadata: ~
|
||||
- add_cloud_metadata: ~
|
@ -0,0 +1,8 @@
|
||||
# 服务端口
|
||||
server.port: 5601
|
||||
# 服务IP
|
||||
server.host: "0.0.0.0"
|
||||
# ES
|
||||
elasticsearch.hosts: ["http://es-master:9200"]
|
||||
# 汉化
|
||||
i18n.locale: "zh-CN"
|
@ -0,0 +1,23 @@
|
||||
input {
|
||||
# 来源beats
|
||||
beats {
|
||||
# 端口
|
||||
port => "5044"
|
||||
}
|
||||
}
|
||||
# 分析、过滤插件,可以多个
|
||||
filter {
|
||||
grok {
|
||||
match => { "message" => "%{COMBINEDAPACHELOG}"}
|
||||
}
|
||||
geoip {
|
||||
source => "clientip"
|
||||
}
|
||||
}
|
||||
output {
|
||||
# 选择elasticsearch
|
||||
elasticsearch {
|
||||
hosts => ["http://es-master:9200"]
|
||||
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
# 服务IP
|
||||
http.host: "0.0.0.0"
|
||||
# ES
|
||||
xpack.monitoring.elasticsearch.hosts: [ "http://es-master:9200" ]
|
||||
|
||||
xpack.monitoring.enabled: true
|
||||
|
||||
xpack.management.enabled: false
|
@ -0,0 +1,16 @@
|
||||
#./bin/bash
|
||||
# 定义颜色
|
||||
BLUE_COLOR="\033[36m"
|
||||
RED_COLOR="\033[31m"
|
||||
GREEN_COLOR="\033[32m"
|
||||
VIOLET_COLOR="\033[35m"
|
||||
RES="\033[0m"
|
||||
|
||||
echo -e "${BLUE_COLOR}# ######################################################################${RES}"
|
||||
echo -e "${BLUE_COLOR}# Docker ELK UnDeploy Script #${RES}"
|
||||
echo -e "${BLUE_COLOR}# ######################################################################${RES}"
|
||||
|
||||
# 部署项目
|
||||
echo -e "${BLUE_COLOR}==================> Docker UnDeploy Start <==================${RES}"
|
||||
docker-compose stop
|
||||
docker-compose rm
|
@ -0,0 +1 @@
|
||||
java -Xms1024m -Xmx1024m -jar app.jar
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,16 @@
|
||||
-- -----------------------------------
|
||||
-- 修改应用表的授权集合
|
||||
-- -----------------------------------
|
||||
UPDATE "BLADEX"."BLADE_CLIENT" SET AUTHORIZED_GRANT_TYPES = 'authorization_code,password,refresh_token,captcha,social,register' where ID < 1123598811738675203;
|
||||
|
||||
-- -----------------------------------
|
||||
-- 删除可能重复的菜单
|
||||
-- -----------------------------------
|
||||
DELETE FROM "BLADEX"."BLADE_CLIENT" WHERE "CLIENT_ID" = 'saber3';
|
||||
DELETE FROM "BLADEX"."BLADE_CLIENT" WHERE "CLIENT_ID" = 'rider';
|
||||
|
||||
-- -----------------------------------
|
||||
-- 新增客户端记录
|
||||
-- -----------------------------------
|
||||
INSERT INTO "BLADEX"."BLADE_CLIENT" ("ID", "CLIENT_ID", "CLIENT_SECRET", "RESOURCE_IDS", "SCOPE", "AUTHORIZED_GRANT_TYPES", "WEB_SERVER_REDIRECT_URI", "AUTHORITIES", "ACCESS_TOKEN_VALIDITY", "REFRESH_TOKEN_VALIDITY", "ADDITIONAL_INFORMATION", "AUTOAPPROVE", "CREATE_USER", "CREATE_DEPT", "CREATE_TIME", "UPDATE_USER", "UPDATE_TIME", "STATUS", "IS_DELETED") VALUES ('1123598811738675203', 'saber3', 'saber3_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:2888/login', NULL, '3600', '604800', NULL, NULL, '1123598815738675201', '1123598813738675201', '2024-04-01 00:00:00', '1123598815738675201', '2024-04-01 00:00:00', '1', '0');
|
||||
INSERT INTO "BLADEX"."BLADE_CLIENT" ("ID", "CLIENT_ID", "CLIENT_SECRET", "RESOURCE_IDS", "SCOPE", "AUTHORIZED_GRANT_TYPES", "WEB_SERVER_REDIRECT_URI", "AUTHORITIES", "ACCESS_TOKEN_VALIDITY", "REFRESH_TOKEN_VALIDITY", "ADDITIONAL_INFORMATION", "AUTOAPPROVE", "CREATE_USER", "CREATE_DEPT", "CREATE_TIME", "UPDATE_USER", "UPDATE_TIME", "STATUS", "IS_DELETED") VALUES ('1123598811738675204', 'rider', 'rider_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:88', NULL, '3600', '604800', NULL, NULL, '1123598815738675201', '1123598813738675201', '2024-04-01 00:00:00', '1123598815738675201', '2024-04-01 00:00:00', '1', '0');
|
@ -0,0 +1,16 @@
|
||||
-- -----------------------------------
|
||||
-- 修改应用表saber的访问地址
|
||||
-- -----------------------------------
|
||||
UPDATE `blade_client` SET authorized_grant_types = 'authorization_code,password,refresh_token,captcha,social,register' where id < 1123598811738675203;
|
||||
|
||||
-- -----------------------------------
|
||||
-- 删除可能重复的菜单
|
||||
-- -----------------------------------
|
||||
DELETE FROM `blade_client` WHERE client_id = 'saber3';
|
||||
DELETE FROM `blade_client` WHERE client_id = 'rider';
|
||||
|
||||
-- -----------------------------------
|
||||
-- 新增模型设计菜单
|
||||
-- -----------------------------------
|
||||
INSERT INTO `blade_client` (`id`, `client_id`, `client_secret`, `resource_ids`, `scope`, `authorized_grant_types`, `web_server_redirect_uri`, `authorities`, `access_token_validity`, `refresh_token_validity`, `additional_information`, `autoapprove`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`, `status`, `is_deleted`) VALUES (1123598811738675203, 'saber3', 'saber3_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:2888/login', NULL, 3600, 604800, NULL, NULL, 1123598815738675201, 1123598813738675201, '2024-04-01 00:00:00', 1123598815738675201, '2024-04-01 00:00:00', 1, 0);
|
||||
INSERT INTO `blade_client` (`id`, `client_id`, `client_secret`, `resource_ids`, `scope`, `authorized_grant_types`, `web_server_redirect_uri`, `authorities`, `access_token_validity`, `refresh_token_validity`, `additional_information`, `autoapprove`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`, `status`, `is_deleted`) VALUES (1123598811738675204, 'rider', 'rider_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:88', NULL, 3600, 604800, NULL, NULL, 1123598815738675201, 1123598813738675201, '2024-04-01 00:00:00', 1123598815738675201, '2024-04-01 00:00:00', 1, 0);
|
@ -0,0 +1,16 @@
|
||||
-- -----------------------------------
|
||||
-- 修改应用表的授权集合
|
||||
-- -----------------------------------
|
||||
UPDATE "BLADEX"."BLADE_CLIENT" SET AUTHORIZED_GRANT_TYPES = 'authorization_code,password,refresh_token,captcha,social,register' where ID < 1123598811738675203;
|
||||
|
||||
-- -----------------------------------
|
||||
-- 删除可能重复的菜单
|
||||
-- -----------------------------------
|
||||
DELETE FROM "BLADEX"."BLADE_CLIENT" WHERE "CLIENT_ID" = 'saber3';
|
||||
DELETE FROM "BLADEX"."BLADE_CLIENT" WHERE "CLIENT_ID" = 'rider';
|
||||
|
||||
-- -----------------------------------
|
||||
-- 新增客户端记录
|
||||
-- -----------------------------------
|
||||
INSERT INTO "BLADEX"."BLADE_CLIENT" ("ID", "CLIENT_ID", "CLIENT_SECRET", "RESOURCE_IDS", "SCOPE", "AUTHORIZED_GRANT_TYPES", "WEB_SERVER_REDIRECT_URI", "AUTHORITIES", "ACCESS_TOKEN_VALIDITY", "REFRESH_TOKEN_VALIDITY", "ADDITIONAL_INFORMATION", "AUTOAPPROVE", "CREATE_USER", "CREATE_DEPT", "CREATE_TIME", "UPDATE_USER", "UPDATE_TIME", "STATUS", "IS_DELETED") VALUES ('1123598811738675203', 'saber3', 'saber3_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:2888/login', NULL, '3600', '604800', NULL, NULL, '1123598815738675201', '1123598813738675201', TO_DATE('2024-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), '1123598815738675201', TO_DATE('2024-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), '1', '0');
|
||||
INSERT INTO "BLADEX"."BLADE_CLIENT" ("ID", "CLIENT_ID", "CLIENT_SECRET", "RESOURCE_IDS", "SCOPE", "AUTHORIZED_GRANT_TYPES", "WEB_SERVER_REDIRECT_URI", "AUTHORITIES", "ACCESS_TOKEN_VALIDITY", "REFRESH_TOKEN_VALIDITY", "ADDITIONAL_INFORMATION", "AUTOAPPROVE", "CREATE_USER", "CREATE_DEPT", "CREATE_TIME", "UPDATE_USER", "UPDATE_TIME", "STATUS", "IS_DELETED") VALUES ('1123598811738675204', 'rider', 'rider_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:88', NULL, '3600', '604800', NULL, NULL, '1123598815738675201', '1123598813738675201', TO_DATE('2024-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), '1123598815738675201', TO_DATE('2024-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), '1', '0');
|
@ -0,0 +1,16 @@
|
||||
-- -----------------------------------
|
||||
-- 修改应用表的授权集合
|
||||
-- -----------------------------------
|
||||
UPDATE blade_client SET authorized_grant_types = 'authorization_code,password,refresh_token,captcha,social,register' WHERE client_id = 'saber';
|
||||
|
||||
-- -----------------------------------
|
||||
-- 删除可能重复的菜单
|
||||
-- -----------------------------------
|
||||
DELETE FROM "blade_client" WHERE "client_id" = 'saber3';
|
||||
DELETE FROM "blade_client" WHERE "client_id" = 'rider';
|
||||
|
||||
-- -----------------------------------
|
||||
-- 新增客户端记录
|
||||
-- -----------------------------------
|
||||
INSERT INTO "blade_client" ("id", "client_id", "client_secret", "resource_ids", "scope", "authorized_grant_types", "web_server_redirect_uri", "authorities", "access_token_validity", "refresh_token_validity", "additional_information", "autoapprove", "create_user", "create_dept", "create_time", "update_user", "update_time", "status", "is_deleted") VALUES (1123598811738675203, 'saber3', 'saber3_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:2888/login', NULL, 3600, 604800, NULL, NULL, 1123598815738675201, 1123598813738675201, '2024-04-01 00:00:00', 1123598815738675201, '2024-04-01 00:00:00', 1, 0);
|
||||
INSERT INTO "blade_client" ("id", "client_id", "client_secret", "resource_ids", "scope", "authorized_grant_types", "web_server_redirect_uri", "authorities", "access_token_validity", "refresh_token_validity", "additional_information", "autoapprove", "create_user", "create_dept", "create_time", "update_user", "update_time", "status", "is_deleted") VALUES (1123598811738675204, 'rider', 'rider_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:88', NULL, 3600, 604800, NULL, NULL, 1123598815738675201, 1123598813738675201, '2024-04-01 00:00:00', 1123598815738675201, '2024-04-01 00:00:00', 1, 0);
|
@ -0,0 +1,16 @@
|
||||
-- -----------------------------------
|
||||
-- 修改应用表saber的访问地址
|
||||
-- -----------------------------------
|
||||
UPDATE [dbo].[blade_client] SET [authorized_grant_types] = 'authorization_code,password,refresh_token,captcha,social,register' WHERE id < '1123598811738675203';
|
||||
|
||||
-- -----------------------------------
|
||||
-- 删除可能重复的菜单
|
||||
-- -----------------------------------
|
||||
DELETE FROM [dbo].[blade_client] WHERE client_id = 'saber3';
|
||||
DELETE FROM [dbo].[blade_client] WHERE client_id = 'rider';
|
||||
|
||||
-- -----------------------------------
|
||||
-- 新增模型设计菜单
|
||||
-- -----------------------------------
|
||||
INSERT INTO [dbo].[blade_client] ([id], [client_id], [client_secret], [resource_ids], [scope], [authorized_grant_types], [web_server_redirect_uri], [authorities], [access_token_validity], [refresh_token_validity], [additional_information], [autoapprove], [create_user], [create_dept], [create_time], [update_user], [update_time], [status], [is_deleted]) VALUES (1123598811738675203, N'saber3', N'saber3_secret', NULL, N'all', N'authorization_code,password,refresh_token,captcha,social,register', N'http://localhost:2888/login', NULL, 3600, 604800, NULL, NULL, 1123598815738675201, 1123598813738675201, '2024-04-01 00:00:00', 1123598815738675201, '2024-04-01 00:00:00', 1, 0);
|
||||
INSERT INTO [dbo].[blade_client] ([id], [client_id], [client_secret], [resource_ids], [scope], [authorized_grant_types], [web_server_redirect_uri], [authorities], [access_token_validity], [refresh_token_validity], [additional_information], [autoapprove], [create_user], [create_dept], [create_time], [update_user], [update_time], [status], [is_deleted]) VALUES (1123598811738675204, N'rider', N'rider_secret', NULL, N'all', N'authorization_code,password,refresh_token,captcha,social,register', N'http://localhost:88', NULL, 3600, 604800, NULL, NULL, 1123598815738675201, 1123598813738675201, '2024-04-01 00:00:00', 1123598815738675201, '2024-04-01 00:00:00', 1, 0);
|
@ -0,0 +1,16 @@
|
||||
-- -----------------------------------
|
||||
-- 修改应用表的授权集合
|
||||
-- -----------------------------------
|
||||
UPDATE "BLADE_CLIENT" SET AUTHORIZED_GRANT_TYPES = 'authorization_code,password,refresh_token,captcha,social,register' where ID < 1123598811738675203;
|
||||
|
||||
-- -----------------------------------
|
||||
-- 删除可能重复的菜单
|
||||
-- -----------------------------------
|
||||
DELETE FROM "BLADE_CLIENT" WHERE "CLIENT_ID" = 'saber3';
|
||||
DELETE FROM "BLADE_CLIENT" WHERE "CLIENT_ID" = 'rider';
|
||||
|
||||
-- -----------------------------------
|
||||
-- 新增客户端记录
|
||||
-- -----------------------------------
|
||||
INSERT INTO "BLADE_CLIENT" ("ID", "CLIENT_ID", "CLIENT_SECRET", "RESOURCE_IDS", "SCOPE", "AUTHORIZED_GRANT_TYPES", "WEB_SERVER_REDIRECT_URI", "AUTHORITIES", "ACCESS_TOKEN_VALIDITY", "REFRESH_TOKEN_VALIDITY", "ADDITIONAL_INFORMATION", "AUTOAPPROVE", "CREATE_USER", "CREATE_DEPT", "CREATE_TIME", "UPDATE_USER", "UPDATE_TIME", "STATUS", "IS_DELETED") VALUES ('1123598811738675203', 'saber3', 'saber3_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:2888/login', NULL, '3600', '604800', NULL, NULL, '1123598815738675201', '1123598813738675201', TO_DATE('2024-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), '1123598815738675201', TO_DATE('2024-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), '1', '0');
|
||||
INSERT INTO "BLADE_CLIENT" ("ID", "CLIENT_ID", "CLIENT_SECRET", "RESOURCE_IDS", "SCOPE", "AUTHORIZED_GRANT_TYPES", "WEB_SERVER_REDIRECT_URI", "AUTHORITIES", "ACCESS_TOKEN_VALIDITY", "REFRESH_TOKEN_VALIDITY", "ADDITIONAL_INFORMATION", "AUTOAPPROVE", "CREATE_USER", "CREATE_DEPT", "CREATE_TIME", "UPDATE_USER", "UPDATE_TIME", "STATUS", "IS_DELETED") VALUES ('1123598811738675204', 'rider', 'rider_secret', NULL, 'all', 'authorization_code,password,refresh_token,captcha,social,register', 'http://localhost:88', NULL, '3600', '604800', NULL, NULL, '1123598815738675201', '1123598813738675201', TO_DATE('2024-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), '1123598815738675201', TO_DATE('2024-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), '1', '0');
|
@ -0,0 +1,359 @@
|
||||
<?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>
|
||||
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>nenghui-uat</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>4.0.1.RELEASE</version>
|
||||
|
||||
<properties>
|
||||
<bladex.project.id>nenghui-uat</bladex.project.id>
|
||||
<bladex.project.version>4.0.1.RELEASE</bladex.project.version>
|
||||
|
||||
<java.version>17</java.version>
|
||||
<maven.plugin.version>3.11.0</maven.plugin.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<!-- Docker仓库服务配置 -->
|
||||
<docker.registry.url>192.168.0.188</docker.registry.url>
|
||||
<docker.username>admin</docker.username>
|
||||
<docker.password>admin12345</docker.password>
|
||||
<docker.namespace>blade</docker.namespace>
|
||||
<docker.fabric.version>0.42.0</docker.fabric.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springblade.platform</groupId>
|
||||
<artifactId>blade-bom</artifactId>
|
||||
<version>${bladex.project.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- Blade -->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-boot</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-cloud</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-oauth2</artifactId>
|
||||
</dependency>
|
||||
<!-- 多租户字段隔离模式 -->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-tenant</artifactId>
|
||||
</dependency>
|
||||
<!-- 多租户数据库隔离模式则引入此配置 -->
|
||||
<!--<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-tenant-dynamic</artifactId>
|
||||
</dependency>-->
|
||||
<!-- 集成sharding功能则引入此配置 -->
|
||||
<!--<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-sharding</artifactId>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-http</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-api-crypto</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-datascope</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-develop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-social</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-powerjob</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-auto</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 报表 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springblade</groupId>-->
|
||||
<!-- <artifactId>blade-starter-report</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 工作流 -->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-flowable</artifactId>
|
||||
</dependency>
|
||||
<!-- 验证码 -->
|
||||
<dependency>
|
||||
<groupId>com.github.whvcse</groupId>
|
||||
<artifactId>easy-captcha</artifactId>
|
||||
</dependency>
|
||||
<!-- Mybatis-Plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
</dependency>
|
||||
<!--Oss-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-oss</artifactId>
|
||||
</dependency>
|
||||
<!--Sms-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-sms</artifactId>
|
||||
</dependency>
|
||||
<!--Aws S3-->
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
</dependency>
|
||||
<!--MinIO-->
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
</dependency>
|
||||
<!--Alioss-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
</dependency>
|
||||
<!--AliSms-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
</dependency>
|
||||
<!--华为云Obs-->
|
||||
<dependency>
|
||||
<groupId>com.huaweicloud</groupId>
|
||||
<artifactId>esdk-obs-java</artifactId>
|
||||
</dependency>
|
||||
<!--腾讯COS-->
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos_api</artifactId>
|
||||
</dependency>
|
||||
<!--腾讯SMS-->
|
||||
<dependency>
|
||||
<groupId>com.github.qcloudsms</groupId>
|
||||
<artifactId>qcloudsms</artifactId>
|
||||
</dependency>
|
||||
<!--QiNiu-->
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
</dependency>
|
||||
<!--YunPian-->
|
||||
<dependency>
|
||||
<groupId>com.yunpian.sdk</groupId>
|
||||
<artifactId>yunpian-java-sdk</artifactId>
|
||||
</dependency>
|
||||
<!-- liteflow -->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-liteflow</artifactId>
|
||||
</dependency>
|
||||
<!-- Oracle -->
|
||||
<!--<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc7</artifactId>
|
||||
</dependency>-->
|
||||
<!-- PostgreSql -->
|
||||
<!--<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>-->
|
||||
<!-- SqlServer -->
|
||||
<!--<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
</dependency>-->
|
||||
<!-- DaMeng -->
|
||||
<!--<dependency>
|
||||
<groupId>com.dameng</groupId>
|
||||
<artifactId>DmJdbcDriver18</artifactId>
|
||||
</dependency>-->
|
||||
<!--YashanDB-->
|
||||
<!--<dependency>
|
||||
<groupId>com.yashandb.jdbc</groupId>
|
||||
<artifactId>yasdb-jdbc</artifactId>
|
||||
</dependency>-->
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.httpcomponents.client5</groupId>-->
|
||||
<!-- <artifactId>httpclient5</artifactId>-->
|
||||
<!-- <version>5.1.3</version> <!– 请使用最新的版本号 –>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${bladex.project.id}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<configuration>
|
||||
<finalName>${project.build.finalName}</finalName>
|
||||
<excludes>
|
||||
<!-- 打包的 jar 中排除 lombok -->
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>${docker.fabric.version}</version>
|
||||
<configuration>
|
||||
<authConfig>
|
||||
<username>${docker.username}</username>
|
||||
<password>${docker.password}</password>
|
||||
</authConfig>
|
||||
<registry>${docker.registry.url}</registry>
|
||||
<images>
|
||||
<image>
|
||||
<name>${docker.namespace}/${project.build.finalName}:${project.version}</name>
|
||||
<alias>${project.name}</alias>
|
||||
<build>
|
||||
<dockerFile>${project.basedir}/Dockerfile</dockerFile>
|
||||
</build>
|
||||
</image>
|
||||
</images>
|
||||
<buildArgs>
|
||||
<JAR_FILE>${basedir}/target/${project.build.finalName}.jar</JAR_FILE>
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>aliyun-repos</id>
|
||||
<name>Aliyun Public Repository</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bladex</id>
|
||||
<name>BladeX Release Repository</name>
|
||||
<url>https://center.javablade.com/api/packages/blade/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>aliyun-plugin</id>
|
||||
<name>Aliyun Public Plugin</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>bladex</id>
|
||||
<name>BladeX Release Repository</name>
|
||||
<url>https://center.javablade.com/api/packages/blade/maven</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>bladex</id>
|
||||
<name>BladeX Snapshot Repository</name>
|
||||
<url>https://center.javablade.com/api/packages/blade/maven</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade;
|
||||
|
||||
import org.springblade.common.constant.CommonConstant;
|
||||
import org.springblade.core.launch.BladeApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
||||
|
||||
/**
|
||||
* 启动器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@EnableScheduling
|
||||
@EnableRedisHttpSession
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BladeApplication.run(CommonConstant.APPLICATION_NAME, Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.cache;
|
||||
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
|
||||
/**
|
||||
* 缓存名
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface CacheNames {
|
||||
|
||||
/**
|
||||
* 返回拼接后的key
|
||||
*
|
||||
* @param cacheKey 缓存key
|
||||
* @param cacheKeyValue 缓存key值
|
||||
* @return tenantKey
|
||||
*/
|
||||
static String cacheKey(String cacheKey, String cacheKeyValue) {
|
||||
return cacheKey.concat(cacheKeyValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回租户格式的key
|
||||
*
|
||||
* @param tenantId 租户编号
|
||||
* @param cacheKey 缓存key
|
||||
* @param cacheKeyValue 缓存key值
|
||||
* @return tenantKey
|
||||
*/
|
||||
static String tenantKey(String tenantId, String cacheKey, String cacheKeyValue) {
|
||||
return tenantId.concat(StringPool.COLON).concat(cacheKey).concat(cacheKeyValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码key
|
||||
*/
|
||||
String CAPTCHA_KEY = "blade:auth::blade:captcha:";
|
||||
|
||||
/**
|
||||
* 登录失败key
|
||||
*/
|
||||
String USER_FAIL_KEY = "blade:user::blade:fail:";
|
||||
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.cache;
|
||||
|
||||
import org.springblade.common.enums.DictBizEnum;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.modules.system.pojo.entity.DictBiz;
|
||||
import org.springblade.modules.system.service.IDictBizService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
|
||||
|
||||
/**
|
||||
* 业务字典缓存工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class DictBizCache {
|
||||
|
||||
private static final String DICT_ID = "dictBiz:id";
|
||||
private static final String DICT_VALUE = "dictBiz:value";
|
||||
private static final String DICT_LIST = "dictBiz:list";
|
||||
|
||||
private static final IDictBizService dictService;
|
||||
|
||||
static {
|
||||
dictService = SpringUtil.getBean(IDictBizService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典实体
|
||||
*
|
||||
* @param id 主键
|
||||
* @return DictBiz
|
||||
*/
|
||||
public static DictBiz getById(Long id) {
|
||||
String keyPrefix = DICT_ID.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
|
||||
return CacheUtil.get(DICT_CACHE, keyPrefix, id, () -> dictService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictKey Integer型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(DictBizEnum code, Integer dictKey) {
|
||||
return getValue(code.getName(), dictKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey Integer型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String code, Integer dictKey) {
|
||||
String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
|
||||
return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, String.valueOf(dictKey), () -> dictService.getValue(code, String.valueOf(dictKey)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictKey String型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(DictBizEnum code, String dictKey) {
|
||||
return getValue(code.getName(), dictKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey String型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String code, String dictKey) {
|
||||
String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
|
||||
return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, dictKey, () -> dictService.getValue(code, dictKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典集合
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @return List<DictBiz>
|
||||
*/
|
||||
public static List<DictBiz> getList(String code) {
|
||||
String keyPrefix = DICT_LIST.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
|
||||
return CacheUtil.get(DICT_CACHE, keyPrefix, code, () -> dictService.getList(code));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.cache;
|
||||
|
||||
import org.springblade.common.enums.DictEnum;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.modules.system.pojo.entity.Dict;
|
||||
import org.springblade.modules.system.service.IDictService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
|
||||
|
||||
/**
|
||||
* 字典缓存工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class DictCache {
|
||||
|
||||
private static final String DICT_ID = "dict:id:";
|
||||
private static final String DICT_KEY = "dict:key:";
|
||||
private static final String DICT_VALUE = "dict:value:";
|
||||
private static final String DICT_LIST = "dict:list:";
|
||||
|
||||
private static final Boolean TENANT_MODE = Boolean.FALSE;
|
||||
|
||||
private static final IDictService dictService;
|
||||
|
||||
static {
|
||||
dictService = SpringUtil.getBean(IDictService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典实体
|
||||
*
|
||||
* @param id 主键
|
||||
* @return Dict
|
||||
*/
|
||||
public static Dict getById(Long id) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_ID, id, () -> dictService.getById(id), TENANT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictValue 字典值
|
||||
* @return String
|
||||
*/
|
||||
public static String getKey(DictEnum code, String dictValue) {
|
||||
return getKey(code.getName(), dictValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典键
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictValue 字典值
|
||||
* @return String
|
||||
*/
|
||||
public static String getKey(String code, String dictValue) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_KEY + code + StringPool.COLON, dictValue, () -> {
|
||||
List<Dict> list = getList(code);
|
||||
Optional<String> key = list.stream().filter(
|
||||
dict -> dict.getDictValue().equalsIgnoreCase(dictValue)
|
||||
).map(Dict::getDictKey).findFirst();
|
||||
return key.orElse(StringPool.EMPTY);
|
||||
}, TENANT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictKey Integer型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(DictEnum code, Integer dictKey) {
|
||||
return getValue(code.getName(), dictKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey Integer型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String code, Integer dictKey) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, String.valueOf(dictKey), () -> dictService.getValue(code, String.valueOf(dictKey)), TENANT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictKey String型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(DictEnum code, String dictKey) {
|
||||
return getValue(code.getName(), dictKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey String型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String code, String dictKey) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, dictKey, () -> dictService.getValue(code, dictKey), TENANT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典集合
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @return List<Dict>
|
||||
*/
|
||||
public static List<Dict> getList(String code) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_LIST, code, () -> dictService.getList(code), TENANT_MODE);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.cache;
|
||||
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.modules.system.pojo.entity.Param;
|
||||
import org.springblade.modules.system.service.IParamService;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.PARAM_CACHE;
|
||||
|
||||
/**
|
||||
* 参数缓存工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class ParamCache {
|
||||
|
||||
private static final String PARAM_ID = "param:id:";
|
||||
private static final String PARAM_VALUE = "param:value:";
|
||||
|
||||
private static final IParamService paramService;
|
||||
|
||||
static {
|
||||
paramService = SpringUtil.getBean(IParamService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数实体
|
||||
*
|
||||
* @param id 主键
|
||||
* @return Param
|
||||
*/
|
||||
public static Param getById(Long id) {
|
||||
return CacheUtil.get(PARAM_CACHE, PARAM_ID, id, () -> paramService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数配置
|
||||
*
|
||||
* @param paramKey 参数值
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String paramKey) {
|
||||
return CacheUtil.get(PARAM_CACHE, PARAM_VALUE, paramKey, () -> paramService.getValue(paramKey));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.cache;
|
||||
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.modules.system.pojo.entity.Region;
|
||||
import org.springblade.modules.system.service.IRegionService;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* 行政区划缓存工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class RegionCache {
|
||||
public static final String MAIN_CODE = "00";
|
||||
public static final int PROVINCE_LEVEL = 1;
|
||||
public static final int CITY_LEVEL = 2;
|
||||
public static final int DISTRICT_LEVEL = 3;
|
||||
public static final int TOWN_LEVEL = 4;
|
||||
public static final int VILLAGE_LEVEL = 5;
|
||||
|
||||
private static final String REGION_CODE = "region:code:";
|
||||
|
||||
private static final IRegionService regionService;
|
||||
|
||||
static {
|
||||
regionService = SpringUtil.getBean(IRegionService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行政区划实体
|
||||
*
|
||||
* @param code 区划编号
|
||||
* @return Param
|
||||
*/
|
||||
public static Region getByCode(String code) {
|
||||
return CacheUtil.get(SYS_CACHE, REGION_CODE, code, () -> regionService.getById(code));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,326 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.cache;
|
||||
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.modules.system.pojo.entity.*;
|
||||
import org.springblade.modules.system.service.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* 系统缓存
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class SysCache {
|
||||
private static final String MENU_ID = "menu:id:";
|
||||
private static final String DEPT_ID = "dept:id:";
|
||||
private static final String DEPT_NAME = "dept:name:";
|
||||
private static final String DEPT_NAME_FUZZY = "dept:nameFuzzy:";
|
||||
private static final String DEPT_NAME_ID = "deptName:id:";
|
||||
private static final String DEPT_NAMES_ID = "deptNames:id:";
|
||||
private static final String DEPT_CHILD_ID = "deptChild:id:";
|
||||
private static final String DEPT_CHILDIDS_ID = "deptChildIds:id:";
|
||||
private static final String POST_ID = "post:id:";
|
||||
private static final String POST_NAME = "post:name:";
|
||||
private static final String POST_NAME_FUZZY = "post:nameFuzzy:";
|
||||
private static final String POST_NAME_ID = "postName:id:";
|
||||
private static final String POST_NAMES_ID = "postNames:id:";
|
||||
private static final String ROLE_ID = "role:id:";
|
||||
private static final String ROLE_NAME = "role:name:";
|
||||
private static final String ROLE_NAME_ID = "roleName:id:";
|
||||
private static final String ROLE_NAMES_ID = "roleNames:id:";
|
||||
private static final String ROLE_ALIAS_ID = "roleAlias:id:";
|
||||
private static final String ROLE_ALIASES_ID = "roleAliases:id:";
|
||||
public static final String TENANT_ID = "tenant:id:";
|
||||
public static final String TENANT_TENANT_ID = "tenant:tenantId:";
|
||||
public static final String TENANT_PACKAGE_ID = "tenant:packageId:";
|
||||
|
||||
private static final IMenuService menuService;
|
||||
private static final IDeptService deptService;
|
||||
private static final IPostService postService;
|
||||
private static final IRoleService roleService;
|
||||
private static final ITenantService tenantService;
|
||||
private static final ITenantPackageService tenantPackageService;
|
||||
|
||||
static {
|
||||
menuService = SpringUtil.getBean(IMenuService.class);
|
||||
deptService = SpringUtil.getBean(IDeptService.class);
|
||||
postService = SpringUtil.getBean(IPostService.class);
|
||||
roleService = SpringUtil.getBean(IRoleService.class);
|
||||
tenantService = SpringUtil.getBean(ITenantService.class);
|
||||
tenantPackageService = SpringUtil.getBean(ITenantPackageService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 菜单
|
||||
*/
|
||||
public static Menu getMenu(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, MENU_ID, id, () -> menuService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 部门
|
||||
*/
|
||||
public static Dept getDept(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, DEPT_ID, id, () -> deptService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门id
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @param deptNames 部门名
|
||||
* @return 部门id
|
||||
*/
|
||||
public static String getDeptIds(String tenantId, String deptNames) {
|
||||
return CacheUtil.get(SYS_CACHE, DEPT_NAME, tenantId + StringPool.DASH + deptNames, () -> deptService.getDeptIds(tenantId, deptNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门id
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @param deptNames 部门名模糊查询
|
||||
* @return 部门id
|
||||
*/
|
||||
public static String getDeptIdsByFuzzy(String tenantId, String deptNames) {
|
||||
return CacheUtil.get(SYS_CACHE, DEPT_NAME_FUZZY, tenantId + StringPool.DASH + deptNames, () -> deptService.getDeptIdsByFuzzy(tenantId, deptNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门名
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 部门名
|
||||
*/
|
||||
public static String getDeptName(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, DEPT_NAME_ID, id, () -> deptService.getById(id).getDeptName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取部门名集合
|
||||
*
|
||||
* @param deptIds 主键集合
|
||||
* @return 部门名
|
||||
*/
|
||||
public static List<String> getDeptNames(String deptIds) {
|
||||
return CacheUtil.get(SYS_CACHE, DEPT_NAMES_ID, deptIds, () -> deptService.getDeptNames(deptIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子部门集合
|
||||
*
|
||||
* @param deptId 主键
|
||||
* @return 子部门
|
||||
*/
|
||||
public static List<Dept> getDeptChild(Long deptId) {
|
||||
return CacheUtil.get(SYS_CACHE, DEPT_CHILD_ID, deptId, () -> deptService.getDeptChild(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子部门ID集合
|
||||
*
|
||||
* @param deptId 主键
|
||||
* @return 子部门ID
|
||||
*/
|
||||
public static List<Long> getDeptChildIds(Long deptId) {
|
||||
if (deptId == null) {
|
||||
return null;
|
||||
}
|
||||
List<Long> deptIdList = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class);
|
||||
if (deptIdList == null) {
|
||||
deptIdList = new ArrayList<>();
|
||||
List<Dept> deptChild = getDeptChild(deptId);
|
||||
if (deptChild != null) {
|
||||
List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList());
|
||||
deptIdList.addAll(collect);
|
||||
}
|
||||
deptIdList.add(deptId);
|
||||
CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdList);
|
||||
}
|
||||
return deptIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
public static Post getPost(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, POST_ID, id, () -> postService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位id
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @param postNames 岗位名
|
||||
* @return
|
||||
*/
|
||||
public static String getPostIds(String tenantId, String postNames) {
|
||||
return CacheUtil.get(SYS_CACHE, POST_NAME, tenantId + StringPool.DASH + postNames, () -> postService.getPostIds(tenantId, postNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位id
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @param postNames 岗位名模糊查询
|
||||
* @return
|
||||
*/
|
||||
public static String getPostIdsByFuzzy(String tenantId, String postNames) {
|
||||
return CacheUtil.get(SYS_CACHE, POST_NAME_FUZZY, tenantId + StringPool.DASH + postNames, () -> postService.getPostIdsByFuzzy(tenantId, postNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位名
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 岗位名
|
||||
*/
|
||||
public static String getPostName(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, POST_NAME_ID, id, () -> postService.getById(id).getPostName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位名集合
|
||||
*
|
||||
* @param postIds 主键集合
|
||||
* @return 岗位名
|
||||
*/
|
||||
public static List<String> getPostNames(String postIds) {
|
||||
return CacheUtil.get(SYS_CACHE, POST_NAMES_ID, postIds, () -> postService.getPostNames(postIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色
|
||||
*
|
||||
* @param id 主键
|
||||
* @return Role
|
||||
*/
|
||||
public static Role getRole(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, ROLE_ID, id, () -> roleService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色id
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @param roleNames 角色名
|
||||
* @return
|
||||
*/
|
||||
public static String getRoleIds(String tenantId, String roleNames) {
|
||||
return CacheUtil.get(SYS_CACHE, ROLE_NAME, tenantId + StringPool.DASH + roleNames, () -> roleService.getRoleIds(tenantId, roleNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色名
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 角色名
|
||||
*/
|
||||
public static String getRoleName(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, ROLE_NAME_ID, id, () -> roleService.getById(id).getRoleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色名集合
|
||||
*
|
||||
* @param roleIds 主键集合
|
||||
* @return 角色名
|
||||
*/
|
||||
public static List<String> getRoleNames(String roleIds) {
|
||||
return CacheUtil.get(SYS_CACHE, ROLE_NAMES_ID, roleIds, () -> roleService.getRoleNames(roleIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色别名
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 角色别名
|
||||
*/
|
||||
public static String getRoleAlias(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, ROLE_ALIAS_ID, id, () -> roleService.getById(id).getRoleAlias());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色别名集合
|
||||
*
|
||||
* @param roleIds 主键集合
|
||||
* @return 角色别名
|
||||
*/
|
||||
public static List<String> getRoleAliases(String roleIds) {
|
||||
return CacheUtil.get(SYS_CACHE, ROLE_ALIASES_ID, roleIds, () -> roleService.getRoleAliases(roleIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户
|
||||
*
|
||||
* @param id 主键
|
||||
* @return Tenant
|
||||
*/
|
||||
public static Tenant getTenant(Long id) {
|
||||
return CacheUtil.get(SYS_CACHE, TENANT_ID, id, () -> tenantService.getById(id), Boolean.FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @return Tenant
|
||||
*/
|
||||
public static Tenant getTenant(String tenantId) {
|
||||
return CacheUtil.get(SYS_CACHE, TENANT_TENANT_ID, tenantId, () -> tenantService.getByTenantId(tenantId), Boolean.FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户产品包
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @return Tenant
|
||||
*/
|
||||
public static TenantPackage getTenantPackage(String tenantId) {
|
||||
Tenant tenant = getTenant(tenantId);
|
||||
return CacheUtil.get(SYS_CACHE, TENANT_PACKAGE_ID, tenantId, () -> tenantPackageService.getById(tenant.getPackageId()), Boolean.FALSE);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.cache;
|
||||
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.modules.system.pojo.entity.User;
|
||||
import org.springblade.modules.system.service.IUserService;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;
|
||||
import static org.springblade.core.launch.constant.FlowConstant.TASK_USR_PREFIX;
|
||||
|
||||
/**
|
||||
* 系统缓存
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class UserCache {
|
||||
private static final String USER_CACHE_ID = "user:id:";
|
||||
private static final String USER_CACHE_ACCOUNT = "user:account:";
|
||||
|
||||
private static final IUserService userService;
|
||||
|
||||
static {
|
||||
userService = SpringUtil.getBean(IUserService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务用户id获取用户信息
|
||||
*
|
||||
* @param taskUserId 任务用户id
|
||||
* @return
|
||||
*/
|
||||
public static User getUserByTaskUser(String taskUserId) {
|
||||
Long userId = Func.toLong(StringUtil.removePrefix(taskUserId, TASK_USR_PREFIX));
|
||||
return getUser(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
public static User getUser(Long userId) {
|
||||
return CacheUtil.get(USER_CACHE, USER_CACHE_ID, userId, () -> userService.getById(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @param account 账号名
|
||||
* @return
|
||||
*/
|
||||
public static User getUser(String tenantId, String account) {
|
||||
return CacheUtil.get(USER_CACHE, USER_CACHE_ACCOUNT, tenantId + StringPool.DASH + account, () -> userService.userByAccount(tenantId, account));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.config;
|
||||
|
||||
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.oauth2.endpoint.OAuth2SocialEndpoint;
|
||||
import org.springblade.core.oauth2.endpoint.OAuth2TokenEndPoint;
|
||||
import org.springblade.core.secure.registry.SecureRegistry;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Blade配置
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class BladeConfiguration implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 安全框架配置
|
||||
*/
|
||||
@Bean
|
||||
public SecureRegistry secureRegistry() {
|
||||
SecureRegistry secureRegistry = new SecureRegistry();
|
||||
secureRegistry.setEnabled(true);
|
||||
secureRegistry.excludePathPatterns("/blade-auth/**");
|
||||
secureRegistry.excludePathPatterns("/blade-system/tenant/info");
|
||||
secureRegistry.excludePathPatterns("/blade-flow/process/resource-view");
|
||||
secureRegistry.excludePathPatterns("/blade-flow/process/diagram-view");
|
||||
secureRegistry.excludePathPatterns("/blade-flow/manager/check-upload");
|
||||
secureRegistry.excludePathPatterns("/doc.html");
|
||||
secureRegistry.excludePathPatterns("/swagger-ui.html");
|
||||
secureRegistry.excludePathPatterns("/static/**");
|
||||
secureRegistry.excludePathPatterns("/blade-auth/**");
|
||||
secureRegistry.excludePathPatterns("/open/**");
|
||||
secureRegistry.excludePathPatterns("/swagger-resources/**");
|
||||
secureRegistry.excludePathPatterns("/druid/**");
|
||||
return secureRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* 跨域配置
|
||||
*/
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowedHeaders("*")
|
||||
.allowedMethods("*")
|
||||
.maxAge(3600)
|
||||
.allowCredentials(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给OAuth2服务端添加前缀
|
||||
*/
|
||||
@Override
|
||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||
configurer.addPathPrefix(StringPool.SLASH + AppConstant.APPLICATION_AUTH_NAME,
|
||||
c -> c.isAnnotationPresent(RestController.class) && (
|
||||
OAuth2TokenEndPoint.class.equals(c) || OAuth2SocialEndpoint.class.equals(c))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
|
||||
package org.springblade.common.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.common.handler.BladeScopeModelHandler;
|
||||
import org.springblade.core.datascope.handler.ScopeModelHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
/**
|
||||
* Blade处理器自动配置
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AllArgsConstructor
|
||||
public class BladeHandlerConfiguration {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Bean
|
||||
public ScopeModelHandler scopeModelHandler() {
|
||||
return new BladeScopeModelHandler(jdbcTemplate);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
|
||||
package org.springblade.common.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.common.event.ApiLogListener;
|
||||
import org.springblade.common.event.ErrorLogListener;
|
||||
import org.springblade.common.event.UsualLogListener;
|
||||
import org.springblade.core.launch.props.BladeProperties;
|
||||
import org.springblade.core.launch.server.ServerInfo;
|
||||
import org.springblade.modules.system.service.ILogService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 日志工具自动配置
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AllArgsConstructor
|
||||
public class BladeLogConfiguration {
|
||||
|
||||
private final ILogService logService;
|
||||
private final ServerInfo serverInfo;
|
||||
private final BladeProperties bladeProperties;
|
||||
|
||||
@Bean(name = "apiLogListener")
|
||||
public ApiLogListener apiLogListener() {
|
||||
return new ApiLogListener(logService, serverInfo, bladeProperties);
|
||||
}
|
||||
|
||||
@Bean(name = "errorEventListener")
|
||||
public ErrorLogListener errorEventListener() {
|
||||
return new ErrorLogListener(logService, serverInfo, bladeProperties);
|
||||
}
|
||||
|
||||
@Bean(name = "usualEventListener")
|
||||
public UsualLogListener usualEventListener() {
|
||||
return new UsualLogListener(logService, serverInfo, bladeProperties);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package org.springblade.common.config;
|
||||
|
||||
import org.springblade.common.filter.PreviewFilter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 演示配置类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnProperty(value = "blade.preview.enabled", havingValue = "true")
|
||||
public class BladePreviewConfiguration {
|
||||
|
||||
/**
|
||||
* 演示模式配置
|
||||
*/
|
||||
@Bean
|
||||
public PreviewFilter previewFilter() {
|
||||
return new PreviewFilter();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 报表配置类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnProperty(value = "report.enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class BladeReportConfiguration {
|
||||
|
||||
/**
|
||||
* 自定义报表可选数据源
|
||||
*/
|
||||
// @Bean
|
||||
// public ReportDataSource reportDataSource(DataSource dataSource) {
|
||||
// return new ReportDataSource(dataSource);
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Swagger配置类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AllArgsConstructor
|
||||
@ConditionalOnProperty(value = "swagger.enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class SwaggerConfiguration {
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi authApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("授权模块")
|
||||
.packagesToScan(AppConstant.BASE_PACKAGES + ".core.oauth2", AppConstant.BASE_PACKAGES + ".modules.auth")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi sysApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("系统模块")
|
||||
.packagesToScan(AppConstant.BASE_PACKAGES + ".modules.system", AppConstant.BASE_PACKAGES + ".modules.resource")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi operationApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("运维模块")
|
||||
.packagesToScan(AppConstant.BASE_PACKAGES + ".modules.operation", AppConstant.BASE_PACKAGES + ".modules.partner")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi orderApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("工单管理")
|
||||
.packagesToScan(AppConstant.BASE_PACKAGES + ".modules.order")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi fittingApplyApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("物料申请模块")
|
||||
.packagesToScan(AppConstant.BASE_PACKAGES + ".modules.fitting", AppConstant.BASE_PACKAGES + ".modules.material")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi nhApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("监控模块")
|
||||
.packagesToScan(AppConstant.BASE_PACKAGES + ".modules.nh")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi flowApi() {
|
||||
// 创建并返回GroupedOpenApi对象
|
||||
return GroupedOpenApi.builder()
|
||||
.group("工作流模块")
|
||||
.packagesToScan(AppConstant.BASE_PACKAGES + ".modules.flowable", AppConstant.BASE_PACKAGES + ".modules.apply")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.constant;
|
||||
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
|
||||
/**
|
||||
* 通用常量
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface CommonConstant {
|
||||
|
||||
/**
|
||||
* app name
|
||||
*/
|
||||
String APPLICATION_NAME = AppConstant.APPLICATION_NAME_PREFIX + "api";
|
||||
|
||||
/**
|
||||
* sword 系统名
|
||||
*/
|
||||
String SWORD_NAME = "sword";
|
||||
|
||||
/**
|
||||
* saber 系统名
|
||||
*/
|
||||
String SABER_NAME = "saber";
|
||||
|
||||
/**
|
||||
* 顶级父节点id
|
||||
*/
|
||||
Long TOP_PARENT_ID = 0L;
|
||||
|
||||
/**
|
||||
* 顶级父节点名称
|
||||
*/
|
||||
String TOP_PARENT_NAME = "顶级";
|
||||
|
||||
/**
|
||||
* 未封存状态值
|
||||
*/
|
||||
Integer NOT_SEALED_ID = 0;
|
||||
|
||||
/**
|
||||
* 默认密码
|
||||
*/
|
||||
String DEFAULT_PASSWORD = "123456";
|
||||
|
||||
/**
|
||||
* 默认密码参数值
|
||||
*/
|
||||
String DEFAULT_PARAM_PASSWORD = "account.initPassword";
|
||||
|
||||
/**
|
||||
* 默认排序字段
|
||||
*/
|
||||
String SORT_FIELD = "sort";
|
||||
|
||||
/**
|
||||
* 数据权限类型
|
||||
*/
|
||||
Integer DATA_SCOPE_CATEGORY = 1;
|
||||
|
||||
/**
|
||||
* 接口权限类型
|
||||
*/
|
||||
Integer API_SCOPE_CATEGORY = 2;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.constant;
|
||||
|
||||
/**
|
||||
* 字典常量.
|
||||
*
|
||||
* @author zhuangqian
|
||||
*/
|
||||
public interface DictConstant {
|
||||
|
||||
String SEX_CODE = "sex";
|
||||
|
||||
String NOTICE_CODE = "notice";
|
||||
|
||||
String MENU_CATEGORY_CODE = "menu_category";
|
||||
|
||||
String BUTTON_FUNC_CODE = "button_func";
|
||||
|
||||
String YES_NO_CODE = "yes_no";
|
||||
|
||||
String FLOW_CATEGORY_CODE = "flow_category";
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.constant;
|
||||
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
|
||||
/**
|
||||
* 启动常量
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface LauncherConstant {
|
||||
|
||||
/**
|
||||
* sentinel dev 地址
|
||||
*/
|
||||
String SENTINEL_DEV_ADDR = "127.0.0.1:8858";
|
||||
|
||||
/**
|
||||
* sentinel prod 地址
|
||||
*/
|
||||
String SENTINEL_PROD_ADDR = "10.211.55.5:8858";
|
||||
|
||||
/**
|
||||
* sentinel test 地址
|
||||
*/
|
||||
String SENTINEL_TEST_ADDR = "172.30.0.58:8858";
|
||||
|
||||
/**
|
||||
* elk dev 地址
|
||||
*/
|
||||
String ELK_DEV_ADDR = "127.0.0.1:9000";
|
||||
|
||||
/**
|
||||
* elk prod 地址
|
||||
*/
|
||||
String ELK_PROD_ADDR = "172.30.0.58:9000";
|
||||
|
||||
/**
|
||||
* elk test 地址
|
||||
*/
|
||||
String ELK_TEST_ADDR = "172.30.0.58:9000";
|
||||
|
||||
/**
|
||||
* 动态获取sentinel地址
|
||||
*
|
||||
* @param profile 环境变量
|
||||
* @return addr
|
||||
*/
|
||||
static String sentinelAddr(String profile) {
|
||||
switch (profile) {
|
||||
case (AppConstant.PROD_CODE):
|
||||
return SENTINEL_PROD_ADDR;
|
||||
case (AppConstant.TEST_CODE):
|
||||
return SENTINEL_TEST_ADDR;
|
||||
default:
|
||||
return SENTINEL_DEV_ADDR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态获取elk地址
|
||||
*
|
||||
* @param profile 环境变量
|
||||
* @return addr
|
||||
*/
|
||||
static String elkAddr(String profile) {
|
||||
switch (profile) {
|
||||
case (AppConstant.PROD_CODE):
|
||||
return ELK_PROD_ADDR;
|
||||
case (AppConstant.TEST_CODE):
|
||||
return ELK_TEST_ADDR;
|
||||
default:
|
||||
return ELK_DEV_ADDR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package org.springblade.common.constant;
|
||||
|
||||
public class MonitorConstants {
|
||||
|
||||
|
||||
/**
|
||||
* 状态 0、正常 1、关闭 2、屏蔽 3、删除
|
||||
*/
|
||||
public static String NORMAL = "0";
|
||||
|
||||
public static String CLOSE = "1";
|
||||
|
||||
public static String SHIELD = "2";
|
||||
|
||||
public static String DELETE = "3";
|
||||
|
||||
public static String ALARM_ST_NOT_CONFIRMED = "1";
|
||||
public static String ALARM_ST_UNHANDLED = "2";
|
||||
public static String ALARM_ST_HANDLING = "3";
|
||||
public static String ALARM_ST_SOLVED = "4";
|
||||
|
||||
/**
|
||||
* 未关闭
|
||||
*/
|
||||
public static String ALARM_CLOSE_NO = "1";
|
||||
/**
|
||||
* 已关闭
|
||||
*/
|
||||
public static String ALARM_CLOSE_YES = "2";
|
||||
|
||||
/**
|
||||
* 告警类型:1故障、2告警、3提示、4建议 level';
|
||||
*/
|
||||
public static String ALARM_TYPE_FAULT = "1";
|
||||
public static String ALARM_TYPE_WARN = "2";
|
||||
public static String ALARM_TYPE_TIPS = "3";
|
||||
public static String ALARM_TYPE_ADVICE = "4";
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package org.springblade.common.constant;
|
||||
|
||||
/**
|
||||
* 通用常量信息
|
||||
* sadasd
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class NhConstants
|
||||
{
|
||||
|
||||
public static final String HQ_ID = "101";
|
||||
|
||||
public static final String SYS_TYPE_GINLONG = "0";
|
||||
public static final String SYS_TYPE_AISWEI = "1";
|
||||
public static final String SYS_TYPE_GOODWE = "2";
|
||||
public static final String SYS_TYPE_SAJ = "5";
|
||||
|
||||
public static final int STATION_STATUS_NORMAL = 1;
|
||||
public static final int STATION_STATUS_WARN = 2;
|
||||
public static final int STATION_STATUS_ONLINE = 3;
|
||||
|
||||
//低效电站状态
|
||||
public static final int INEFFICIENT_STATION_STATION_TODO = 0;
|
||||
//已转运维
|
||||
public static final int INEFFICIENT_STATION_STATION_DONE = 0;
|
||||
|
||||
/**
|
||||
* 直流
|
||||
*/
|
||||
public static final String UAP_TYPE_DC = "1";
|
||||
/**
|
||||
* 交流
|
||||
*/
|
||||
public static final String UAP_TYPE_AC = "2";
|
||||
|
||||
public static final String UAP_LIST_TEMP_KEY = "UAP_LIST_TEMP_KEY";
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.constant;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户常量
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface TenantConstant {
|
||||
|
||||
/**
|
||||
* 租户默认密码KEY
|
||||
*/
|
||||
String PASSWORD_KEY = "tenant.default.password";
|
||||
|
||||
/**
|
||||
* 租户默认账号额度KEY
|
||||
*/
|
||||
String ACCOUNT_NUMBER_KEY = "tenant.default.accountNumber";
|
||||
|
||||
/**
|
||||
* 租户默认菜单集合KEY
|
||||
*/
|
||||
String ACCOUNT_MENU_CODE_KEY = "tenant.default.menuCode";
|
||||
|
||||
/**
|
||||
* 租户默认密码
|
||||
*/
|
||||
String DEFAULT_PASSWORD = "123456";
|
||||
|
||||
/**
|
||||
* 租户授权码默认16位密钥
|
||||
*/
|
||||
String DES_KEY = "0000000000000000";
|
||||
|
||||
/**
|
||||
* 租户默认账号额度
|
||||
*/
|
||||
Integer DEFAULT_ACCOUNT_NUMBER = -1;
|
||||
|
||||
/**
|
||||
* 租户默认菜单集合
|
||||
*/
|
||||
List<String> MENU_CODES = Arrays.asList(
|
||||
"desk", "flow", "work", "monitor", "resource", "role", "user", "dept", "dictbiz", "topmenu"
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 业务字典枚举类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DictBizEnum {
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
TEST("test"),
|
||||
;
|
||||
|
||||
final String name;
|
||||
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 系统字典枚举类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DictEnum {
|
||||
|
||||
/**
|
||||
* 物料类型
|
||||
*/
|
||||
WL_TYPE("wl_type"),
|
||||
BRAND("device_brand"),
|
||||
/**
|
||||
* 工单状态
|
||||
*/
|
||||
ORDER_STATUS("order_status"),
|
||||
ORDER_TYPE("order_type"),
|
||||
|
||||
/**
|
||||
* 方案类型
|
||||
*/
|
||||
SETTING_PLAN_TYPE("setting_plan_type"),
|
||||
/**
|
||||
* 备案方式
|
||||
*/
|
||||
SETTING_RECORD_TYPE("setting_record_type"),
|
||||
/**
|
||||
* 客户类型
|
||||
*/
|
||||
SETTING_CUSTOMER_TYPE("setting_customer_type"),
|
||||
/**
|
||||
* 电站状态
|
||||
*/
|
||||
POWER_STATION_STATUS("power_station_status"),
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
SEX("sex"),
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
NOTICE("notice"),
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
MENU_CATEGORY("menu_category"),
|
||||
/**
|
||||
* 按钮功能
|
||||
*/
|
||||
BUTTON_FUNC("button_func"),
|
||||
/**
|
||||
* 是否
|
||||
*/
|
||||
YES_NO("yes_no"),
|
||||
/**
|
||||
* 流程类型
|
||||
*/
|
||||
FLOW("flow"),
|
||||
/**
|
||||
* 机构类型
|
||||
*/
|
||||
ORG_CATEGORY("org_category"),
|
||||
/**
|
||||
* 数据权限
|
||||
*/
|
||||
DATA_SCOPE_TYPE("data_scope_type"),
|
||||
/**
|
||||
* 接口权限
|
||||
*/
|
||||
API_SCOPE_TYPE("api_scope_type"),
|
||||
/**
|
||||
* 权限类型
|
||||
*/
|
||||
SCOPE_CATEGORY("scope_category"),
|
||||
/**
|
||||
* 对象存储类型
|
||||
*/
|
||||
OSS("oss"),
|
||||
/**
|
||||
* 短信服务类型
|
||||
*/
|
||||
SMS("sms"),
|
||||
/**
|
||||
* 岗位类型
|
||||
*/
|
||||
POST_CATEGORY("post_category"),
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
REGION("region"),
|
||||
/**
|
||||
* 用户平台
|
||||
*/
|
||||
USER_TYPE("user_type"),
|
||||
|
||||
DEVICE_BRAND("device_brand"),
|
||||
;
|
||||
|
||||
final String name;
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package org.springblade.common.enums;
|
||||
|
||||
import org.springblade.common.constant.NhConstants;
|
||||
|
||||
public class SysType {
|
||||
|
||||
private final String sysType;
|
||||
|
||||
public SysType(String sysType) {
|
||||
this.sysType = sysType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
switch (sysType) {
|
||||
case NhConstants.SYS_TYPE_GINLONG:
|
||||
return "锦浪";
|
||||
case NhConstants.SYS_TYPE_GOODWE:
|
||||
return "固德威";
|
||||
case NhConstants.SYS_TYPE_AISWEI:
|
||||
return "爱士惟";
|
||||
}
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
|
||||
package org.springblade.common.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.launch.props.BladeProperties;
|
||||
import org.springblade.core.launch.server.ServerInfo;
|
||||
import org.springblade.core.log.constant.EventConstant;
|
||||
import org.springblade.core.log.event.ApiLogEvent;
|
||||
import org.springblade.core.log.model.LogApi;
|
||||
import org.springblade.core.log.utils.LogAbstractUtil;
|
||||
import org.springblade.modules.system.service.ILogService;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 异步监听日志事件
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class ApiLogListener {
|
||||
|
||||
private final ILogService logService;
|
||||
private final ServerInfo serverInfo;
|
||||
private final BladeProperties bladeProperties;
|
||||
|
||||
|
||||
@Async
|
||||
@Order
|
||||
@EventListener(ApiLogEvent.class)
|
||||
public void saveApiLog(ApiLogEvent event) {
|
||||
Map<String, Object> source = (Map<String, Object>) event.getSource();
|
||||
LogApi logApi = (LogApi) source.get(EventConstant.EVENT_LOG);
|
||||
LogAbstractUtil.addOtherInfoToLog(logApi, bladeProperties, serverInfo);
|
||||
logService.saveApiLog(logApi);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.event;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.launch.props.BladeProperties;
|
||||
import org.springblade.core.launch.server.ServerInfo;
|
||||
import org.springblade.core.log.constant.EventConstant;
|
||||
import org.springblade.core.log.event.ErrorLogEvent;
|
||||
import org.springblade.core.log.model.LogError;
|
||||
import org.springblade.core.log.utils.LogAbstractUtil;
|
||||
import org.springblade.modules.system.service.ILogService;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 异步监听错误日志事件
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class ErrorLogListener {
|
||||
|
||||
private final ILogService logService;
|
||||
private final ServerInfo serverInfo;
|
||||
private final BladeProperties bladeProperties;
|
||||
|
||||
@Async
|
||||
@Order
|
||||
@EventListener(ErrorLogEvent.class)
|
||||
public void saveErrorLog(ErrorLogEvent event) {
|
||||
try {
|
||||
Map<String, Object> source = (Map<String, Object>) event.getSource();
|
||||
LogError logError = (LogError) source.get(EventConstant.EVENT_LOG);
|
||||
LogAbstractUtil.addOtherInfoToLog(logError, bladeProperties, serverInfo);
|
||||
logService.saveErrorLog(logError);
|
||||
} catch (Exception e) {
|
||||
// 可以根据需要进行更多的异常处理,例如发送警报等
|
||||
log.error("保存错误日志时发生异常", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.event;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.launch.props.BladeProperties;
|
||||
import org.springblade.core.launch.server.ServerInfo;
|
||||
import org.springblade.core.log.constant.EventConstant;
|
||||
import org.springblade.core.log.event.UsualLogEvent;
|
||||
import org.springblade.core.log.model.LogUsual;
|
||||
import org.springblade.core.log.utils.LogAbstractUtil;
|
||||
import org.springblade.modules.system.service.ILogService;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 异步监听日志事件
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class UsualLogListener {
|
||||
|
||||
private final ILogService logService;
|
||||
private final ServerInfo serverInfo;
|
||||
private final BladeProperties bladeProperties;
|
||||
|
||||
@Async
|
||||
@Order
|
||||
@EventListener(UsualLogEvent.class)
|
||||
public void saveUsualLog(UsualLogEvent event) {
|
||||
Map<String, Object> source = (Map<String, Object>) event.getSource();
|
||||
LogUsual logUsual = (LogUsual) source.get(EventConstant.EVENT_LOG);
|
||||
LogAbstractUtil.addOtherInfoToLog(logUsual, bladeProperties, serverInfo);
|
||||
logService.saveUsualLog(logUsual);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package org.springblade.common.filter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestExecution;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LoggingInterceptor implements ClientHttpRequestInterceptor {
|
||||
|
||||
static Logger LOGGER = LoggerFactory.getLogger(LoggingInterceptor.class);
|
||||
private static final boolean debug = false;
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest req, byte[] reqBody, ClientHttpRequestExecution ex) throws IOException {
|
||||
if (debug) {
|
||||
LOGGER.debug("Request body: {}", new String(reqBody, StandardCharsets.UTF_8));
|
||||
}
|
||||
ClientHttpResponse response = ex.execute(req, reqBody);
|
||||
InputStreamReader isr = new InputStreamReader(response.getBody(), StandardCharsets.UTF_8);
|
||||
String body = new BufferedReader(isr).lines().collect(Collectors.joining("\n"));
|
||||
if (debug) {
|
||||
LOGGER.debug("Response body: {}", body);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.filter;
|
||||
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 演示过滤器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class PreviewFilter implements Filter {
|
||||
|
||||
private static final List<String> KEYS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
KEYS.add("notice");
|
||||
KEYS.add("process");
|
||||
KEYS.add("work");
|
||||
KEYS.add("token");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
|
||||
String path = httpServletRequest.getServletPath();
|
||||
String method = httpServletRequest.getMethod();
|
||||
|
||||
String get = "GET";
|
||||
if (method.equals(get) || KEYS.stream().anyMatch(path::contains)) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
} else {
|
||||
throw new RuntimeException("演示环境暂时无法操作!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.handler;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.datascope.constant.DataScopeConstant;
|
||||
import org.springblade.core.datascope.handler.ScopeModelHandler;
|
||||
import org.springblade.core.datascope.model.DataScopeModel;
|
||||
import org.springblade.core.tool.utils.CollectionUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* BladeScopeModelHandler
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
//若开启动态数据源功能,则加上@Master注解指定权限数据库为主库
|
||||
//@Master
|
||||
@RequiredArgsConstructor
|
||||
public class BladeScopeModelHandler implements ScopeModelHandler {
|
||||
|
||||
private static final String SCOPE_CACHE_CODE = "dataScope:code:";
|
||||
private static final String SCOPE_CACHE_CLASS = "dataScope:class:";
|
||||
private static final String DEPT_CACHE_ANCESTORS = "dept:ancestors:";
|
||||
private static final DataScopeModel SEARCHED_DATA_SCOPE_MODEL = new DataScopeModel(Boolean.TRUE);
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
/**
|
||||
* 获取数据权限
|
||||
*
|
||||
* @param mapperId 数据权限mapperId
|
||||
* @param roleId 用户角色集合
|
||||
* @return DataScopeModel
|
||||
*/
|
||||
@Override
|
||||
public DataScopeModel getDataScopeByMapper(String mapperId, String roleId) {
|
||||
List<Object> args = new ArrayList<>(Collections.singletonList(mapperId));
|
||||
List<Long> roleIds = Func.toLongList(roleId);
|
||||
args.addAll(roleIds);
|
||||
// 增加searched字段防止未配置的参数重复读库导致缓存击穿
|
||||
// 后续若有新增配置则会清空缓存重新加载
|
||||
DataScopeModel dataScope = CacheUtil.get(SYS_CACHE, SCOPE_CACHE_CLASS, mapperId + StringPool.COLON + roleId, DataScopeModel.class, Boolean.FALSE);
|
||||
if (dataScope == null || !dataScope.getSearched()) {
|
||||
List<DataScopeModel> list = jdbcTemplate.query(DataScopeConstant.dataByMapper(roleIds.size()), args.toArray(), new BeanPropertyRowMapper<>(DataScopeModel.class));
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
dataScope = list.iterator().next();
|
||||
dataScope.setSearched(Boolean.TRUE);
|
||||
} else {
|
||||
dataScope = SEARCHED_DATA_SCOPE_MODEL;
|
||||
}
|
||||
CacheUtil.put(SYS_CACHE, SCOPE_CACHE_CLASS, mapperId + StringPool.COLON + roleId, dataScope, Boolean.FALSE);
|
||||
}
|
||||
return StringUtil.isNotBlank(dataScope.getResourceCode()) ? dataScope : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据权限
|
||||
*
|
||||
* @param code 数据权限资源编号
|
||||
* @return DataScopeModel
|
||||
*/
|
||||
@Override
|
||||
public DataScopeModel getDataScopeByCode(String code) {
|
||||
DataScopeModel dataScope = CacheUtil.get(SYS_CACHE, SCOPE_CACHE_CODE, code, DataScopeModel.class, Boolean.FALSE);
|
||||
// 增加searched字段防止未配置的参数重复读库导致缓存击穿
|
||||
// 后续若有新增配置则会清空缓存重新加载
|
||||
if (dataScope == null || !dataScope.getSearched()) {
|
||||
List<DataScopeModel> list = jdbcTemplate.query(DataScopeConstant.DATA_BY_CODE, new Object[]{code}, new BeanPropertyRowMapper<>(DataScopeModel.class));
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
dataScope = list.iterator().next();
|
||||
dataScope.setSearched(Boolean.TRUE);
|
||||
} else {
|
||||
dataScope = SEARCHED_DATA_SCOPE_MODEL;
|
||||
}
|
||||
CacheUtil.put(SYS_CACHE, SCOPE_CACHE_CODE, code, dataScope, Boolean.FALSE);
|
||||
}
|
||||
return StringUtil.isNotBlank(dataScope.getResourceCode()) ? dataScope : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门子级
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return deptIds
|
||||
*/
|
||||
@Override
|
||||
public List<Long> getDeptAncestors(Long deptId) {
|
||||
List ancestors = CacheUtil.get(SYS_CACHE, DEPT_CACHE_ANCESTORS, deptId, List.class);
|
||||
if (CollectionUtil.isEmpty(ancestors)) {
|
||||
ancestors = jdbcTemplate.queryForList(DataScopeConstant.DATA_BY_DEPT, new Object[]{deptId}, Long.class);
|
||||
CacheUtil.put(SYS_CACHE, DEPT_CACHE_ANCESTORS, deptId, ancestors);
|
||||
}
|
||||
return ancestors;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.common.launch;
|
||||
|
||||
import org.springblade.common.constant.LauncherConstant;
|
||||
import org.springblade.core.auto.service.AutoService;
|
||||
import org.springblade.core.launch.service.LauncherService;
|
||||
import org.springblade.core.launch.utils.PropsUtil;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 启动参数拓展
|
||||
*
|
||||
* @author smallchil
|
||||
*/
|
||||
@AutoService(LauncherService.class)
|
||||
public class LauncherServiceImpl implements LauncherService {
|
||||
|
||||
@Override
|
||||
public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) {
|
||||
Properties props = System.getProperties();
|
||||
PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile));
|
||||
PropsUtil.setProperty(props, "spring.datasource.dynamic.enabled", "false");
|
||||
// 开启elk日志
|
||||
//PropsUtil.setProperty(props, "blade.log.elk.destination", LauncherConstant.elkAddr(profile));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package org.springblade.common.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AsyncTaskRunner {
|
||||
|
||||
void run(List<Runnable> runnables);
|
||||
|
||||
}
|
@ -0,0 +1,374 @@
|
||||
package org.springblade.common.utils;
|
||||
|
||||
import cn.hutool.core.math.MathUtil;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.springblade.core.http.util.HttpUtil;
|
||||
import org.springblade.core.tool.utils.CollectionUtil;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.utils.DigestUtil;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.modules.nh.pojo.entity.MonitorInverterDailyStatEntity;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.*;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 通用工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class CommonUtil {
|
||||
|
||||
public static Double sum(Double num1, Double num2) {
|
||||
Double sum = 0D;
|
||||
if(num1!=null){
|
||||
sum = sum+num1;
|
||||
}
|
||||
if(num2!=null){
|
||||
sum = sum+num2;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
public static int getDaysInCurrentMonth() {
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
// 获取当前月的最后一天
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth());
|
||||
// 返回当前月的天数
|
||||
return lastDayOfMonth.getDayOfMonth();
|
||||
}
|
||||
|
||||
public static List<String> splitOutStationIds(String outStationIds) {
|
||||
if(StringUtil.isBlank(outStationIds)) return null;
|
||||
String[] arr = outStationIds.split(",");
|
||||
return Arrays.asList(arr);
|
||||
}
|
||||
|
||||
public static List<Object> retainNum(List<Object> list, int num) {
|
||||
List<Object> result = Lists.newArrayList();
|
||||
if(CollectionUtil.isEmpty(list)){
|
||||
return list;
|
||||
}
|
||||
for(Object item : list){
|
||||
if(item instanceof Double){
|
||||
String formattedValue = String.format("%."+num+"f", item);
|
||||
result.add(formattedValue);
|
||||
}else{
|
||||
result.add(item);
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Double retainDoubleNum(Double e, int num) {
|
||||
String formattedValue = String.format("%."+num+"f", e);
|
||||
return Double.parseDouble(formattedValue);
|
||||
}
|
||||
|
||||
public static boolean monthBeginLessThanDays(int days, Date baseDate) {
|
||||
int date = baseDate.getDate();
|
||||
return date <= days;
|
||||
}
|
||||
public static boolean yearBeginLessThanDays(int days, Date baseDate) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(baseDate);
|
||||
return c.get(Calendar.DAY_OF_YEAR) <= days;
|
||||
}
|
||||
|
||||
public static List<String> hourListFrom0() {
|
||||
List<String> ret = new ArrayList<>();
|
||||
for (int i = 0; i < 24; i++) {
|
||||
ret.add(String.format("%d:00", i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<String> hourListFrom1() {
|
||||
List<String> ret = new ArrayList<>();
|
||||
for (int i = 0; i < 24; i++) {
|
||||
ret.add(String.format("%02d", i + 1));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Double getDoubleByFile(Class<?> clazz, MonitorInverterDailyStatEntity entity, String key) {
|
||||
Double ret=null;
|
||||
try{
|
||||
Field field = clazz.getDeclaredField(key);
|
||||
field.setAccessible(true);
|
||||
|
||||
Object value = field.get(entity);
|
||||
return (Double) value;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<Double> repeatNum(int ticks, Double val) {
|
||||
List<Double> ret = new ArrayList<>();
|
||||
for (int i = 0; i < ticks; i++) {
|
||||
ret.add(val);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String queryWeather(String area){
|
||||
String host = "https://weather01.market.alicloudapi.com";
|
||||
String path = "/area-to-weather";
|
||||
String method = "GET";
|
||||
String appcode = "84f9472ee67349189cd5f61c1805a430";
|
||||
Map<String, String> headers = Maps.newHashMap();
|
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " + appcode);
|
||||
Map<String, Object> querys = Maps.newHashMap();
|
||||
querys.put("area", area);
|
||||
querys.put("need3HourForcast", "0");
|
||||
querys.put("needAlarm", "0");
|
||||
querys.put("needHourData", "0");
|
||||
querys.put("needIndex", "0");
|
||||
querys.put("needMoreDay", "0");
|
||||
return HttpUtil.get(host+path,headers,querys);
|
||||
}
|
||||
|
||||
public static String queryWeatherByMonth(String area,String month){
|
||||
String host = "https://weather01.market.alicloudapi.com";
|
||||
String path = "/weatherhistory";
|
||||
String method = "GET";
|
||||
String appcode = "84f9472ee67349189cd5f61c1805a430";
|
||||
Map<String, String> headers = Maps.newHashMap();
|
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " + appcode);
|
||||
Map<String, Object> querys = Maps.newHashMap();
|
||||
querys.put("area", area);
|
||||
querys.put("month", month);
|
||||
return HttpUtil.get(host+path,headers,querys);
|
||||
}
|
||||
|
||||
public static void reflectSetField(Object r, String fieldName, Object value) {
|
||||
try{
|
||||
Field field= r.getClass().getDeclaredField(fieldName);
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
ReflectionUtils.setField(field, r,value);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static Object reflectGetField(Object r, String fieldName) {
|
||||
try{
|
||||
Field field= r.getClass().getDeclaredField(fieldName);
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
return ReflectionUtils.getField(field, r);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BigDecimal getPreHourMax(Map<String, Object> resMap, int hour) {
|
||||
BigDecimal max = BigDecimal.ZERO;
|
||||
for(int i=(hour-1); i>0; i--){
|
||||
BigDecimal bigDecimal = new BigDecimal(resMap.get("h" + i).toString());
|
||||
if(bigDecimal!=null && bigDecimal.compareTo(max) > 0){
|
||||
max = bigDecimal;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public static String assembleIUData(String ukey,String iKey,int max,Object detail){
|
||||
List<String> list = Lists.newArrayList();
|
||||
for(int i=1;i<=max;i++){
|
||||
Object iPvObj = CommonUtil.reflectGetField(detail,iKey+i);
|
||||
Object uPvObj = CommonUtil.reflectGetField(detail,ukey+i);
|
||||
if(iPvObj==null||uPvObj==null){
|
||||
break;
|
||||
}
|
||||
if(iPvObj.equals(0d) && uPvObj.equals(0d)){
|
||||
break;
|
||||
}
|
||||
list.add(uPvObj+":"+iPvObj);
|
||||
}
|
||||
return String.join("|", list);
|
||||
}
|
||||
|
||||
public static void copyFieldToOther(Object sourceObj,String sourceField,Object toObj,String toField){
|
||||
Object sourceVal = CommonUtil.reflectGetField(sourceObj,sourceField);
|
||||
CommonUtil.reflectSetField(toObj,toField,sourceVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param start
|
||||
* @return
|
||||
*/
|
||||
public static String calDuringToNow(Date start){
|
||||
|
||||
String today = DateUtil.format(new Date(),"yyyyMMdd");
|
||||
Date startDate = DateUtil.parse(today+"080000","yyyyMMddHHmmss");
|
||||
|
||||
if(start==null){
|
||||
start = startDate;
|
||||
}
|
||||
|
||||
if(start.after(startDate)){
|
||||
startDate = start;
|
||||
}
|
||||
|
||||
Long now = System.currentTimeMillis();
|
||||
Long startTime = startDate.getTime();
|
||||
long during = (now - startTime)/1000;
|
||||
return convertDuring(during);
|
||||
}
|
||||
|
||||
public static String convertDuring(Long during){
|
||||
if(during==null){
|
||||
return "";
|
||||
}
|
||||
long day = during/(24*3600);
|
||||
during = during%(24*3600);
|
||||
long hour = during/3600;
|
||||
during = during%(3600);
|
||||
long min = during/60;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(day>0){
|
||||
sb.append(day+"天");
|
||||
}
|
||||
if(hour>0){
|
||||
sb.append(hour+"时");
|
||||
}
|
||||
if(min>0){
|
||||
sb.append(min+"分");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static int getVendorIndex(Map<String, Object> ctx){
|
||||
if(ctx.containsKey("index")){
|
||||
int index = (int) ctx.get("index");
|
||||
return index;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String,Object> getCtx(int i){
|
||||
Map<String, Object> ctx = Maps.newHashMap();
|
||||
ctx.put("index",i);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public static List<String> assembleIdsList(List<String> list,int size) {
|
||||
List<String> result = Lists.newArrayList();
|
||||
int page = list.size()/size;
|
||||
if(list.size()%size>0){
|
||||
page++;
|
||||
}
|
||||
for(int i=0;i<page;i++){
|
||||
int last = (i+1)*size;
|
||||
if(last>=list.size()){
|
||||
last = list.size();
|
||||
}
|
||||
List<String> sublist = list.subList(i*size,last);
|
||||
result.add(StringUtil.join(sublist,","));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Double round(Double number,int precision) {
|
||||
BigDecimal bigDecimal = new BigDecimal(number);
|
||||
// 四舍五入到两位有效数字
|
||||
bigDecimal = bigDecimal.round(new java.math.MathContext(precision, RoundingMode.HALF_UP));
|
||||
// 转换回double类型
|
||||
return bigDecimal.doubleValue();
|
||||
}
|
||||
|
||||
public static Double setScale(Double number,int precision) {
|
||||
BigDecimal bigDecimal = new BigDecimal(number);
|
||||
// 四舍五入到两位有效数字
|
||||
bigDecimal = bigDecimal.setScale(precision,RoundingMode.HALF_UP);
|
||||
// 转换回double类型
|
||||
return bigDecimal.doubleValue();
|
||||
}
|
||||
public static boolean isOutTime(Long time,int min){
|
||||
if(time==null) return true;
|
||||
|
||||
long during = System.currentTimeMillis() - time;
|
||||
//超过15分钟
|
||||
if(during>min*60*1000){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Date getNowHour(){
|
||||
// 获取当前日期和时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
int c = now.getMinute()/15;
|
||||
// 获取当前小时的整点时间
|
||||
LocalTime currentHour = LocalTime.of(now.getHour(), c*15);
|
||||
LocalDateTime currentHourDateTime = LocalDateTime.of(now.toLocalDate(), currentHour);
|
||||
// 将LocalDateTime转换为ZonedDateTime
|
||||
ZonedDateTime zonedDateTime = currentHourDateTime.atZone(ZoneId.systemDefault());
|
||||
Instant instant = zonedDateTime.toInstant();
|
||||
// 将Instant转换为Date
|
||||
Date date = Date.from(instant);
|
||||
return date;
|
||||
}
|
||||
|
||||
public static String genSign(Map<String, ?> paramMap){
|
||||
TreeMap<String, Object> treeMap = Maps.newTreeMap();
|
||||
paramMap.forEach((key, value) -> {
|
||||
treeMap.put(key, value);
|
||||
});
|
||||
return genSign(treeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Sign
|
||||
* @return String
|
||||
*/
|
||||
public static String genSign(TreeMap<String, Object> paramMap) {
|
||||
StringBuilder data = new StringBuilder();
|
||||
paramMap.forEach((key, value) -> {
|
||||
if (StringUtil.isNotBlank(data.toString())) {
|
||||
data.append(",");
|
||||
}
|
||||
data.append(key).append("=").append(value);
|
||||
});
|
||||
try {
|
||||
return DigestUtil.sha256Hex(data.toString());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// {
|
||||
// "aqiLevel": "1",
|
||||
// "wind_direction": "无持续风向",
|
||||
// "aqi": "40",
|
||||
// "wind_power": "微风",
|
||||
// "area": "丽江",
|
||||
// "time": "20160101",
|
||||
// "min_temperature": "1",
|
||||
// "max_temperature": "15",
|
||||
// "aqiInfo": "优",
|
||||
// "weather": "多云"
|
||||
// },
|
||||
// System.out.println(queryWeatherByMonth("合肥","202405"));
|
||||
// System.out.println(DateUtil.formatDateTime(getNowHour()));
|
||||
TreeMap<String, Object> paramMap = Maps.newTreeMap();
|
||||
paramMap.put("appId", "123456789");
|
||||
System.out.println(genSign(paramMap));
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.springblade.common.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ListUtils {
|
||||
|
||||
public static boolean isEqualList(final Collection list1, final Collection list2) {
|
||||
if (list1 == list2) {
|
||||
return true;
|
||||
}
|
||||
if (list1 == null || list2 == null || list1.size() != list2.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator it1 = list1.iterator();
|
||||
Iterator it2 = list2.iterator();
|
||||
Object obj1, obj2;
|
||||
|
||||
while (it1.hasNext() && it2.hasNext()) {
|
||||
obj1 = it1.next();
|
||||
obj2 = it2.next();
|
||||
|
||||
if (!(obj1 == null ? obj2 == null : obj1.equals(obj2))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !(it1.hasNext() || it2.hasNext());
|
||||
}
|
||||
|
||||
public static <T> List<List<T>> maxParts(List<T> all, int maxParts) {
|
||||
int partSize = all.size() / maxParts;
|
||||
if (partSize == 0) {
|
||||
partSize = 1;
|
||||
}
|
||||
return CollectionUtil.split(all ,partSize);
|
||||
}
|
||||
|
||||
public static <T> List<List<T>> split(List<T> all, int size) {
|
||||
return org.apache.commons.collections4.ListUtils.partition(all, size);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.springblade.common.utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MonitorTask {
|
||||
private final String taskId;
|
||||
private final Date requestTime;
|
||||
|
||||
public MonitorTask(String taskId) {
|
||||
this.taskId = taskId;
|
||||
this.requestTime = new Date();
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public Date getRequestTime() {
|
||||
return requestTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MonitorTask that = (MonitorTask) o;
|
||||
return Objects.equals(taskId, that.taskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(taskId);
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package org.springblade.common.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class MultiAsyncTaskRunner implements AsyncTaskRunner {
|
||||
|
||||
private final Runnable taskCleaner;
|
||||
private volatile boolean run;
|
||||
private static final Logger log = LoggerFactory.getLogger(MultiAsyncTaskRunner.class);
|
||||
|
||||
public MultiAsyncTaskRunner(String taskId, Runnable taskCleaner) {
|
||||
this.taskCleaner = taskCleaner;
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!run) {
|
||||
log.error("task might hang, task.id: {}", taskId, new Exception());
|
||||
taskCleaner.run();
|
||||
}
|
||||
}
|
||||
}, 30 * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(List<Runnable> runnableList) {
|
||||
run = true;
|
||||
if (CollectionUtils.isEmpty(runnableList)) {
|
||||
taskCleaner.run();
|
||||
return;
|
||||
}
|
||||
CountDownLatch latch = new CountDownLatch(runnableList.size());
|
||||
for (Runnable runnable : runnableList) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
runnable.run();
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
} finally {
|
||||
taskCleaner.run();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package org.springblade.common.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NopTaskRunner implements AsyncTaskRunner {
|
||||
@Override
|
||||
public void run(List<Runnable> runnables) {
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package org.springblade.common.utils;
|
||||
|
||||
public class UnitUtil {
|
||||
|
||||
public static Double convEnergy(Double val, String unit) {
|
||||
if (unit == null || val == null) {
|
||||
return null;
|
||||
}
|
||||
String s = unit.toLowerCase();
|
||||
switch (s) {
|
||||
case "kwh":
|
||||
return val;
|
||||
case "mwh":
|
||||
return val * 1000;
|
||||
case "gwh":
|
||||
return val * 1000 * 1000;
|
||||
case "twh":
|
||||
return val * 1000 * 1000 * 1000;
|
||||
case "pwh":
|
||||
return val * 1000 * 1000 * 1000 * 1000;
|
||||
}
|
||||
throw new RuntimeException("invalid unit: " + unit);
|
||||
}
|
||||
|
||||
public static Double convPower(Double val, String unit) {
|
||||
if (unit == null || val == null) {
|
||||
return null;
|
||||
}
|
||||
String s = unit.toLowerCase();
|
||||
if (s.endsWith("p")) {
|
||||
s = s.substring(0, s.length() - 1);
|
||||
}
|
||||
switch (s) {
|
||||
case "w":
|
||||
return val / 1000;
|
||||
case "kw":
|
||||
return val;
|
||||
case "mw":
|
||||
return val * 1000;
|
||||
case "gw":
|
||||
return val * 1000 * 1000;
|
||||
case "tw":
|
||||
return val * 1000 * 1000 * 1000;
|
||||
case "pw":
|
||||
return val * 1000 * 1000 * 1000 * 1000;
|
||||
}
|
||||
throw new RuntimeException("invalid unit: " + unit);
|
||||
}
|
||||
|
||||
public static Double convVa(Double v, String unit) {
|
||||
if (unit == null || v == null) {
|
||||
return null;
|
||||
}
|
||||
String s = unit.toLowerCase();
|
||||
if (s.endsWith("w")) {
|
||||
return convPower(v, unit);
|
||||
}
|
||||
switch (s) {
|
||||
case "va":
|
||||
return v;
|
||||
case "kva":
|
||||
return v * 1000;
|
||||
case "mva":
|
||||
return v * 1000 * 1000;
|
||||
case "gva":
|
||||
return v * 1000 * 1000 * 1000;
|
||||
}
|
||||
throw new RuntimeException("invalid unit: " + unit);
|
||||
}
|
||||
|
||||
public static Double convHz(Double fac, String facStr) {
|
||||
if (facStr == null || fac == null) {
|
||||
return null;
|
||||
}
|
||||
String s = facStr.toLowerCase();
|
||||
switch (s) {
|
||||
case "hz":
|
||||
return fac;
|
||||
case "khz":
|
||||
return fac * 1000;
|
||||
case "mhz":
|
||||
return fac * 1000 * 1000;
|
||||
case "ghz":
|
||||
return fac * 1000 * 1000 * 1000;
|
||||
}
|
||||
throw new RuntimeException("invalid unit: " + facStr);
|
||||
}
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.business.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.flow.business.service.FlowBusinessService;
|
||||
import org.springblade.flow.core.entity.BladeFlow;
|
||||
import org.springblade.flow.core.utils.TaskUtil;
|
||||
import org.springblade.flow.engine.entity.FlowProcess;
|
||||
import org.springblade.flow.engine.service.FlowEngineService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 流程事务通用接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(AppConstant.APPLICATION_FLOW_NAME + "/work")
|
||||
@Tag(name = "流程事务通用接口", description = "流程事务通用接口")
|
||||
public class WorkController {
|
||||
|
||||
private final TaskService taskService;
|
||||
private final FlowEngineService flowEngineService;
|
||||
private final FlowBusinessService flowBusinessService;
|
||||
|
||||
/**
|
||||
* 发起事务列表页
|
||||
*/
|
||||
@GetMapping("start-list")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "发起事务列表页", description = "传入流程类型")
|
||||
public R<IPage<FlowProcess>> startList(@Parameter(description = "流程类型") String category, Query query, @RequestParam(required = false, defaultValue = "1") Integer mode) {
|
||||
IPage<FlowProcess> pages = flowEngineService.selectProcessPage(Condition.getPage(query), category, mode);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 待签事务列表页
|
||||
*/
|
||||
@GetMapping("claim-list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "待签事务列表页", description = "传入流程信息")
|
||||
public R<IPage<BladeFlow>> claimList(@Parameter(description = "流程信息") BladeFlow bladeFlow, Query query) {
|
||||
IPage<BladeFlow> pages = flowBusinessService.selectClaimPage(Condition.getPage(query), bladeFlow);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 待办事务列表页
|
||||
*/
|
||||
@GetMapping("todo-list")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "待办事务列表页", description = "传入流程信息")
|
||||
public R<IPage<BladeFlow>> todoList(@Parameter(description = "流程信息") BladeFlow bladeFlow, Query query) {
|
||||
IPage<BladeFlow> pages = flowBusinessService.selectTodoPage(Condition.getPage(query), bladeFlow);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 已发事务列表页
|
||||
*/
|
||||
@GetMapping("send-list")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "已发事务列表页", description = "传入流程信息")
|
||||
public R<IPage<BladeFlow>> sendList(@Parameter(description = "流程信息") BladeFlow bladeFlow, Query query) {
|
||||
IPage<BladeFlow> pages = flowBusinessService.selectSendPage(Condition.getPage(query), bladeFlow);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 办结事务列表页
|
||||
*/
|
||||
@GetMapping("done-list")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "办结事务列表页", description = "传入流程信息")
|
||||
public R<IPage<BladeFlow>> doneList(@Parameter(description = "流程信息") BladeFlow bladeFlow, Query query) {
|
||||
IPage<BladeFlow> pages = flowBusinessService.selectDonePage(Condition.getPage(query), bladeFlow);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 签收事务
|
||||
*
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
@PostMapping("claim-task")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "签收事务", description = "传入流程信息")
|
||||
public R claimTask(@Parameter(description = "任务id") String taskId) {
|
||||
taskService.claim(taskId, TaskUtil.getTaskUser());
|
||||
return R.success("签收事务成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*
|
||||
* @param flow 请假信息
|
||||
*/
|
||||
@PostMapping("complete-task")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "完成任务", description = "传入流程信息")
|
||||
public R completeTask(@Parameter(description = "任务信息") @RequestBody BladeFlow flow) {
|
||||
return R.status(flowBusinessService.completeTask(flow));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param reason 删除原因
|
||||
*/
|
||||
@PostMapping("delete-task")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "删除任务", description = "传入流程信息")
|
||||
public R deleteTask(@Parameter(description = "任务id") String taskId, @Parameter(description = "删除原因") String reason) {
|
||||
taskService.deleteTask(taskId, reason);
|
||||
return R.success("删除任务成功");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.flow.core.entity.BladeFlow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程业务类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface FlowBusinessService {
|
||||
|
||||
/**
|
||||
* 流程待签列表
|
||||
*
|
||||
* @param page 分页工具
|
||||
* @param bladeFlow 流程类
|
||||
* @return
|
||||
*/
|
||||
IPage<BladeFlow> selectClaimPage(IPage<BladeFlow> page, BladeFlow bladeFlow);
|
||||
|
||||
/**
|
||||
* 流程待办列表
|
||||
*
|
||||
* @param page 分页工具
|
||||
* @param bladeFlow 流程类
|
||||
* @return
|
||||
*/
|
||||
IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page, BladeFlow bladeFlow);
|
||||
|
||||
/**
|
||||
* 流程已发列表
|
||||
*
|
||||
* @param page 分页工具
|
||||
* @param bladeFlow 流程类
|
||||
* @return
|
||||
*/
|
||||
IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page, BladeFlow bladeFlow);
|
||||
|
||||
/**
|
||||
* 流程办结列表
|
||||
*
|
||||
* @param page 分页工具
|
||||
* @param bladeFlow 流程类
|
||||
* @return
|
||||
*/
|
||||
IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page, BladeFlow bladeFlow);
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*
|
||||
* @param leave 请假信息
|
||||
* @return boolean
|
||||
*/
|
||||
boolean completeTask(BladeFlow leave);
|
||||
|
||||
/**
|
||||
* 获取某个流程事务下已完成的任务
|
||||
*/
|
||||
// List<BladeFlow> findHidTask(String processInstanceId);
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.business.service;
|
||||
|
||||
import org.springblade.flow.core.entity.BladeFlow;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工作流调用接口.
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface IFlowService {
|
||||
|
||||
/**
|
||||
* 开启流程
|
||||
*
|
||||
* @param processDefinitionId 流程id
|
||||
* @param businessKey 业务key
|
||||
* @param variables 参数
|
||||
* @return BladeFlow
|
||||
*/
|
||||
BladeFlow startProcessInstanceById(String processDefinitionId, String businessKey, Map<String, Object> variables);
|
||||
|
||||
/**
|
||||
* 开启流程
|
||||
*
|
||||
* @param processDefinitionKey 流程标识
|
||||
* @param businessKey 业务key
|
||||
* @param variables 参数
|
||||
* @return BladeFlow
|
||||
*/
|
||||
BladeFlow startProcessInstanceByKey(String processDefinitionKey, String businessKey, Map<String, Object> variables);
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param processInstanceId 流程实例id
|
||||
* @param comment 评论
|
||||
* @param variables 参数
|
||||
* @return R
|
||||
*/
|
||||
boolean completeTask(String taskId, String processInstanceId, String comment, Map<String, Object> variables);
|
||||
|
||||
/**
|
||||
* 获取流程变量
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param variableName 变量名
|
||||
* @return R
|
||||
*/
|
||||
Object taskVariable(String taskId, String variableName);
|
||||
|
||||
/**
|
||||
* 获取流程变量集合
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @return R
|
||||
*/
|
||||
Map<String, Object> taskVariables(String taskId);
|
||||
}
|
@ -0,0 +1,343 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.flowable.task.api.TaskQuery;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.flow.business.service.FlowBusinessService;
|
||||
import org.springblade.flow.core.constant.ProcessConstant;
|
||||
import org.springblade.flow.core.entity.BladeFlow;
|
||||
import org.springblade.flow.core.utils.TaskUtil;
|
||||
import org.springblade.flow.engine.constant.FlowEngineConstant;
|
||||
import org.springblade.flow.engine.entity.FlowProcess;
|
||||
import org.springblade.flow.engine.utils.FlowCache;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程业务实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class FlowBusinessServiceImpl implements FlowBusinessService {
|
||||
|
||||
private final TaskService taskService;
|
||||
private final HistoryService historyService;
|
||||
|
||||
@Override
|
||||
public IPage<BladeFlow> selectClaimPage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
|
||||
String taskUser = TaskUtil.getTaskUser();
|
||||
String taskGroup = TaskUtil.getCandidateGroup();
|
||||
List<BladeFlow> flowList = new LinkedList<>();
|
||||
|
||||
// 个人等待签收的任务
|
||||
TaskQuery claimUserQuery = taskService.createTaskQuery().taskCandidateUser(taskUser)
|
||||
.includeProcessVariables().active().orderByTaskCreateTime().desc();
|
||||
// 定制流程等待签收的任务
|
||||
TaskQuery claimRoleWithTenantIdQuery = taskService.createTaskQuery().taskTenantId(AuthUtil.getTenantId()).taskCandidateGroupIn(Func.toStrList(taskGroup))
|
||||
.includeProcessVariables().active().orderByTaskCreateTime().desc();
|
||||
// 通用流程等待签收的任务
|
||||
TaskQuery claimRoleWithoutTenantIdQuery = taskService.createTaskQuery().taskWithoutTenantId().taskCandidateGroupIn(Func.toStrList(taskGroup))
|
||||
.includeProcessVariables().active().orderByTaskCreateTime().desc();
|
||||
|
||||
// 构建列表数据
|
||||
buildFlowTaskList(bladeFlow, flowList, claimUserQuery, FlowEngineConstant.STATUS_CLAIM);
|
||||
buildFlowTaskList(bladeFlow, flowList, claimRoleWithTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
|
||||
buildFlowTaskList(bladeFlow, flowList, claimRoleWithoutTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
|
||||
|
||||
// 计算总数
|
||||
long count = claimUserQuery.count() + claimRoleWithTenantIdQuery.count() + claimRoleWithoutTenantIdQuery.count();
|
||||
// 设置页数
|
||||
page.setSize(count);
|
||||
// 设置总数
|
||||
page.setTotal(count);
|
||||
// 设置数据
|
||||
page.setRecords(flowList);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
|
||||
String taskUser = TaskUtil.getTaskUser();
|
||||
List<BladeFlow> flowList = new LinkedList<>();
|
||||
|
||||
// 已签收的任务
|
||||
TaskQuery todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
|
||||
.includeProcessVariables().orderByTaskCreateTime().desc();
|
||||
|
||||
// 构建列表数据
|
||||
buildFlowTaskList(bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO);
|
||||
|
||||
// 计算总数
|
||||
long count = todoQuery.count();
|
||||
// 设置页数
|
||||
page.setSize(count);
|
||||
// 设置总数
|
||||
page.setTotal(count);
|
||||
// 设置数据
|
||||
page.setRecords(flowList);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
|
||||
String taskUser = TaskUtil.getTaskUser();
|
||||
List<BladeFlow> flowList = new LinkedList<>();
|
||||
|
||||
HistoricProcessInstanceQuery historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser).orderByProcessInstanceStartTime().desc();
|
||||
|
||||
if (bladeFlow.getCategory() != null) {
|
||||
historyQuery.processDefinitionCategory(bladeFlow.getCategory());
|
||||
}
|
||||
if (bladeFlow.getProcessDefinitionName() != null) {
|
||||
historyQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
||||
}
|
||||
if (bladeFlow.getBeginDate() != null) {
|
||||
historyQuery.startedAfter(bladeFlow.getBeginDate());
|
||||
}
|
||||
if (bladeFlow.getEndDate() != null) {
|
||||
historyQuery.startedBefore(bladeFlow.getEndDate());
|
||||
}
|
||||
|
||||
// 查询列表
|
||||
List<HistoricProcessInstance> historyList = historyQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize()));
|
||||
|
||||
historyList.forEach(historicProcessInstance -> {
|
||||
BladeFlow flow = new BladeFlow();
|
||||
// historicProcessInstance
|
||||
flow.setCreateTime(historicProcessInstance.getStartTime());
|
||||
flow.setEndTime(historicProcessInstance.getEndTime());
|
||||
flow.setVariables(historicProcessInstance.getProcessVariables());
|
||||
String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
||||
if (businessKey.length > 1) {
|
||||
flow.setBusinessTable(businessKey[0]);
|
||||
flow.setBusinessId(businessKey[1]);
|
||||
}
|
||||
flow.setHistoryActivityName(historicProcessInstance.getName());
|
||||
flow.setProcessInstanceId(historicProcessInstance.getId());
|
||||
flow.setHistoryProcessInstanceId(historicProcessInstance.getId());
|
||||
// ProcessDefinition
|
||||
FlowProcess processDefinition = FlowCache.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
|
||||
flow.setProcessDefinitionId(processDefinition.getId());
|
||||
flow.setProcessDefinitionName(processDefinition.getName());
|
||||
flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
||||
flow.setProcessDefinitionKey(processDefinition.getKey());
|
||||
flow.setCategory(processDefinition.getCategory());
|
||||
flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
||||
flow.setProcessInstanceId(historicProcessInstance.getId());
|
||||
// HistoricTaskInstance
|
||||
List<HistoricTaskInstance> historyTasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.getId()).orderByHistoricTaskInstanceEndTime().desc().list();
|
||||
if (Func.isNotEmpty(historyTasks)) {
|
||||
HistoricTaskInstance historyTask = historyTasks.iterator().next();
|
||||
flow.setTaskId(historyTask.getId());
|
||||
flow.setTaskName(historyTask.getName());
|
||||
flow.setTaskDefinitionKey(historyTask.getTaskDefinitionKey());
|
||||
}
|
||||
// Status
|
||||
if (historicProcessInstance.getEndActivityId() != null) {
|
||||
flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED);
|
||||
} else {
|
||||
flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
|
||||
}
|
||||
flow.setStatus(FlowEngineConstant.STATUS_FINISH);
|
||||
flowList.add(flow);
|
||||
});
|
||||
|
||||
// 计算总数
|
||||
long count = historyQuery.count();
|
||||
// 设置总数
|
||||
page.setTotal(count);
|
||||
page.setRecords(flowList);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
|
||||
String taskUser = TaskUtil.getTaskUser();
|
||||
List<BladeFlow> flowList = new LinkedList<>();
|
||||
|
||||
HistoricTaskInstanceQuery doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
|
||||
.includeProcessVariables().orderByHistoricTaskInstanceEndTime().desc();
|
||||
|
||||
if (bladeFlow.getCategory() != null) {
|
||||
doneQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory()));
|
||||
}
|
||||
if (bladeFlow.getProcessDefinitionName() != null) {
|
||||
doneQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
||||
}
|
||||
if (bladeFlow.getBeginDate() != null) {
|
||||
doneQuery.taskCompletedAfter(bladeFlow.getBeginDate());
|
||||
}
|
||||
if (bladeFlow.getEndDate() != null) {
|
||||
doneQuery.taskCompletedBefore(bladeFlow.getEndDate());
|
||||
}
|
||||
|
||||
// 查询列表
|
||||
List<HistoricTaskInstance> doneList = doneQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize()));
|
||||
doneList.forEach(historicTaskInstance -> {
|
||||
BladeFlow flow = new BladeFlow();
|
||||
flow.setTaskId(historicTaskInstance.getId());
|
||||
flow.setTaskDefinitionKey(historicTaskInstance.getTaskDefinitionKey());
|
||||
flow.setTaskName(historicTaskInstance.getName());
|
||||
flow.setAssignee(historicTaskInstance.getAssignee());
|
||||
flow.setCreateTime(historicTaskInstance.getCreateTime());
|
||||
flow.setExecutionId(historicTaskInstance.getExecutionId());
|
||||
flow.setHistoryTaskEndTime(historicTaskInstance.getEndTime());
|
||||
flow.setVariables(historicTaskInstance.getProcessVariables());
|
||||
|
||||
FlowProcess processDefinition = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId());
|
||||
flow.setProcessDefinitionId(processDefinition.getId());
|
||||
flow.setProcessDefinitionName(processDefinition.getName());
|
||||
flow.setProcessDefinitionKey(processDefinition.getKey());
|
||||
flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
||||
flow.setCategory(processDefinition.getCategory());
|
||||
flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
||||
|
||||
flow.setProcessInstanceId(historicTaskInstance.getProcessInstanceId());
|
||||
flow.setHistoryProcessInstanceId(historicTaskInstance.getProcessInstanceId());
|
||||
HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance((historicTaskInstance.getProcessInstanceId()));
|
||||
if (Func.isNotEmpty(historicProcessInstance)) {
|
||||
String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
||||
flow.setBusinessTable(businessKey[0]);
|
||||
flow.setBusinessId(businessKey[1]);
|
||||
if (historicProcessInstance.getEndActivityId() != null) {
|
||||
flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED);
|
||||
} else {
|
||||
flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
|
||||
}
|
||||
}
|
||||
flow.setStatus(FlowEngineConstant.STATUS_FINISH);
|
||||
flowList.add(flow);
|
||||
});
|
||||
// 计算总数
|
||||
long count = doneQuery.count();
|
||||
// 设置总数
|
||||
page.setTotal(count);
|
||||
page.setRecords(flowList);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeTask(BladeFlow flow) {
|
||||
String taskId = flow.getTaskId();
|
||||
String processInstanceId = flow.getProcessInstanceId();
|
||||
String comment = Func.toStr(flow.getComment(), ProcessConstant.PASS_COMMENT);
|
||||
// 增加评论
|
||||
if (StringUtil.isNoneBlank(processInstanceId, comment)) {
|
||||
taskService.addComment(taskId, processInstanceId, comment);
|
||||
}
|
||||
// 创建变量
|
||||
Map<String, Object> variables = flow.getVariables();
|
||||
if (variables == null) {
|
||||
variables = Kv.create();
|
||||
}
|
||||
variables.put(ProcessConstant.PASS_KEY, flow.isPass());
|
||||
// 完成任务
|
||||
taskService.complete(taskId, variables);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建流程
|
||||
*
|
||||
* @param bladeFlow 流程通用类
|
||||
* @param flowList 流程列表
|
||||
* @param taskQuery 任务查询类
|
||||
* @param status 状态
|
||||
*/
|
||||
private void buildFlowTaskList(BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status) {
|
||||
if (bladeFlow.getCategory() != null) {
|
||||
taskQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory()));
|
||||
}
|
||||
if (bladeFlow.getProcessDefinitionName() != null) {
|
||||
taskQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
||||
}
|
||||
if (bladeFlow.getBeginDate() != null) {
|
||||
taskQuery.taskCreatedAfter(bladeFlow.getBeginDate());
|
||||
}
|
||||
if (bladeFlow.getEndDate() != null) {
|
||||
taskQuery.taskCreatedBefore(bladeFlow.getEndDate());
|
||||
}
|
||||
taskQuery.list().forEach(task -> {
|
||||
BladeFlow flow = new BladeFlow();
|
||||
flow.setTaskId(task.getId());
|
||||
flow.setTaskDefinitionKey(task.getTaskDefinitionKey());
|
||||
flow.setTaskName(task.getName());
|
||||
flow.setAssignee(task.getAssignee());
|
||||
flow.setCreateTime(task.getCreateTime());
|
||||
flow.setClaimTime(task.getClaimTime());
|
||||
flow.setExecutionId(task.getExecutionId());
|
||||
flow.setVariables(task.getProcessVariables());
|
||||
|
||||
HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance(task.getProcessInstanceId());
|
||||
if (Func.isNotEmpty(historicProcessInstance)) {
|
||||
String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
||||
flow.setBusinessTable(businessKey[0]);
|
||||
flow.setBusinessId(businessKey[1]);
|
||||
}
|
||||
|
||||
FlowProcess processDefinition = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
|
||||
flow.setCategory(processDefinition.getCategory());
|
||||
flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
||||
flow.setProcessDefinitionId(processDefinition.getId());
|
||||
flow.setProcessDefinitionName(processDefinition.getName());
|
||||
flow.setProcessDefinitionKey(processDefinition.getKey());
|
||||
flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
||||
flow.setProcessInstanceId(task.getProcessInstanceId());
|
||||
flow.setStatus(status);
|
||||
flowList.add(flow);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取历史流程
|
||||
*
|
||||
* @param processInstanceId 流程实例id
|
||||
* @return HistoricProcessInstance
|
||||
*/
|
||||
private HistoricProcessInstance getHistoricProcessInstance(String processInstanceId) {
|
||||
return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.business.service.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.flowable.engine.IdentityService;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.flow.business.service.IFlowService;
|
||||
import org.springblade.flow.core.entity.BladeFlow;
|
||||
import org.springblade.flow.core.utils.TaskUtil;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class FlowServiceImpl implements IFlowService {
|
||||
|
||||
private final RuntimeService runtimeService;
|
||||
private final IdentityService identityService;
|
||||
private final TaskService taskService;
|
||||
|
||||
@Override
|
||||
public BladeFlow startProcessInstanceById(String processDefinitionId, String businessKey, Map<String, Object> variables) {
|
||||
// 设置流程启动用户
|
||||
identityService.setAuthenticatedUserId(TaskUtil.getTaskUser());
|
||||
// 开启流程
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinitionId, businessKey, variables);
|
||||
// 组装流程通用类
|
||||
BladeFlow flow = new BladeFlow();
|
||||
flow.setProcessInstanceId(processInstance.getId());
|
||||
return flow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BladeFlow startProcessInstanceByKey(String processDefinitionKey, String businessKey, Map<String, Object> variables) {
|
||||
// 设置流程启动用户
|
||||
identityService.setAuthenticatedUserId(TaskUtil.getTaskUser());
|
||||
// 开启流程
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, variables);
|
||||
// 组装流程通用类
|
||||
BladeFlow flow = new BladeFlow();
|
||||
flow.setProcessInstanceId(processInstance.getId());
|
||||
return flow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeTask(String taskId, String processInstanceId, String comment, Map<String, Object> variables) {
|
||||
// 增加评论
|
||||
if (StringUtil.isNoneBlank(processInstanceId, comment)) {
|
||||
taskService.addComment(taskId, processInstanceId, comment);
|
||||
}
|
||||
// 非空判断
|
||||
if (Func.isEmpty(variables)) {
|
||||
variables = Kv.create();
|
||||
}
|
||||
// 完成任务
|
||||
taskService.complete(taskId, variables);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object taskVariable(String taskId, String variableName) {
|
||||
return R.data(taskService.getVariable(taskId, variableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> taskVariables(String taskId) {
|
||||
return taskService.getVariables(taskId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.core.constant;
|
||||
|
||||
/**
|
||||
* 流程常量.
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ProcessConstant {
|
||||
|
||||
/**
|
||||
* 请假流程标识
|
||||
*/
|
||||
String LEAVE_KEY = "Leave";
|
||||
|
||||
/**
|
||||
* 报销流程标识
|
||||
*/
|
||||
String EXPENSE_KEY = "Expense";
|
||||
|
||||
/**
|
||||
* 同意标识
|
||||
*/
|
||||
String PASS_KEY = "pass";
|
||||
|
||||
/**
|
||||
* 同意代号
|
||||
*/
|
||||
String PASS_ALIAS = "ok";
|
||||
|
||||
/**
|
||||
* 同意默认批复
|
||||
*/
|
||||
String PASS_COMMENT = "同意";
|
||||
|
||||
/**
|
||||
* 驳回默认批复
|
||||
*/
|
||||
String NOT_PASS_COMMENT = "驳回";
|
||||
|
||||
/**
|
||||
* 创建人变量名
|
||||
*/
|
||||
String TASK_VARIABLE_CREATE_USER = "createUser";
|
||||
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.core.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springblade.flow.core.constant.ProcessConstant;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工作流通用实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
public class BladeFlow implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 任务编号
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String taskName;
|
||||
/**
|
||||
* 任务定义Key
|
||||
*/
|
||||
private String taskDefinitionKey;
|
||||
/**
|
||||
* 任务执行人编号
|
||||
*/
|
||||
private String assignee;
|
||||
/**
|
||||
* 任务执行人名称
|
||||
*/
|
||||
private String assigneeName;
|
||||
/**
|
||||
* 流程分类
|
||||
*/
|
||||
private String category;
|
||||
/**
|
||||
* 流程分类名
|
||||
*/
|
||||
private String categoryName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 签收时间
|
||||
*/
|
||||
private Date claimTime;
|
||||
/**
|
||||
* 历史任务结束时间
|
||||
*/
|
||||
private Date historyTaskEndTime;
|
||||
/**
|
||||
* 执行ID
|
||||
*/
|
||||
private String executionId;
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 流程ID
|
||||
*/
|
||||
private String processDefinitionId;
|
||||
/**
|
||||
* 流程标识
|
||||
*/
|
||||
private String processDefinitionKey;
|
||||
/**
|
||||
* 流程名
|
||||
*/
|
||||
private String processDefinitionName;
|
||||
/**
|
||||
* 流程版本
|
||||
*/
|
||||
private int processDefinitionVersion;
|
||||
/**
|
||||
* 流程说明
|
||||
*/
|
||||
private String processDefinitionDesc;
|
||||
/**
|
||||
* 流程简图名
|
||||
*/
|
||||
private String processDefinitionDiagramResName;
|
||||
/**
|
||||
* 流程重命名
|
||||
*/
|
||||
private String processDefinitionResName;
|
||||
/**
|
||||
* 历史任务流程实例ID 查看流程图会用到
|
||||
*/
|
||||
private String historyProcessInstanceId;
|
||||
/**
|
||||
* 流程实例是否结束
|
||||
*/
|
||||
private String processIsFinished;
|
||||
/**
|
||||
* 历史活动ID
|
||||
*/
|
||||
private String historyActivityId;
|
||||
/**
|
||||
* 历史活动流程
|
||||
*/
|
||||
private String historyActivityName;
|
||||
/**
|
||||
* 历史活动耗时
|
||||
*/
|
||||
private String historyActivityDurationTime;
|
||||
/**
|
||||
* 业务绑定Table
|
||||
*/
|
||||
private String businessTable;
|
||||
/**
|
||||
* 业务绑定ID
|
||||
*/
|
||||
private String businessId;
|
||||
/**
|
||||
* 任务状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 任务意见
|
||||
*/
|
||||
private String comment;
|
||||
/**
|
||||
* 是否通过
|
||||
*/
|
||||
private boolean isPass;
|
||||
/**
|
||||
* 是否通过代号
|
||||
*/
|
||||
private String flag;
|
||||
/**
|
||||
* 开始查询日期
|
||||
*/
|
||||
private Date beginDate;
|
||||
/**
|
||||
* 结束查询日期
|
||||
*/
|
||||
private Date endDate;
|
||||
/**
|
||||
* 流程参数
|
||||
*/
|
||||
private Map<String, Object> variables;
|
||||
|
||||
/**
|
||||
* 获取是否通过
|
||||
*/
|
||||
public boolean isPass() {
|
||||
return ProcessConstant.PASS_ALIAS.equals(flag) || ProcessConstant.PASS_COMMENT.equals(comment);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.core.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* FlowEntity
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FlowEntity extends BaseEntity {
|
||||
|
||||
@TableField(exist = false)
|
||||
private BladeFlow flow;
|
||||
|
||||
public BladeFlow getFlow() {
|
||||
if (flow == null) {
|
||||
flow = new BladeFlow();
|
||||
}
|
||||
return flow;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.core.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 流程类型枚举
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum FlowModeEnum {
|
||||
|
||||
/**
|
||||
* 通用流程
|
||||
*/
|
||||
COMMON("common", 1),
|
||||
|
||||
/**
|
||||
* 定制流程
|
||||
*/
|
||||
CUSTOM("custom", 2),
|
||||
;
|
||||
|
||||
final String name;
|
||||
final int mode;
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.core.utils;
|
||||
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.flow.core.constant.ProcessConstant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工作流工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class FlowUtil {
|
||||
|
||||
/**
|
||||
* 定义流程key对应的表名
|
||||
*/
|
||||
private final static Map<String, String> BUSINESS_TABLE = new HashMap<>();
|
||||
|
||||
static {
|
||||
BUSINESS_TABLE.put(ProcessConstant.LEAVE_KEY, "blade_process_leave");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过流程key获取业务表名
|
||||
*
|
||||
* @param key 流程key
|
||||
*/
|
||||
public static String getBusinessTable(String key) {
|
||||
String businessTable = BUSINESS_TABLE.get(key);
|
||||
if (Func.isEmpty(businessTable)) {
|
||||
return StringPool.EMPTY;
|
||||
}
|
||||
return businessTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务标识
|
||||
*
|
||||
* @param businessTable 业务表
|
||||
* @param businessId 业务表主键
|
||||
* @return businessKey
|
||||
*/
|
||||
public static String getBusinessKey(String businessTable, String businessId) {
|
||||
return StringUtil.format("{}:{}", businessTable, businessId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.core.utils;
|
||||
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
||||
import static org.springblade.core.launch.constant.FlowConstant.TASK_USR_PREFIX;
|
||||
|
||||
/**
|
||||
* 工作流任务工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class TaskUtil {
|
||||
|
||||
/**
|
||||
* 获取任务用户格式
|
||||
*
|
||||
* @return taskUser
|
||||
*/
|
||||
public static String getTaskUser() {
|
||||
return StringUtil.format("{}{}", TASK_USR_PREFIX, AuthUtil.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务用户格式
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return taskUser
|
||||
*/
|
||||
public static String getTaskUser(String userId) {
|
||||
return StringUtil.format("{}{}", TASK_USR_PREFIX, userId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户主键
|
||||
*
|
||||
* @param taskUser 任务用户
|
||||
* @return userId
|
||||
*/
|
||||
public static Long getUserId(String taskUser) {
|
||||
return Func.toLong(StringUtil.removePrefix(taskUser, TASK_USR_PREFIX));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户组格式
|
||||
*
|
||||
* @return candidateGroup
|
||||
*/
|
||||
public static String getCandidateGroup() {
|
||||
return AuthUtil.getUserRole();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.demo.leave.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.common.cache.UserCache;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.flow.demo.leave.entity.ProcessLeave;
|
||||
import org.springblade.flow.demo.leave.service.ILeaveService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@RequestMapping(AppConstant.APPLICATION_DESK_NAME + "/process/leave")
|
||||
@AllArgsConstructor
|
||||
public class LeaveController {
|
||||
|
||||
private final ILeaveService leaveService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param businessId 主键
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public R<ProcessLeave> detail(Long businessId) {
|
||||
ProcessLeave detail = leaveService.getById(businessId);
|
||||
detail.getFlow().setAssigneeName(UserCache.getUser(detail.getCreateUser()).getName());
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*
|
||||
* @param leave 请假信息
|
||||
*/
|
||||
@PostMapping("start-process")
|
||||
public R startProcess(@RequestBody ProcessLeave leave) {
|
||||
return R.status(leaveService.startProcess(leave));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.demo.leave.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.flow.core.entity.FlowEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 请假流程实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_process_leave")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProcessLeave extends FlowEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 流程定义id
|
||||
*/
|
||||
private String processDefinitionId;
|
||||
/**
|
||||
* 流程实例id
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 请假开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 请假结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 请假理由
|
||||
*/
|
||||
private String reason;
|
||||
/**
|
||||
* 审批人
|
||||
*/
|
||||
private String taskUser;
|
||||
/**
|
||||
* 流程申请时间
|
||||
*/
|
||||
private Date applyTime;
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.demo.leave.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.flow.demo.leave.entity.ProcessLeave;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface LeaveMapper extends BaseMapper<ProcessLeave> {
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.flow.demo.leave.mapper.LeaveMapper">
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.demo.leave.service;
|
||||
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.flow.demo.leave.entity.ProcessLeave;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ILeaveService extends BaseService<ProcessLeave> {
|
||||
|
||||
/**
|
||||
* 开启流程
|
||||
*
|
||||
* @param leave 请假实体
|
||||
* @return boolean
|
||||
*/
|
||||
boolean startProcess(ProcessLeave leave);
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.engine.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.flowable.spring.SpringProcessEngineConfiguration;
|
||||
import org.flowable.spring.boot.EngineConfigurationConfigurer;
|
||||
import org.flowable.spring.boot.FlowableProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Flowable配置类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AllArgsConstructor
|
||||
@EnableConfigurationProperties(FlowableProperties.class)
|
||||
public class FlowableConfiguration implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {
|
||||
private final FlowableProperties flowableProperties;
|
||||
|
||||
@Override
|
||||
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
|
||||
engineConfiguration.setActivityFontName(flowableProperties.getActivityFontName());
|
||||
engineConfiguration.setLabelFontName(flowableProperties.getLabelFontName());
|
||||
engineConfiguration.setAnnotationFontName(flowableProperties.getAnnotationFontName());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package org.springblade.flow.engine.constant;
|
||||
|
||||
public class BondApplyConstant {
|
||||
|
||||
public static String APPLYSTATUS_ZERO="0";//0.暂存
|
||||
|
||||
public static String APPLYSTATUS_ONE="1";//1.审核中
|
||||
|
||||
public static String APPLYSTATUS_TWO="2";//2.驳回
|
||||
|
||||
public static String APPLYSTATUS_THREE="3";//3.正常
|
||||
|
||||
public static String APPLYSTATUS_FOUR="4";//4 取消
|
||||
|
||||
|
||||
|
||||
public static final String TYPE_ONE = "1"; //审批
|
||||
public static final String TYPE_TWO = "2"; //驳回
|
||||
public static final String TYPE_THREE = "3"; //抄送
|
||||
public static final String TYPE_FOUR = "4"; //转发
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.engine.constant;
|
||||
|
||||
/**
|
||||
* 流程常量.
|
||||
*
|
||||
* @author zhuangqian
|
||||
*/
|
||||
public interface FlowEngineConstant {
|
||||
|
||||
String FLOWABLE_BASE_PACKAGES = "org.flowable.ui";
|
||||
|
||||
String SUFFIX = ".bpmn20.xml";
|
||||
|
||||
String ACTIVE = "active";
|
||||
|
||||
String SUSPEND = "suspend";
|
||||
|
||||
String STATUS_TODO = "todo";
|
||||
|
||||
String STATUS_CLAIM = "claim";
|
||||
|
||||
String STATUS_SEND = "send";
|
||||
|
||||
String STATUS_DONE = "done";
|
||||
|
||||
String STATUS_FINISHED = "finished";
|
||||
|
||||
String STATUS_UNFINISHED = "unfinished";
|
||||
|
||||
String STATUS_FINISH = "finish";
|
||||
|
||||
String START_EVENT = "startEvent";
|
||||
|
||||
String END_EVENT = "endEvent";
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.engine.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.RoleConstant;
|
||||
import org.springblade.flow.engine.entity.FlowExecution;
|
||||
import org.springblade.flow.engine.service.FlowEngineService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 流程状态控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@RequestMapping(AppConstant.APPLICATION_FLOW_NAME + "/follow")
|
||||
@AllArgsConstructor
|
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
|
||||
@Hidden
|
||||
public class FlowFollowController {
|
||||
|
||||
private final FlowEngineService flowEngineService;
|
||||
|
||||
/**
|
||||
* 流程状态列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "分页", description = "传入notice")
|
||||
public R<IPage<FlowExecution>> list(Query query, @Parameter(description = "流程实例id") String processInstanceId, @Parameter(description = "流程key") String processDefinitionKey) {
|
||||
IPage<FlowExecution> pages = flowEngineService.selectFollowPage(Condition.getPage(query), processInstanceId, processDefinitionKey);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程实例
|
||||
*/
|
||||
@PostMapping("delete-process-instance")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "删除", description = "传入主键集合")
|
||||
public R deleteProcessInstance(@Parameter(description = "流程实例id") @RequestParam String processInstanceId, @Parameter(description = "删除原因") @RequestParam String deleteReason) {
|
||||
boolean temp = flowEngineService.deleteProcessInstance(processInstanceId, deleteReason);
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.engine.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.RoleConstant;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.flow.engine.constant.FlowEngineConstant;
|
||||
import org.springblade.flow.engine.entity.FlowProcess;
|
||||
import org.springblade.flow.engine.service.FlowEngineService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 流程管理接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@RequestMapping(AppConstant.APPLICATION_FLOW_NAME + "/manager")
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "流程管理接口", description = "流程管理接口")
|
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
|
||||
@Hidden
|
||||
public class FlowManagerController {
|
||||
|
||||
private final FlowEngineService flowEngineService;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("list")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "分页", description = "传入流程类型")
|
||||
public R<IPage<FlowProcess>> list(@Parameter(description = "流程类型") String category, Query query, @RequestParam(required = false, defaultValue = "1") Integer mode) {
|
||||
IPage<FlowProcess> pages = flowEngineService.selectProcessPage(Condition.getPage(query), category, mode);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更流程状态
|
||||
*
|
||||
* @param state 状态
|
||||
* @param processId 流程id
|
||||
*/
|
||||
@PostMapping("change-state")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "变更流程状态", description = "传入state,processId")
|
||||
public R changeState(@RequestParam String state, @RequestParam String processId) {
|
||||
String msg = flowEngineService.changeState(state, processId);
|
||||
return R.success(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部署流程
|
||||
*
|
||||
* @param deploymentIds 部署流程id集合
|
||||
*/
|
||||
@PostMapping("delete-deployment")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "删除部署流程", description = "部署流程id集合")
|
||||
public R deleteDeployment(String deploymentIds) {
|
||||
return R.status(flowEngineService.deleteDeployment(deploymentIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查流程文件格式
|
||||
*
|
||||
* @param file 流程文件
|
||||
*/
|
||||
@PostMapping("check-upload")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "上传部署流程文件", description = "传入文件")
|
||||
public R checkUpload(@RequestParam MultipartFile file) {
|
||||
boolean temp = Objects.requireNonNull(file.getOriginalFilename()).endsWith(FlowEngineConstant.SUFFIX);
|
||||
return R.data(Kv.create().set("name", file.getOriginalFilename()).set("success", temp));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传部署流程文件
|
||||
*
|
||||
* @param files 流程文件
|
||||
* @param category 类型
|
||||
*/
|
||||
@PostMapping("deploy-upload")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "上传部署流程文件", description = "传入文件")
|
||||
public R deployUpload(@RequestParam List<MultipartFile> files,
|
||||
@RequestParam String category,
|
||||
@RequestParam(required = false, defaultValue = "") String tenantIds) {
|
||||
return R.status(flowEngineService.deployUpload(files, category, Func.toStrList(tenantIds)));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.flow.engine.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.RoleConstant;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.flow.engine.entity.FlowModel;
|
||||
import org.springblade.flow.engine.service.FlowEngineService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程模型控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@RequestMapping(AppConstant.APPLICATION_FLOW_NAME + "/model")
|
||||
@AllArgsConstructor
|
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
|
||||
@Hidden
|
||||
public class FlowModelController {
|
||||
|
||||
private final FlowEngineService flowEngineService;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "modelKey", description = "模型标识", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "name", description = "模型名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "分页", description = "传入notice")
|
||||
public R<IPage<FlowModel>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> flow, Query query) {
|
||||
IPage<FlowModel> pages = flowEngineService.page(Condition.getPage(query), Condition.getQueryWrapper(flow, FlowModel.class)
|
||||
.select("id,model_key modelKey,name,description,version,created,last_updated lastUpdated")
|
||||
.orderByDesc("last_updated"));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "删除", description = "传入主键集合")
|
||||
public R remove(@Parameter(description = "主键集合") @RequestParam String ids) {
|
||||
boolean temp = flowEngineService.removeByIds(Func.toStrList(ids));
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部署
|
||||
*/
|
||||
@PostMapping("/deploy")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "部署", description = "传入模型id和分类")
|
||||
public R deploy(@Parameter(description = "模型id") @RequestParam String modelId,
|
||||
@Parameter(description = "工作流分类") @RequestParam String category,
|
||||
@Parameter(description = "租户ID") @RequestParam(required = false, defaultValue = "") String tenantIds) {
|
||||
boolean temp = flowEngineService.deployModel(modelId, category, Func.toStrList(tenantIds));
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
@PostMapping("submit")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "保存/编辑")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "模型id"),
|
||||
@Parameter(name = "name", description = "模型名称", required = true),
|
||||
@Parameter(name = "modelKey", description = "模型key", required = true),
|
||||
@Parameter(name = "description", description = "模型描述"),
|
||||
@Parameter(name = "xml", description = "模型xml", required = true),
|
||||
})
|
||||
public R<FlowModel> submit(@RequestBody @Parameter(hidden = true) FlowModel model) {
|
||||
return R.data(flowEngineService.submitModel(model));
|
||||
}
|
||||
|
||||
@GetMapping("detail")
|
||||
@Operation(summary = "详情")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "模型id", required = true),
|
||||
})
|
||||
public R<FlowModel> detail(String id) {
|
||||
return R.data(flowEngineService.getById(id));
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue