diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..92f4631fba52b76e8f32e3b49fc4ce99f74183ea
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,42 @@
+
+### 版本号:2.2.4
+- 更新日期:2025-10-07
+- 更新内容:
+1. 基于EFRAME进行调整更新
+2. 拆分CHANGELOG文件
+3. 增加Prometheus相关代码,支持promQL
+4. 更新redis配置文件,更新其他Datasource配置文件
+5. 优化调整magic的配置信息
+6. 对代码的格式、注释、引用等进行标准化改造
+7. magic-editor文字更新,暂时使用编译成果
+8. 基于eframe进行修改配置信息调整,删除view包
+9. 暂不引用eframe的api包,对controller进行拷贝,仅保留登录api文件
+10. config路径移动到scripts下
+11. workflow文件移动到scripts下
+12. 工程路径调整为:java-magic-api
+13. 更新README.md文件内容
+
+
+### 版本号:2.2.3
+- 更新日期:2025-06-26
+- 更新内容:
+```
+2.2.3 2025-06-26 ent版本升级,删除gov框架的包
+
+2.2.2 2025-06-02 配置SecurityConfig内白名单路径,修改javadoc注释信息
+2.2.1 2025-05-25 配置SecurityConfig内白名单路径,修改javadoc注释信息
+2.2.0 2025-05-24 变量前缀统一调整为platform
+
+2.1.5 2025-05-21 进行代码资源调整,集成融合java-ent-parent资源
+2.1.4 2025-02-11 增加本地jar包
+2.1.3 2025-02-08 entdb框架已经融合,暂时放开不需要登录方式
+将magic-editor的2.1.1资源拷贝到工程中,进行修改title、ico等
+融合entdb配置SecurityConfig信息,对/llxm/**进行白名单放行,后续需进行安全加固
+后续验证迁移到可使用达梦数据库环境
+
+2.1.2 2025-02-07 增加多数据源支撑,增加配置信息加密处理,后续完善entdb框架中的登录信息
+
+2.1.1 2025-02-06 基于Magic-api的工程,修改包路径
+
+2.1.0 2025-01-12 初始化版本
+```
\ No newline at end of file
diff --git a/FAQ.md b/FAQ.md
new file mode 100644
index 0000000000000000000000000000000000000000..6b2fce3c7902a9034c756000b5e8ea53e0541675
--- /dev/null
+++ b/FAQ.md
@@ -0,0 +1,16 @@
+### 分支情况说明
+```
+master:主分支
+develop:开发分支
+
+```
+
+### 待解决和规划扩展
+```
+
+```
+
+### 常见问题及处理
+```
+
+```
diff --git a/README.en.md b/README.en.md
new file mode 100644
index 0000000000000000000000000000000000000000..b86a3cdefc0ec7e3bce4e517dcd64464bc914fe9
--- /dev/null
+++ b/README.en.md
@@ -0,0 +1,69 @@
+# java-magic-api
+
+[](https://www.apache.org/licenses/LICENSE-2.0)
+
+
+
+## Introduce
+
+The project based on Magic-api is used for data interface configuration project, which can realize api output by configuring SQL and mybatis,
+support configuring promQL to write Prometheus scripts, and realize monitoring stream data and real-time status inquiry machine display.
+
+## Change Log
+
+[CHANGELOG](./CHANGELOG.md)
+
+
+## Technical Guidelines
+### Software Architecture
+```
+Springboot + Framework + Security + Mybatis
+```
+
+### Installation
+1. mvn clean install
+2. mvn clean deploy
+
+### Instructions
+1. use by maven
+```
+
+ ${groupId}
+ ${artifactId}
+ ${project.version}
+ test
+
+```
+2. use direct jar
+
+## Contribution
+1. Fork repository
+2. new Feat_1.0.0 branch
+3. commit
+```
+git config user.name linlaninfo
+git config user.email linlannet@163.com
+git config --global --list
+git config --list
+```
+4. new Pull Request
+5. create and commit tag
+```
+create
+git tag -a 1.0.0 -m "initial version"
+list
+git tag
+commit
+git push origin --tags
+delete
+git tag -d 1.0.0
+
+install: mvn clean install
+deploy: mvn clean deploy
+
+```
+6. other
+
+## Licence
+
+[Apache 2.0 © java-magic-api 2023](./LICENSE)
diff --git a/README.md b/README.md
index c31a6268495f26a456d677ec1a1dcd9cb67eada4..7ea3e571f7b296a485024334caf084bb6e84b4ae 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,68 @@
-# java-stage-magic-api
-基于Magic-api的工程,用于项目,可通过配置SQL、mybatis方式实现api输出
+# java-magic-api
+[](https://www.apache.org/licenses/LICENSE-2.0)
+
+
-## 版本信息
+## 介绍
+
+基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+
+
+## 版本历史
+
+[CHANGELOG](./CHANGELOG.md)
+
+## 技术路径
+### 软件架构
+```
+Springboot + Framework + Security + Mybatis
```
-2.2.3 2025-06-26 ent版本升级,删除gov框架的包
+### 安装教程
+1. mvn clean install
+2. mvn clean deploy
-2.2.2 2025-06-02 配置SecurityConfig内白名单路径,修改javadoc注释信息
-2.2.1 2025-05-25 配置SecurityConfig内白名单路径,修改javadoc注释信息
-2.2.0 2025-05-24 变量前缀统一调整为platform
+### 使用说明
+1. 通过依赖使用
+```
+
+ ${groupId}
+ ${artifactId}
+ ${project.version}
+ test
+
+```
+2. 直接拷贝打包后的jar包
-2.1.5 2025-05-21 进行代码资源调整,集成融合java-ent-parent资源
-2.1.4 2025-02-11 增加本地jar包
-2.1.3 2025-02-08 entdb框架已经融合,暂时放开不需要登录方式
-将magic-editor的2.1.1资源拷贝到工程中,进行修改title、ico等
-融合entdb配置SecurityConfig信息,对/llxm/**进行白名单放行,后续需进行安全加固
-后续验证迁移到可使用达梦数据库环境
+## 参与贡献
+1. Fork 本仓库
+2. 新建 Feat_1.0.0 分支
+3. 提交代码
+```
+git config user.name linlaninfo
+git config user.email linlannet@163.com
+git config --global --list
+git config --list
+```
+4. 新建 Pull Request
+5. 创建和提交tag
+```
+创建
+git tag -a 1.0.0 -m "初始化版本"
+查看
+git tag
+提交
+git push origin --tags
+删除
+git tag -d 1.0.0
-2.1.2 2025-02-07 增加多数据源支撑,增加配置信息加密处理,后续完善entdb框架中的登录信息
+本地编译:mvn clean install
+发布到github:mvn clean deploy
-2.1.1 2025-02-06 基于Magic-api的工程,修改包路径
+```
+6. 其他
-2.1.0 2025-01-12 初始化版本
+## 版权
-```
\ No newline at end of file
+[Apache 2.0 © java-magic-api 2023](./LICENSE)
diff --git a/pom.xml b/pom.xml
index bcdd356129e2aeee3d70f01ca64379c355b6908d..9054cf35a77eb0d727898bbbdce260a5bea6741c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,23 @@
+
@@ -10,10 +29,10 @@
2.7.18
net.linlan.stage
- java-stage-magic-api
- 2.2.3
- java-stage-magic-api
- 基于Magic-api的工程,用于项目,可通过配置SQL、mybatis方式实现api输出
+ java-magic-api
+ 2.2.4
+ java-magic-api
+ 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
UTF-8
@@ -41,14 +60,17 @@
0.9.1
1.21
4.1.2
+ 4.2
+ 2.16.0
+ 1.6.2
- 2.3.12
- 2.6.6
- 1.8.24
+ 2.3.12
+ 2.6.7
+ 1.1.6
- https://gitee.com/linlannet/java-stage-magic-api.git
+ https://gitee.com/linlannet/java-magic-api.git
Apache-2.0
@@ -56,8 +78,8 @@
- https://gitee.com/linlannet/java-stage-magic-api
- scm:git:git://gitee.com/linlannet/java-stage-magic-api.git
+ https://gitee.com/linlannet/java-magic-api
+ scm:git:git://gitee.com/linlannet/java-magic-api.git
@@ -226,7 +248,11 @@
-
+
+ com.squareup.okhttp3
+ okhttp
+ 4.9.3
+
com.github.ulisesbocchio
@@ -244,33 +270,32 @@
${linlan.tools.version}
- net.linlan.ent
- utils-ent
- ${java.ent.version}
+ net.linlan.eframe
+ eframe-support
+ ${linlan.eframe.version}
- net.linlan.ent
- model-ent-admin
- ${java.ent.version}
+ net.linlan.eframe
+ eframe-core
+ ${linlan.eframe.version}
- net.linlan.ent
- view-ent-comm
- ${java.ent.version}
+ net.linlan.eframe
+ eframe-model
+ ${linlan.eframe.version}
- net.linlan.ent
- view-ent-admin
- ${java.ent.version}
+ net.linlan.eframe
+ eframe-view
+ ${linlan.eframe.version}
-
-
-
+
+
+
-
@@ -410,6 +435,135 @@
true
+
+
+ com.mycila
+ license-maven-plugin
+ ${license-maven-plugin.version}
+
+
+ compile
+
+ remove
+ format
+
+
+
+
+ true
+ ${user.dir}/scripts/codestyle/HEADER
+
+ Linlan
+ 2020-2025
+ open@linlan.net
+
+
+
+ **/*.java
+
+
+ **/*.ts
+ **/*.tsx
+ **/*.js
+ **/*.jsx
+ **/*.vue
+ **/*.css
+
+
+ **/*.xml
+ **/*.properties
+ **/*.yaml
+
+
+
+ *.sh
+ *.yml
+ *.iml
+ *.config
+ **/*.ftlh
+ .editorconfig
+ .gitignore
+ LICENSE
+ **/*.md
+ **/*.log
+ **/codestyle/HEADER
+ **/.gitkeep
+ **/spring.factories
+ **/.mvn/**
+ **/mvnw
+ **/ip2region.db
+ **/resources/template/**
+ **/node_modules/**
+ **/.umi-production/**
+ **/docs/**
+ **/dictionaries/**
+ **/static/antd.min.css
+ **/META-INF/**
+
+ true
+
+ SLASHSTAR_STYLE
+ JAVADOC_STYLE
+ JAVADOC_STYLE
+
+
+
+
+
+ net.revelc.code.formatter
+ formatter-maven-plugin
+ ${formatter-maven-plugin.version}
+
+
+ compile
+
+ format
+ validate
+
+
+
+
+ ${user.dir}/scripts/codestyle/Formatter.xml
+ ${project.build.sourceEncoding}
+
+ **/static/antd.min.css
+
+
+
+
+
+ net.revelc.code
+ impsort-maven-plugin
+ ${impsort-maven-plugin.version}
+
+ ${java.version}
+ java.,javax.,org.,com.,cn.,lombok.
+ java.,javax.,org.,com.,cn.,lombok.
+
+ false
+ true
+
+ true
+ true
+ true
+ true
+
+
+
+ sort-imports
+
+ sort
+
+
+
+
+
+ org.codehaus.plexus
+ plexus-utils
+ 3.5.1
+
+
+
diff --git a/.workflow/branch-pipeline.yml b/scripts/.workflow/branch-pipeline.yml
similarity index 100%
rename from .workflow/branch-pipeline.yml
rename to scripts/.workflow/branch-pipeline.yml
diff --git a/.workflow/master-pipeline.yml b/scripts/.workflow/master-pipeline.yml
similarity index 100%
rename from .workflow/master-pipeline.yml
rename to scripts/.workflow/master-pipeline.yml
diff --git a/.workflow/pr-pipeline.yml b/scripts/.workflow/pr-pipeline.yml
similarity index 100%
rename from .workflow/pr-pipeline.yml
rename to scripts/.workflow/pr-pipeline.yml
diff --git a/scripts/codestyle/Formatter.xml b/scripts/codestyle/Formatter.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7c5f983d008ef01f24cedc60941e1175c3d23ddc
--- /dev/null
+++ b/scripts/codestyle/Formatter.xml
@@ -0,0 +1,400 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scripts/codestyle/HEADER b/scripts/codestyle/HEADER
new file mode 100644
index 0000000000000000000000000000000000000000..90fc13a732415a1de29f96b90bb56ec126d9a7b9
--- /dev/null
+++ b/scripts/codestyle/HEADER
@@ -0,0 +1,15 @@
+${project.name} - ${project.description}
+Copyright © 2020-2025 Linlan (open@linlan.net)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
\ No newline at end of file
diff --git a/config/Dockerfile b/scripts/config/Dockerfile
similarity index 67%
rename from config/Dockerfile
rename to scripts/config/Dockerfile
index 146e8098cd4aedeb6177761946fb0ebcb2079c51..ed2c20279c2b22b98eab82730dba07ac91cdeec6 100644
--- a/config/Dockerfile
+++ b/scripts/config/Dockerfile
@@ -9,14 +9,14 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
#设置编码
ENV LANG C.UTF-8
-ADD java-stage-magic-api.jar /data/
+ADD java-magic-api.jar /data/
#没有lib包注释改行
#ADD lib /data/lib
WORKDIR /data
#测试环境
-#CMD java -jar java-stage-magic-api.jar
+#CMD java -jar java-magic-api.jar
#生产环境
-#CMD java -server -Xmx4g -Xms4g -XX:+UseG1GC -jar java-stage-magic-api.jar
-CMD java -server -Xmx4g -Xms4g -XX:+UseG1GC -Dspring.profiles.active=release -jar java-stage-magic-api.jar
+#CMD java -server -Xmx4g -Xms4g -XX:+UseG1GC -jar java-magic-api.jar
+CMD java -server -Xmx4g -Xms4g -XX:+UseG1GC -Dspring.profiles.active=release -jar java-magic-api.jar
diff --git a/config/stage-shell.sh b/scripts/config/stage-shell.sh
similarity index 65%
rename from config/stage-shell.sh
rename to scripts/config/stage-shell.sh
index 60d7ae9b16118afc509336da803dd1b9591975a7..56f6ba221ad7c1d1623090de1fe7d6dd4c38476b 100644
--- a/config/stage-shell.sh
+++ b/scripts/config/stage-shell.sh
@@ -13,20 +13,20 @@ done
# 2、clean old war or jar
cd /www/api/gov
-rm -dfr /www/api/gov/java-stage-magic-api*.jar
-rm -rf /www/api/gov/java-stage-magic-api*.txt
+rm -dfr /www/api/gov/java-magic-api*.jar
+rm -rf /www/api/gov/java-magic-api*.txt
# 3、拷贝现有打包文件,进行部署
#cd到jar包所在目录
#爬取版本号
-var=`curl -u https://repo1.maven.org/maven2/net/linlan/stage/java-stage-magic-api/`
+var=`curl -u https://repo1.maven.org/maven2/net/linlan/stage/java-magic-api/`
#找出最大版本号 并且赋给变量
edt=`echo "$var" | egrep td|grep href|grep -oE "[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}"|sort -rVu|head -n 1`
#拉取jar包
-wget https://repo1.maven.org/maven2/net/linlan/stage/java-stage-magic-api/"$edt"/java-stage-magic-api-"$edt".jar
+wget https://repo1.maven.org/maven2/net/linlan/stage/java-magic-api/"$edt"/java-magic-api-"$edt".jar
#启动jar包
-nohup java -jar -Xms256m -Xmx256m -XX:PermSize=128M -XX:MaxPermSize=512M java-stage-magic-api-"$edt".jar --server.port=8018 --spring.profiles.active=dev >java-stage-magic-api-log"$(date +%Y-%m-%d)".8018.txt 2>&1 &
+nohup java -jar -Xms256m -Xmx256m -XX:PermSize=128M -XX:MaxPermSize=512M java-magic-api-"$edt".jar --server.port=8018 --spring.profiles.active=dev >java-magic-api-log"$(date +%Y-%m-%d)".8018.txt 2>&1 &
diff --git a/scripts/db/db-script.sql b/scripts/db/db-script.sql
index fca6fb92d73eebaa03e10d6dea22735efb3e4bca..0892e163a07461405fee2b96ac7b3c25ba953a6d 100644
--- a/scripts/db/db-script.sql
+++ b/scripts/db/db-script.sql
@@ -1,162 +1,19 @@
-
-create table `ll_system_1_1_2` (
- `cfg_id` varchar(50) not null,
- `cfg_key` varchar(50) not null,
- `cfg_value` varchar(4000) not null,
- `is_disabled` tinyint(1) default null,
- `description` varchar(800) default null,
- primary key (`cfg_id`),
- key `idx_global_config_whole_key` (`cfg_key`)
-) ;
-
-
-insert into `ll_system_1_1_2`(`cfg_id`,`cfg_key`,`cfg_value`,`is_disabled`,`description`) values
- ('100006','sys.login.blackiplist','',0,'设置登录ip黑名单限制,多个匹配项以;分隔,支持匹配(*通配、网段)');
-
-
-create table `ll_system_3_1_3` (
- `role_id` bigint not null,
- `roletype_id` varchar(50) default null,
- `app_id` varchar(50) default null,
- `user_id` varchar(50) default null,
- `name` varchar(100) not null,
- `code` varchar(50) not null,
- `priority` int not null default '10',
- `is_regular` tinyint(1) not null default '0',
- `is_super` tinyint(1) not null default '0',
- `is_public` tinyint(1) default null,
- `create_time` datetime default null,
- `status` int default null,
- `description` varchar(800) default null,
- primary key (`role_id`),
- key `idx_admin_role_code` (`code`),
- key `idx_admin_role_app_id` (`app_id`)
-) ;
-
-
-create table `ll_system_3_2_1` (
- `dept_id` bigint not null,
- `organ_id` varchar(50) default null,
- `parent_id` bigint default null,
- `app_id` varchar(50) default null,
- `depttype_id` bigint default null,
- `foreign_id` varchar(50) default null,
- `create_type` int default '1',
- `type` varchar(20) default null,
- `name` varchar(200) default null,
- `sname` varchar(50) default null,
- `area_code` varchar(50) default null,
- `organ_leader` varchar(50) default null,
- `leader_id` varchar(50) default null,
- `leader_mobile` varchar(50) default null,
- `is_organ_level` tinyint(1) default '1',
- `is_virtual` tinyint(1) default '0',
- `is_leaf` tinyint(1) default '0',
- `is_disabled` tinyint(1) not null default '0',
- `search_code` varchar(800) default null,
- `image_path` varchar(255) default null,
- `priority` int not null default '10',
- `status` int default null,
- `creator_id` varchar(50) default null,
- `create_time` datetime default null,
- `last_time` datetime default null,
- `del_flag` int default null,
- `description` varchar(800) default null,
- `spare1` varchar(255) default null,
- `spare2` varchar(255) default null,
- primary key (`dept_id`),
- key `idx_admin_dept_parent_id` (`parent_id`)
-) ;
-
-
-create table `ll_system_3_2_5` (
- `admin_id` bigint not null,
- `user_id` varchar(50) default null,
- `organ_id` varchar(50) default null,
- `dept_id` bigint default null,
- `create_type` int default '1',
- `name` varchar(200) default null,
- `username` varchar(100) default null,
- `mobile` varchar(50) default null,
- `email` varchar(200) default null,
- `password` varchar(200) default null,
- `salt` varchar(200) default null,
- `image_path` varchar(255) default null,
- `admin_type` varchar(20) default null,
- `is_super_admin` tinyint(1) not null default '0',
- `is_audit_admin` tinyint(1) not null default '0',
- `is_self_admin` tinyint(1) not null default '0',
- `admin_range` varchar(800) default null,
- `admin_perms` varchar(4000) default null,
- `last_app_id` varchar(50) default null,
- `last_login_time` datetime default null,
- `last_login_ip` varchar(50) default '127.0.0.1',
- `login_count` int not null default '0',
- `status` int not null default '1',
- `creator_id` varchar(50) default null,
- `create_time` datetime default null,
- `last_time` timestamp null default null,
- `del_flag` int default '0',
- `spare1` varchar(800) default null,
- `spare2` varchar(255) default null,
- primary key (`admin_id`),
- key `idx_admin_user_su_id` (`user_id`)
-) ;
-
-
-insert into `ll_system_3_2_5`(`admin_id`,`user_id`,`organ_id`,`dept_id`,`create_type`,`name`,`username`,`mobile`,`email`,`password`,`salt`,`image_path`,`admin_type`,`is_super_admin`,`is_audit_admin`,`is_self_admin`,`admin_range`,`admin_perms`,`last_app_id`,`last_login_time`,`last_login_ip`,`login_count`,`status`,`creator_id`,`create_time`,`last_time`,`del_flag`,`spare1`,`spare2`) values
- (1,null,'c4bdcd3051314867b827201c4018083c',103,0,'管理员','datadmin','1588888888','wd@qq.com','$2a$10$7jb720yubvszvui0reqk/.vqgozth.ulu33dhoibe8byohjirdau2',null,'',null,0,0,0,null,null,null,'2025-02-14 14:46:17','127.0.0.1',0,1,'datadmin','2024-11-04 00:19:29','2025-02-14 14:46:17',0,'管理员',null);
-
-
-create table `ll_system_3_2_7` (
- `userrole_id` bigint not null auto_increment,
- `role_id` bigint not null,
- `admin_id` bigint default null,
- primary key (`userrole_id`)
-) ;
-
-create table `ll_system_3_2_8` (
- `log_id` bigint not null,
- `admin_id` bigint default null,
- `user_id` varchar(50) default null,
- `app_id` varchar(50) default null,
- `category` int default null,
- `title` varchar(200) default null,
- `content` varchar(255) default null,
- `src_code` int default null,
- `log_time` datetime default null,
- `log_ip` varchar(50) default null,
- `log_url` varchar(255) default null,
- `log_browse` varchar(255) default null,
- `log_os` varchar(255) default null,
- `status` varchar(20) default null,
- `description` varchar(800) default null,
- primary key (`log_id`),
- key `idx_admin_login_log_a_id` (`admin_id`),
- key `idx_admin_login_log_l_time` (`log_time`)
-) ;
-
-
-insert into `ll_system_3_2_8`(`log_id`,`admin_id`,`user_id`,`app_id`,`category`,`title`,`content`,`src_code`,`log_time`,`log_ip`,`log_url`,`log_browse`,`log_os`,`status`,`description`) values
- (5234261636373760,1,'datadmin','pa-stage-ent',1,'登录成功','ip:[127.0.0.1]address:[内网ip]username:[datadmin]status:[success]message:[登录成功]',null,'2025-02-14 14:46:17','127.0.0.1','/stage_magic/login','chrome 13','windows 10','0',null);
-
-
-create table `magic_api_file_v2` (
- `file_path` varchar(512) not null,
- `file_content` mediumtext,
- primary key (`file_path`)
-) engine=innodb default charset=utf8mb4
+CREATE TABLE `MAGIC_API_FILE_V2` (
+ `FILE_PATH` VARCHAR(512) NOT NULL,
+ `FILE_CONTENT` MEDIUMTEXT,
+ PRIMARY KEY (`FILE_PATH`)
+)
;
-create table `magic_backup_record_v2` (
- `id` varchar(32) not null comment '原对象id',
- `create_date` bigint(13) not null comment '备份时间',
- `tag` varchar(32) default null comment '标签',
- `type` varchar(32) default null comment '类型',
- `name` varchar(64) default null comment '原名称',
- `content` blob comment '备份内容',
- `create_by` varchar(64) default null comment '操作人',
- primary key (`id`,`create_date`)
-) engine=innodb default charset=utf8mb4
+CREATE TABLE `MAGIC_BACKUP_RECORD_V2` (
+ `ID` VARCHAR(32) NOT NULL COMMENT '原对象ID',
+ `CREATE_DATE` BIGINT(13) NOT NULL COMMENT '备份时间',
+ `TAG` VARCHAR(32) DEFAULT NULL COMMENT '标签',
+ `TYPE` VARCHAR(32) DEFAULT NULL COMMENT '类型',
+ `NAME` VARCHAR(64) DEFAULT NULL COMMENT '原名称',
+ `CONTENT` BLOB COMMENT '备份内容',
+ `CREATE_BY` VARCHAR(64) DEFAULT NULL COMMENT '操作人',
+ PRIMARY KEY (`ID`,`CREATE_DATE`)
+)
;
\ No newline at end of file
diff --git a/src/main/java/net/linlan/MagicApiApplication.java b/src/main/java/net/linlan/MagicApiApplication.java
index 0a342b4dd032c38a6e30334cbc3850b38daf3890..76f62b4197afe9a6b0fa840ef3591f9a63f5620c 100644
--- a/src/main/java/net/linlan/MagicApiApplication.java
+++ b/src/main/java/net/linlan/MagicApiApplication.java
@@ -1,7 +1,22 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan;
-import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
-import net.linlan.config.DynamicDataSourceConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -14,24 +29,24 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
-//import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
-@Import({DynamicDataSourceConfig.class})
-@EnableAutoConfiguration(exclude = {
- DataSourceAutoConfiguration.class
-})
+import net.linlan.config.DynamicDataSourceConfig;
+
+//import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Import({ DynamicDataSourceConfig.class })
+@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })
@Configuration
-@MapperScan(basePackages={"net.linlan.**.dao"})
-@ComponentScan(basePackages = {"net.linlan"})
+@MapperScan(basePackages = { "net.linlan.**.dao" })
+@ComponentScan(basePackages = { "net.linlan" })
@EnableScheduling
@EnableAsync
@ServletComponentScan
-@EnableEncryptableProperties//@EnableSwagger2 // 配置swagger 文档
-public class MagicApiApplication extends SpringBootServletInitializer
-{
- public static void main(String[] args)
- {
+@EnableEncryptableProperties //@EnableSwagger2 // 配置swagger 文档
+public class MagicApiApplication extends SpringBootServletInitializer {
+ public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(MagicApiApplication.class, args);
System.out.println("------- 接口管理平台启动成功 -------");
@@ -43,4 +58,3 @@ public class MagicApiApplication extends SpringBootServletInitializer
}
}
-
diff --git a/src/main/java/net/linlan/config/CaptchaConfig.java b/src/main/java/net/linlan/config/CaptchaConfig.java
index ff76bc78941a1e7a3846a20f0b3355dce40caf92..5961d527f50fb281e56d6efc3573cf2b50895fa7 100644
--- a/src/main/java/net/linlan/config/CaptchaConfig.java
+++ b/src/main/java/net/linlan/config/CaptchaConfig.java
@@ -1,12 +1,29 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
-import com.google.code.kaptcha.impl.DefaultKaptcha;
-import com.google.code.kaptcha.util.Config;
+import java.util.Properties;
+
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import java.util.Properties;
-
+import com.google.code.kaptcha.impl.DefaultKaptcha;
+import com.google.code.kaptcha.util.Config;
import static com.google.code.kaptcha.Constants.*;
/**
@@ -15,11 +32,9 @@ import static com.google.code.kaptcha.Constants.*;
* @author Linlan
*/
@Configuration
-public class CaptchaConfig
-{
+public class CaptchaConfig {
@Bean(name = "captchaProducer")
- public DefaultKaptcha getKaptchaBean()
- {
+ public DefaultKaptcha getKaptchaBean() {
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yes,no
@@ -39,15 +54,15 @@ public class CaptchaConfig
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
- properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
+ properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL,
+ "com.google.code.kaptcha.impl.ShadowGimpy");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
@Bean(name = "captchaProducerMath")
- public DefaultKaptcha getKaptchaBeanMath()
- {
+ public DefaultKaptcha getKaptchaBeanMath() {
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yes,no
@@ -65,7 +80,8 @@ public class CaptchaConfig
// KAPTCHA_SESSION_KEY
properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCodeMath");
// 验证码文本生成器
- properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "net.linlan.webconfig.KaptchaTextCreator");
+ properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL,
+ "net.linlan.webconfig.KaptchaTextCreator");
// 验证码文本字符间距 默认为2
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "3");
// 验证码文本字符长度 默认为5
@@ -77,7 +93,8 @@ public class CaptchaConfig
// 干扰实现类
properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise");
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
- properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
+ properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL,
+ "com.google.code.kaptcha.impl.ShadowGimpy");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
diff --git a/src/main/java/net/linlan/config/CorsConfig.java b/src/main/java/net/linlan/config/CorsConfig.java
index 3a9ed0f499faf183c1676e67a43caf0c97a6e759..9badacf0b48acc42a4eaf76be7e6d67c93bf21ae 100644
--- a/src/main/java/net/linlan/config/CorsConfig.java
+++ b/src/main/java/net/linlan/config/CorsConfig.java
@@ -1,3 +1,20 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
import org.springframework.beans.factory.annotation.Value;
@@ -25,24 +42,24 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
public class CorsConfig implements WebMvcConfigurer {
@Value("${spring.profiles.active}")
- private String activeMode;
+ private String activeMode;
@Value("${platform.prop.allowedOrigins}")
private String[] allowedOrigins;
/**
* 跨域配置
+ * @return 跨域配置过滤器
*/
@Bean
- public CorsFilter corsFilter()
- {
+ public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
// 可信域配置
- if (allowedOrigins != null && allowedOrigins.length > 0){
+ if (allowedOrigins != null && allowedOrigins.length > 0) {
for (String allowedOrigin : allowedOrigins) {
config.addAllowedOriginPattern(allowedOrigin);
}
- }else{
+ } else {
// 设置访问源地址
config.addAllowedOriginPattern("*");
}
@@ -61,17 +78,15 @@ public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
- String[] origins = {"*"};
+ String[] origins = { "*" };
if (activeMode.contains("prod")
-// || activeMode.contains("test") //开发调试下,注释,生产发布开启
- ){
+ // || activeMode.contains("test") //开发调试下,注释,生产发布开启
+ ) {
origins = allowedOrigins;
}
registry.addMapping("/**")
-// .allowedOrigins(origins)
- .allowedOriginPatterns(origins)
- .allowCredentials(true)
- .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
- .maxAge(3600);
+ // .allowedOrigins(origins)
+ .allowedOriginPatterns(origins).allowCredentials(true)
+ .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS").maxAge(3600);
}
}
diff --git a/src/main/java/net/linlan/config/DataSourceNames.java b/src/main/java/net/linlan/config/DataSourceNames.java
index fb0604598421b1f963f607888dc023d8b42ca878..6ae0d0d652ac9d554419619e79bfc2a39ad852b8 100644
--- a/src/main/java/net/linlan/config/DataSourceNames.java
+++ b/src/main/java/net/linlan/config/DataSourceNames.java
@@ -1,6 +1,23 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
-import net.linlan.plat.comm.datasource.BaseDataSourceNames;
+import net.linlan.frame.comm.datasource.BaseDataSourceNames;
/**
*
@@ -19,4 +36,9 @@ import net.linlan.plat.comm.datasource.BaseDataSourceNames;
*/
public class DataSourceNames implements BaseDataSourceNames {
+ /**
+ * 第三个数据源
+ */
+ public static final String THIRD = "third";
+
}
diff --git a/src/main/java/net/linlan/config/DynamicDataSource.java b/src/main/java/net/linlan/config/DynamicDataSource.java
index 4f361b1a623febfb4e412d6fe99dcb1f605e3b1b..ada3d4f094aca87dfa2bb3ec84ed3cc89097e7f6 100644
--- a/src/main/java/net/linlan/config/DynamicDataSource.java
+++ b/src/main/java/net/linlan/config/DynamicDataSource.java
@@ -1,13 +1,31 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
-import javax.sql.DataSource;
-import java.util.HashMap;
-import java.util.Map;
-
/**
*
* Filename:DynamicDataSource.java
@@ -22,14 +40,16 @@ import java.util.Map;
*/
public class DynamicDataSource extends AbstractRoutingDataSource {
- static Logger logger = LoggerFactory.getLogger(DynamicDataSource.class);
+ static Logger logger = LoggerFactory
+ .getLogger(DynamicDataSource.class);
/**
* 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本,
* 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。
*/
private static final ThreadLocal contextHolder = new ThreadLocal<>();
- public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) {
+ public DynamicDataSource(DataSource defaultTargetDataSource,
+ Map targetDataSources) {
super.setDefaultTargetDataSource(defaultTargetDataSource);
super.setTargetDataSources(new HashMap<>(targetDataSources));
super.afterPropertiesSet();
@@ -39,6 +59,7 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
protected Object determineCurrentLookupKey() {
return getDataSource();
}
+
/**
* 设置数据源的变量
* @param dataSource 数据源
@@ -47,6 +68,7 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
logger.info("切换到{}数据源", dataSource);
contextHolder.set(dataSource);
}
+
/**
* 获得数据源的变量
* @return 数据源连接变量
@@ -54,6 +76,7 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
public static String getDataSource() {
return contextHolder.get();
}
+
/**
* 清空数据源变量
*/
diff --git a/src/main/java/net/linlan/config/DynamicDataSourceConfig.java b/src/main/java/net/linlan/config/DynamicDataSourceConfig.java
index 15e8aaddf1bc6bf2c4fc53a94876cee3e69c0a0d..9100f65978ac3e169879e4c5204b2b661de933f7 100644
--- a/src/main/java/net/linlan/config/DynamicDataSourceConfig.java
+++ b/src/main/java/net/linlan/config/DynamicDataSourceConfig.java
@@ -1,17 +1,36 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
-import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
+import java.util.Properties;
+
+import javax.sql.DataSource;
+
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
+import org.ssssssss.magicapi.datasource.model.MagicDynamicDataSource;
-import javax.sql.DataSource;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
/**
*
@@ -28,27 +47,47 @@ import java.util.Properties;
@Configuration
public class DynamicDataSourceConfig {
- @Bean
+ @Primary //标记主数据源,当存在多个DataSource Bean时,默认使用该数据源
+ @Bean(name = "db1") //创建一个名为"d1"的DataSource Bean
+ @Qualifier("db1")
@ConfigurationProperties("spring.datasource.druid.first")
- public DataSource firstDataSource(){
+ public DataSource firstDataSource() {
return DruidDataSourceBuilder.create().build();
}
- @Bean
+ @Bean(name = "db2")
+ @Qualifier("db2")
@ConfigurationProperties("spring.datasource.druid.second")
- public DataSource secondDataSource(){
+ public DataSource secondDataSource() {
return DruidDataSourceBuilder.create().build();
}
+ // @Bean
+ // @ConfigurationProperties("spring.datasource.druid.third")
+ // public DataSource thirdDataSource(){
+ // return DruidDataSourceBuilder.create().build();
+ // }
+
+ // @Bean
+ // @Primary
+ // public DynamicDataSource dataSource(DataSource firstDataSource,
+ // DataSource secondDataSource
+ // ) {
+ // Map targetDataSources = new HashMap<>();
+ // targetDataSources.put(DataSourceNames.FIRST, firstDataSource);
+ // targetDataSources.put(DataSourceNames.SECOND, secondDataSource);
+ // targetDataSources.put(DataSourceNames.THIRD, thirdDataSource());
+ // return new DynamicDataSource(firstDataSource, targetDataSources);
+ // }
+
+ // 创建一个MagicDynamicDataSource类型的Bean,用于管理多个数据源并实现动态切换
@Bean
- @Primary
- public DynamicDataSource dataSource(DataSource firstDataSource,
- DataSource secondDataSource
- ) {
- Map targetDataSources = new HashMap<>();
- targetDataSources.put(DataSourceNames.FIRST, firstDataSource);
- targetDataSources.put(DataSourceNames.SECOND, secondDataSource);
- return new DynamicDataSource(firstDataSource, targetDataSources);
+ public MagicDynamicDataSource magicDynamicDataSource() {
+ MagicDynamicDataSource dynamicDataSource = new MagicDynamicDataSource();
+ // 将默认数据源设置为d1,并将d2的DataSource加入到动态数据源管理器中
+ dynamicDataSource.setDefault(firstDataSource());
+ dynamicDataSource.add("db2", secondDataSource());
+ return dynamicDataSource;
}
/**
@@ -58,13 +97,14 @@ public class DynamicDataSourceConfig {
* @return 数据库提供者
*/
@Bean
- public DatabaseIdProvider getDatabaseIdProvider(){
+ public DatabaseIdProvider getDatabaseIdProvider() {
DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
Properties properties = new Properties();
- properties.setProperty("Oracle","oracle");
- properties.setProperty("MySQL","mysql");
- properties.setProperty("DM8","dm8");
+ properties.setProperty("Oracle", "oracle");
+ properties.setProperty("MySQL", "mysql");
+ properties.setProperty("DM8", "dm8");
databaseIdProvider.setProperties(properties);
return databaseIdProvider;
}
+
}
diff --git a/src/main/java/net/linlan/config/FastJson2JsonRedisSerializer.java b/src/main/java/net/linlan/config/FastJson2JsonRedisSerializer.java
index af8ab8a75a724d3cdbba51128e0915490c42ebe4..64784ddeaaeab70d8c0d5bf7f571dde557e01de3 100644
--- a/src/main/java/net/linlan/config/FastJson2JsonRedisSerializer.java
+++ b/src/main/java/net/linlan/config/FastJson2JsonRedisSerializer.java
@@ -1,14 +1,31 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
+import java.nio.charset.Charset;
+
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.filter.Filter;
-import org.springframework.data.redis.serializer.RedisSerializer;
-import org.springframework.data.redis.serializer.SerializationException;
-
-import java.nio.charset.Charset;
-
import static net.linlan.utils.constant.Constants.JSON_WHITELIST_STR;
/**
@@ -16,35 +33,29 @@ import static net.linlan.utils.constant.Constants.JSON_WHITELIST_STR;
*
* @author shuxiaobo
*/
-public class FastJson2JsonRedisSerializer implements RedisSerializer
-{
- public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+public class FastJson2JsonRedisSerializer implements RedisSerializer {
+ public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
- static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(JSON_WHITELIST_STR);
+ static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(JSON_WHITELIST_STR);
- private Class clazz;
+ private Class clazz;
- public FastJson2JsonRedisSerializer(Class clazz)
- {
+ public FastJson2JsonRedisSerializer(Class clazz) {
super();
this.clazz = clazz;
}
@Override
- public byte[] serialize(T t) throws SerializationException
- {
- if (t == null)
- {
+ public byte[] serialize(T t) throws SerializationException {
+ if (t == null) {
return new byte[0];
}
return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
}
@Override
- public T deserialize(byte[] bytes) throws SerializationException
- {
- if (bytes == null || bytes.length <= 0)
- {
+ public T deserialize(byte[] bytes) throws SerializationException {
+ if (bytes == null || bytes.length <= 0) {
return null;
}
String str = new String(bytes, DEFAULT_CHARSET);
diff --git a/src/main/java/net/linlan/config/FilterConfig.java b/src/main/java/net/linlan/config/FilterConfig.java
index fc6aa41a9ab7b6beb9e9f8383ef47451d81a640a..3f2e34f93ac7bcaa7d0acf479d2fcdcdaf0ce02e 100644
--- a/src/main/java/net/linlan/config/FilterConfig.java
+++ b/src/main/java/net/linlan/config/FilterConfig.java
@@ -1,17 +1,35 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
-import net.linlan.commons.core.StringUtils;
-import net.linlan.stage.handler.RepeatFilter;
-import net.linlan.utils.xss.XssFilter;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.DispatcherType;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import javax.servlet.DispatcherType;
-import java.util.HashMap;
-import java.util.Map;
+import net.linlan.commons.core.StringUtils;
+import net.linlan.utils.xss.XssFilter;
/**
* Filter配置
@@ -19,8 +37,7 @@ import java.util.Map;
* @author Linlan
*/
@Configuration
-public class FilterConfig
-{
+public class FilterConfig {
@Value("${platform.xss.excludes}")
private String excludes;
@@ -30,8 +47,7 @@ public class FilterConfig
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
@ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
- public FilterRegistrationBean xssFilterRegistration()
- {
+ public FilterRegistrationBean xssFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST);
registration.setFilter(new XssFilter());
@@ -44,16 +60,4 @@ public class FilterConfig
return registration;
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Bean
- public FilterRegistrationBean repeatFilterRegistration()
- {
- FilterRegistrationBean registration = new FilterRegistrationBean();
- registration.setFilter(new RepeatFilter());
- registration.addUrlPatterns("/api/*");
- registration.setName("repeatFilter");
- registration.setOrder(FilterRegistrationBean.LOWEST_PRECEDENCE);
- return registration;
- }
-
}
diff --git a/src/main/java/net/linlan/config/HttpClientConfig.java b/src/main/java/net/linlan/config/HttpClientConfig.java
index 26477fd44f40c840aa298db0b8796e55952f892e..20984fc2f9143b46c789627d28121d570337eca5 100644
--- a/src/main/java/net/linlan/config/HttpClientConfig.java
+++ b/src/main/java/net/linlan/config/HttpClientConfig.java
@@ -1,3 +1,20 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
import org.apache.http.client.config.RequestConfig;
@@ -43,7 +60,7 @@ public class HttpClientConfig {
* @return 连接池
*/
@Bean(name = "httpClientConnectionManager")
- public PoolingHttpClientConnectionManager getHttpClientConnectionManager(){
+ public PoolingHttpClientConnectionManager getHttpClientConnectionManager() {
PoolingHttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager();
//最大连接数
httpClientConnectionManager.setMaxTotal(maxTotal);
@@ -59,7 +76,7 @@ public class HttpClientConfig {
* @return 实例化连接池
*/
@Bean(name = "httpClientBuilder")
- public HttpClientBuilder getHttpClientBuilder(@Qualifier("httpClientConnectionManager")PoolingHttpClientConnectionManager httpClientConnectionManager){
+ public HttpClientBuilder getHttpClientBuilder(@Qualifier("httpClientConnectionManager") PoolingHttpClientConnectionManager httpClientConnectionManager) {
//HttpClientBuilder中的构造方法被protected修饰,所以这里不能直接使用new来实例化一个HttpClientBuilder,可以使用HttpClientBuilder提供的静态方法create()来获取HttpClientBuilder对象
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
@@ -75,7 +92,7 @@ public class HttpClientConfig {
* @return 注入连接池
*/
@Bean
- public CloseableHttpClient getCloseableHttpClient(@Qualifier("httpClientBuilder") HttpClientBuilder httpClientBuilder){
+ public CloseableHttpClient getCloseableHttpClient(@Qualifier("httpClientBuilder") HttpClientBuilder httpClientBuilder) {
return httpClientBuilder.build();
}
@@ -87,11 +104,10 @@ public class HttpClientConfig {
* @return Builder对象
*/
@Bean(name = "builder")
- public RequestConfig.Builder getBuilder(){
+ public RequestConfig.Builder getBuilder() {
RequestConfig.Builder builder = RequestConfig.custom();
return builder.setConnectTimeout(connectTimeout)
- .setConnectionRequestTimeout(connectionRequestTimeout)
- .setSocketTimeout(socketTimeout);
+ .setConnectionRequestTimeout(connectionRequestTimeout).setSocketTimeout(socketTimeout);
}
/**
@@ -100,7 +116,7 @@ public class HttpClientConfig {
* @return 构建RequestConfig对象
*/
@Bean
- public RequestConfig getRequestConfig(@Qualifier("builder") RequestConfig.Builder builder){
+ public RequestConfig getRequestConfig(@Qualifier("builder") RequestConfig.Builder builder) {
return builder.build();
}
diff --git a/src/main/java/net/linlan/config/I18nConfig.java b/src/main/java/net/linlan/config/I18nConfig.java
index 401bfca2517e2fa4bc83f11eb30212c5a923c4c6..f1957c992564da15a460e543b9f8857cf3067aa7 100644
--- a/src/main/java/net/linlan/config/I18nConfig.java
+++ b/src/main/java/net/linlan/config/I18nConfig.java
@@ -1,5 +1,24 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
+import java.util.Locale;
+
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
@@ -8,19 +27,15 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
-import java.util.Locale;
-
/**
* 资源文件配置加载
*
* @author Linlan
*/
@Configuration
-public class I18nConfig implements WebMvcConfigurer
-{
+public class I18nConfig implements WebMvcConfigurer {
@Bean
- public LocaleResolver localeResolver()
- {
+ public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
// 默认语言
slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
@@ -28,8 +43,7 @@ public class I18nConfig implements WebMvcConfigurer
}
@Bean
- public LocaleChangeInterceptor localeChangeInterceptor()
- {
+ public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
// 参数名
lci.setParamName("lang");
@@ -37,8 +51,7 @@ public class I18nConfig implements WebMvcConfigurer
}
@Override
- public void addInterceptors(InterceptorRegistry registry)
- {
+ public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
}
diff --git a/src/main/java/net/linlan/config/RedisConfig.java b/src/main/java/net/linlan/config/RedisConfig.java
index 2e0e3ed2b3cef838a05f5d2a7852cdcc4391303a..b74a5f438d354447653ac6e5e87caf6419afb053 100644
--- a/src/main/java/net/linlan/config/RedisConfig.java
+++ b/src/main/java/net/linlan/config/RedisConfig.java
@@ -1,68 +1,281 @@
+/*
+ * java-magic-api - 基于Magic-api的工程,用于数据接口配置项目,可通过配置SQL、mybatis方式实现api输出,支持配置promQL编写Prometheus脚本,实现监控流数据和即时状态查询机展示
+ * Copyright © 2020-2025 Linlan (open@linlan.net)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
package net.linlan.config;
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.interceptor.CacheErrorHandler;
+import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.StringRedisTemplate;
-import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
+import org.springframework.util.Assert;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONFactory;
+
+import lombok.extern.slf4j.Slf4j;
+import net.linlan.commons.core.StringUtils;
+import static com.alibaba.fastjson2.JSONWriter.Feature.WriteClassName;
/**
- *
- * Filename:RedisConfig.java
- * Desc:Redis配置
+ * redis配置
*
* @author Linlan
- * CreateTime:2017-07-70 19:22
- *
- * @version 1.0
- * @since 1.0
- *
*/
+@Slf4j
@Configuration
-public class RedisConfig {
+@EnableCaching
+@ConditionalOnClass(RedisOperations.class)
+@EnableConfigurationProperties(RedisProperties.class)
+public class RedisConfig extends CachingConfigurerSupport {
+
+ @Value("${platform.cache.prefix:eframe}")
+ private String prefix;
+
+ @Bean
+ public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
+ //序列化
+ RedisSerializer redisSerializer = new StringRedisSerializer(String.class, prefix);
+ FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer<>(
+ Object.class);
+ //redis缓存配置
+ RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration
+ .defaultCacheConfig()
+ // 默认redis cache 缓存时间1天
+ .entryTtl(Duration.ofDays(1))
+ .serializeKeysWith(
+ RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
+ .serializeValuesWith(RedisSerializationContext.SerializationPair
+ .fromSerializer(fastJsonRedisSerializer));
+
+ RedisCacheManager redisCacheManager = RedisCacheManager.builder(redisConnectionFactory)
+ .cacheDefaults(redisCacheConfiguration).build();
+ return redisCacheManager;
+ }
- /** 对REDISTEMPLATE的键进行标准化处理
- * RedisTemplate配置
- * @param factory 缓存工厂
- * @return redis 模板
+ /**
+ * 设置 redis 数据默认过期时间,默认2小时
+ * 设置@cacheable 序列化方式
+ * @return redis配置工厂
*/
@Bean
- public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
- StringRedisTemplate template = new StringRedisTemplate(factory);
- //定义key序列化方式
- RedisSerializer redisSerializer = new StringRedisSerializer();
- //定义value的序列化方式
- Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
- ObjectMapper om = new ObjectMapper();
- om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
- om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
- jackson2JsonRedisSerializer.setObjectMapper(om);
-
- template.setKeySerializer(redisSerializer);
- template.setValueSerializer(jackson2JsonRedisSerializer);
- template.setHashValueSerializer(jackson2JsonRedisSerializer);
- template.afterPropertiesSet();
+ public RedisCacheConfiguration redisCacheConfiguration() {
+ FastJsonRedisSerializer