mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-17 19:06:39 +08:00
Compare commits
91 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
63ef235b95 | ||
|
3ceea05ba1 | ||
|
9fda0a7bd6 | ||
|
9361097097 | ||
|
942c628cc6 | ||
|
521b98746f | ||
|
4229ec80b0 | ||
|
4582656e27 | ||
|
fff0120058 | ||
|
b8f2200af6 | ||
|
0a56497b51 | ||
|
2eb3742063 | ||
|
74aa2da89b | ||
|
3dcad0b78a | ||
|
6ba6b18849 | ||
|
d2c55e35ff | ||
|
8135e0ec10 | ||
|
2a545117fa | ||
|
d8baf9dba7 | ||
|
2f8a0b6153 | ||
|
a97afd4683 | ||
|
075e7ad134 | ||
|
acecebf4b3 | ||
|
73cd7f196c | ||
|
d3ef935859 | ||
|
97df843072 | ||
|
12bd821770 | ||
|
2b6ead23bd | ||
|
b2aa70ce9e | ||
|
143a500c44 | ||
|
8302ba4c2c | ||
|
7ae4e898ad | ||
|
245f8c7856 | ||
|
43a9f53c0a | ||
|
551c9c9086 | ||
|
28d188251b | ||
|
87210fad28 | ||
|
4f0296ce23 | ||
|
563b20206b | ||
|
c1373ed21d | ||
|
8f6852673a | ||
|
336bdc4895 | ||
|
922e49b27e | ||
|
3adb7376dd | ||
|
40880b87c1 | ||
|
a260368d0c | ||
|
e7d29c68ae | ||
|
c0dea0c3c6 | ||
|
4d2be37e0e | ||
|
d5abf42014 | ||
|
8d2d8f2846 | ||
|
0e06f36787 | ||
|
012096a3ee | ||
|
3fb4dfad09 | ||
|
f198a949c9 | ||
|
41fad5b831 | ||
|
696db3835a | ||
|
40edf452ac | ||
|
c93616bec2 | ||
|
61c49b5798 | ||
|
54ad0e5893 | ||
|
fa5b5c7def | ||
|
57270a7130 | ||
|
6c4cf9cc34 | ||
|
c49c1bbbfe | ||
|
47d41f0379 | ||
|
3c3e3b4e32 | ||
|
7bad13fc23 | ||
|
51caeb1ad1 | ||
|
f127f02c96 | ||
|
6583f5f90d | ||
|
d6a53f03b7 | ||
|
caf8e3aa25 | ||
|
97cfdf1f57 | ||
|
8bb9f173eb | ||
|
7ea97f8433 | ||
|
e7927bb948 | ||
|
79fc04d8cb | ||
|
393cb325c7 | ||
|
33c93ae365 | ||
|
3c2c3cf81b | ||
|
ec8fb1d69d | ||
|
d4f1806491 | ||
|
ce0551696a | ||
|
1abe2ee05e | ||
|
486aa13cfd | ||
|
ade82f8aa2 | ||
|
66aac47a43 | ||
|
23c4889723 | ||
|
4062d5a4bb | ||
|
5136148ce1 |
11
README.md
11
README.md
@ -4,16 +4,19 @@
|
|||||||
|
|
||||||
**<font color="#DC143C">国内首个满足《网络安全-三级等保》、《数据安全》</font>** 功能要求,支持登录限制、接口国产加解密、数据脱敏等一系列安全要求。
|
**<font color="#DC143C">国内首个满足《网络安全-三级等保》、《数据安全》</font>** 功能要求,支持登录限制、接口国产加解密、数据脱敏等一系列安全要求。
|
||||||
|
|
||||||
前端提供 **<font color="#DC143C">JavaScript和TypeScript双版本</font>**,后端提供 **<font color="#DC143C">Java8+SpringBoot2.X和Java17+SpringBoot3.X 双版本</font>**。
|
**<font color="#DC143C">支持国产数据库:【达梦、金仓、南大通用、OceanBase、GaussDB 高斯、阿里PolarDB、GoldenDB】等,主流数据库:【Mysql, PostgreSQL】等</font>**
|
||||||
|
|
||||||
|
**<font color="#DC143C">前端提供JavaScript和TypeScript双版本,后端提供Java8+SpringBoot2.X和Java17+SpringBoot3.X 双版本</font>**。
|
||||||
|
|
||||||
同时 **<font color="#DC143C">重磅开源</font>** 开源六年来 **<font color="#DC143C">千余家企业验证过且正在使用</font>** 的代码规范: **<font color="#DC143C">《高质量代码思想》、《Vue3规范》、《Java规范》</font>** ,让大家在这浮躁的世界里感受到一股把代码写好的清流!同时又能节省大量时间,减少加班,快乐工作,保持谦逊,保持学习,**<font color="#DC143C">热爱代码,更热爱生活</font>** !
|
同时 **<font color="#DC143C">重磅开源</font>** 开源六年来 **<font color="#DC143C">千余家企业验证过且正在使用</font>** 的代码规范: **<font color="#DC143C">《高质量代码思想》、《Vue3规范》、《Java规范》</font>** ,让大家在这浮躁的世界里感受到一股把代码写好的清流!同时又能节省大量时间,减少加班,快乐工作,保持谦逊,保持学习,**<font color="#DC143C">热爱代码,更热爱生活</font>** !
|
||||||
### **技术体系**
|
### **技术体系**
|
||||||
|
|
||||||
- 前端:JavaScript/TypeScript + Vue3 + Vite5 + Pinia + Ant Design Vue 4.X
|
- 前端:JavaScript/TypeScript + Vue3 + Vite5 + Pinia + Ant Design Vue 4.X
|
||||||
- 移动端:uniapp (vue3版本) + uni-ui + (同时支持APP、小程序、H5)
|
- 移动端:uniapp (vue3版本) + uni-ui + (同时支持APP、小程序、H5)
|
||||||
- 后端:Java8/17 + SpringBoot2/3 + Sa Token + Mybatis-plus + 多种数据库
|
- 后端:Java8/17 + SpringBoot2/3 + Sa Token + Mybatis-plus + 主流数据库/国产数据库
|
||||||
- 官方文档:[http://115.190.111.229/smart-admin/](http://115.190.111.229/smart-admin/)
|
- 官方文档:[https://smartadmin.vip](https://smartadmin.vip)
|
||||||
- 在线预览:[http://115.190.111.229/smart-admin-preview/](http://115.190.111.229/smart-admin-preview/)
|
- 电脑在线预览:[https://preview.smartadmin.vip](https://preview.smartadmin.vip)
|
||||||
|
- 移动端在线预览:[https://app.smartadmin.vip](https://app.smartadmin.vip/#/pages/login/login)
|
||||||
### **理念与思想**
|
### **理念与思想**
|
||||||
|
|
||||||
- 我们分享的不是徒劳无功的各种功能,而是必须有的功能,如:数据变动记录、系统说明文档、版本更新记录、意见反馈、日志、心跳、单号生成器等等。
|
- 我们分享的不是徒劳无功的各种功能,而是必须有的功能,如:数据变动记录、系统说明文档、版本更新记录、意见反馈、日志、心跳、单号生成器等等。
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>net.1024lab</groupId>
|
<groupId>net.lab1024</groupId>
|
||||||
<artifactId>sa-parent</artifactId>
|
<artifactId>sa-parent</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
@ -16,55 +16,49 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<springboot.version>3.3.1</springboot.version>
|
<java.version>17</java.version>
|
||||||
<spring-mock.version>2.0.8</spring-mock.version>
|
<springboot.version>3.5.4</springboot.version>
|
||||||
<spring-security-crypto.version>6.4.3</spring-security-crypto.version>
|
<spring-security-crypto.version>6.5.1</spring-security-crypto.version>
|
||||||
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
<mybatis-plus.version>3.5.12</mybatis-plus.version>
|
||||||
<p6spy.version>3.9.1</p6spy.version>
|
<p6spy.version>3.9.1</p6spy.version>
|
||||||
<knife4j.version>4.4.0</knife4j.version>
|
<springdoc-openapi.version>2.8.9</springdoc-openapi.version>
|
||||||
<fastjson.version>2.0.52</fastjson.version>
|
<knife4j.version>4.6.0</knife4j.version>
|
||||||
<druid.version>1.2.23</druid.version>
|
<fastjson.version>2.0.57</fastjson.version>
|
||||||
|
<druid.version>1.2.25</druid.version>
|
||||||
<google-linkedhashmap.version>1.4.2</google-linkedhashmap.version>
|
<google-linkedhashmap.version>1.4.2</google-linkedhashmap.version>
|
||||||
<google-guava.version>20.0</google-guava.version>
|
<google-guava.version>20.0</google-guava.version>
|
||||||
<user-agent-utils.version>1.21</user-agent-utils.version>
|
<reflections.version>0.10.2</reflections.version>
|
||||||
<reflections.version>0.9.11</reflections.version>
|
<commons-io.version>2.19.0</commons-io.version>
|
||||||
<commons-io.version>2.15.0</commons-io.version>
|
<commons-lang3.version>3.18.0</commons-lang3.version>
|
||||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
<commons-collections4.version>4.5.0</commons-collections4.version>
|
||||||
<commons-collections4.version>4.4</commons-collections4.version>
|
<commons-compress.version>1.27.1</commons-compress.version>
|
||||||
<commons-compress.version>1.26.0</commons-compress.version>
|
<commons-codec.version>1.18.0</commons-codec.version>
|
||||||
<commons-codec.version>1.13</commons-codec.version>
|
<commons-text.version>1.13.1</commons-text.version>
|
||||||
<commons-text.version>1.9</commons-text.version>
|
<fast-excel.version>1.2.0</fast-excel.version>
|
||||||
<xerces.version>2.12.0</xerces.version>
|
<poi.version>5.4.1</poi.version>
|
||||||
<fast-excel.version>1.0.0</fast-excel.version>
|
<awssdk-s3.version>2.31.78</awssdk-s3.version>
|
||||||
<poi.version>5.2.4</poi.version>
|
<mysql-connector-j.version>9.3.0</mysql-connector-j.version>
|
||||||
<ooxml-schemas.version>1.4</ooxml-schemas.version>
|
<hutool.version>5.8.39</hutool.version>
|
||||||
<aws-java-sdk.version>1.11.842</aws-java-sdk.version>
|
<velocity-engine-core.version>2.4.1</velocity-engine-core.version>
|
||||||
<log4j-spring-boot.version>2.23.1</log4j-spring-boot.version>
|
|
||||||
<hutool.version>5.8.29</hutool.version>
|
|
||||||
<velocity-engine-core.version>2.3</velocity-engine-core.version>
|
|
||||||
<jjwt.version>0.9.1</jjwt.version>
|
|
||||||
<jwks-rsa.version>0.9.0</jwks-rsa.version>
|
|
||||||
<velocity-tools.version>3.1</velocity-tools.version>
|
<velocity-tools.version>3.1</velocity-tools.version>
|
||||||
<sa-token.version>1.41.0</sa-token.version>
|
<sa-token.version>1.44.0</sa-token.version>
|
||||||
<ip2region.version>2.7.0</ip2region.version>
|
<ip2region.version>2.7.0</ip2region.version>
|
||||||
<bcprov.version>1.80</bcprov.version>
|
<bcprov.version>1.80</bcprov.version>
|
||||||
<jackson-datatype-jsr310.version>2.13.4</jackson-datatype-jsr310.version>
|
|
||||||
<jackson-dataformat-yaml.version>2.16.1</jackson-dataformat-yaml.version>
|
|
||||||
<smartdb.version>1.2.0</smartdb.version>
|
<smartdb.version>1.2.0</smartdb.version>
|
||||||
<redisson.version>3.25.0</redisson.version>
|
<redisson.version>3.50.0</redisson.version>
|
||||||
<snakeyaml.version>2.2</snakeyaml.version>
|
<snakeyaml.version>2.4</snakeyaml.version>
|
||||||
<freemarker.version>2.3.33</freemarker.version>
|
<freemarker.version>2.3.34</freemarker.version>
|
||||||
<jsoup.version>1.18.1</jsoup.version>
|
<jsoup.version>1.21.1</jsoup.version>
|
||||||
<tika.version>3.1.0</tika.version>
|
<tika.version>3.1.0</tika.version>
|
||||||
|
<httpcomponents.version>5.5</httpcomponents.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!--BOM begin-->
|
<!--SpringBoot BOM begin-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
@ -72,19 +66,16 @@
|
|||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--BOM end-->
|
<!--SpringBoot BOM end-->
|
||||||
|
<!--mybatis-plus BOM begin-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
<artifactId>mybatis-plus-bom</artifactId>
|
||||||
<version>${mybatis-plus.version}</version>
|
<version>${mybatis-plus.version}</version>
|
||||||
<exclusions>
|
<type>pom</type>
|
||||||
<exclusion>
|
<scope>import</scope>
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-logging</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--mybatis-plus BOM end-->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
@ -92,6 +83,12 @@
|
|||||||
<version>${spring-security-crypto.version}</version>
|
<version>${spring-security-crypto.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>${mysql-connector-j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>p6spy</groupId>
|
<groupId>p6spy</groupId>
|
||||||
<artifactId>p6spy</artifactId>
|
<artifactId>p6spy</artifactId>
|
||||||
@ -99,7 +96,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xingfudeshi</groupId>
|
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||||
<version>${knife4j.version}</version>
|
<version>${knife4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -110,7 +107,6 @@
|
|||||||
<version>${fastjson.version}</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||||
@ -129,12 +125,6 @@
|
|||||||
<version>${google-guava.version}</version>
|
<version>${google-guava.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.bitwalker</groupId>
|
|
||||||
<artifactId>UserAgentUtils</artifactId>
|
|
||||||
<version>${user-agent-utils.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.reflections</groupId>
|
<groupId>org.reflections</groupId>
|
||||||
<artifactId>reflections</artifactId>
|
<artifactId>reflections</artifactId>
|
||||||
@ -178,9 +168,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.amazonaws</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>aws-java-sdk-s3</artifactId>
|
<artifactId>s3</artifactId>
|
||||||
<version>${aws-java-sdk.version}</version>
|
<version>${awssdk-s3.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
@ -200,19 +190,6 @@
|
|||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>${hutool.version}</version>
|
<version>${hutool.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
|
||||||
<artifactId>jjwt</artifactId>
|
|
||||||
<version>${jjwt.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.auth0</groupId>
|
|
||||||
<artifactId>jwks-rsa</artifactId>
|
|
||||||
<version>${jwks-rsa.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--velocity begin-->
|
<!--velocity begin-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
@ -239,6 +216,7 @@
|
|||||||
<artifactId>sa-token-redis-jackson</artifactId>
|
<artifactId>sa-token-redis-jackson</artifactId>
|
||||||
<version>${sa-token.version}</version>
|
<version>${sa-token.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- sa-token end -->
|
<!-- sa-token end -->
|
||||||
|
|
||||||
<!--ip 地址-->
|
<!--ip 地址-->
|
||||||
@ -263,6 +241,10 @@
|
|||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -272,12 +254,6 @@
|
|||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
<version>${poi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-scratchpad</artifactId>
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
@ -286,20 +262,8 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>ooxml-schemas</artifactId>
|
<artifactId>poi-ooxml-full</artifactId>
|
||||||
<version>${ooxml-schemas.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
|
||||||
<version>${jackson-datatype-jsr310.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
|
||||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
|
||||||
<version>${jackson-dataformat-yaml.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -313,6 +277,25 @@
|
|||||||
<groupId>org.redisson</groupId>
|
<groupId>org.redisson</groupId>
|
||||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
<version>${redisson.version}</version>
|
<version>${redisson.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-data-32</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>objenesis</artifactId>
|
||||||
|
<groupId>org.objenesis</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-data-27</artifactId>
|
||||||
|
<version>${redisson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -339,6 +322,12 @@
|
|||||||
<version>${tika.version}</version>
|
<version>${tika.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
|
<artifactId>httpclient5</artifactId>
|
||||||
|
<version>${httpcomponents.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.1024lab</groupId>
|
<groupId>net.lab1024</groupId>
|
||||||
<artifactId>sa-parent</artifactId>
|
<artifactId>sa-parent</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.1024lab</groupId>
|
<groupId>net.lab1024</groupId>
|
||||||
<artifactId>sa-base</artifactId>
|
<artifactId>sa-base</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -20,11 +20,6 @@ public class AdminCacheConst extends CacheKeyConst {
|
|||||||
*/
|
*/
|
||||||
public static final String DEPARTMENT_LIST_CACHE = "department_list_cache";
|
public static final String DEPARTMENT_LIST_CACHE = "department_list_cache";
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门map
|
|
||||||
*/
|
|
||||||
public static final String DEPARTMENT_MAP_CACHE = "department_map_cache";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门树
|
* 部门树
|
||||||
*/
|
*/
|
||||||
@ -54,4 +49,20 @@ public class AdminCacheConst extends CacheKeyConst {
|
|||||||
public static final String CATEGORY_TREE = "category_tree_cache";
|
public static final String CATEGORY_TREE = "category_tree_cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录相关
|
||||||
|
*/
|
||||||
|
public static class Login {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求用户信息
|
||||||
|
*/
|
||||||
|
public static final String REQUEST_EMPLOYEE = "login_request_employee";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求用户信息权限
|
||||||
|
*/
|
||||||
|
public static final String USER_PERMISSION = "login_user_permission";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ public class AdminSwaggerTagConst extends SwaggerTagConst {
|
|||||||
|
|
||||||
public static final String SYSTEM_POSITION = "系统-职务管理";
|
public static final String SYSTEM_POSITION = "系统-职务管理";
|
||||||
|
|
||||||
|
public static final String SYSTEM_MESSAGE = "系统-消息";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ public class AdminInterceptor implements HandlerInterceptor {
|
|||||||
Method method = ((HandlerMethod) handler).getMethod();
|
Method method = ((HandlerMethod) handler).getMethod();
|
||||||
NoNeedLogin noNeedLogin = ((HandlerMethod) handler).getMethodAnnotation(NoNeedLogin.class);
|
NoNeedLogin noNeedLogin = ((HandlerMethod) handler).getMethodAnnotation(NoNeedLogin.class);
|
||||||
if (noNeedLogin != null) {
|
if (noNeedLogin != null) {
|
||||||
checkActiveTimeout(requestEmployee);
|
updateActiveTimeout(requestEmployee);
|
||||||
|
SmartRequestUtil.setRequestUser(requestEmployee);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +77,8 @@ public class AdminInterceptor implements HandlerInterceptor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测token 活跃频率
|
// 更新活跃
|
||||||
checkActiveTimeout(requestEmployee);
|
updateActiveTimeout(requestEmployee);
|
||||||
|
|
||||||
|
|
||||||
// --------------- 第三步: 校验 权限 ---------------
|
// --------------- 第三步: 校验 权限 ---------------
|
||||||
@ -122,15 +123,12 @@ public class AdminInterceptor implements HandlerInterceptor {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测:token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结
|
* 更新活跃时间
|
||||||
*/
|
*/
|
||||||
private void checkActiveTimeout(RequestEmployee requestEmployee) {
|
private void updateActiveTimeout(RequestEmployee requestEmployee) {
|
||||||
// 用户不在线,也不用检测
|
|
||||||
if (requestEmployee == null) {
|
if (requestEmployee == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StpUtil.checkActiveTimeout();
|
|
||||||
StpUtil.updateLastActiveToNow();
|
StpUtil.updateLastActiveToNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.lab1024.sa.admin.module.business.goods.domain.vo;
|
package net.lab1024.sa.admin.module.business.goods.domain.vo;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.bank;
|
package net.lab1024.sa.admin.module.business.oa.bank.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
|
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
|
||||||
|
import net.lab1024.sa.admin.module.business.oa.bank.service.BankService;
|
||||||
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankCreateForm;
|
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankCreateForm;
|
||||||
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankQueryForm;
|
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankQueryForm;
|
||||||
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankUpdateForm;
|
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankUpdateForm;
|
||||||
@ -35,24 +37,28 @@ public class BankController {
|
|||||||
|
|
||||||
@Operation(summary = "分页查询银行信息 @author 善逸")
|
@Operation(summary = "分页查询银行信息 @author 善逸")
|
||||||
@PostMapping("/oa/bank/page/query")
|
@PostMapping("/oa/bank/page/query")
|
||||||
|
@SaCheckPermission("oa:bank:query")
|
||||||
public ResponseDTO<PageResult<BankVO>> queryByPage(@RequestBody @Valid BankQueryForm queryForm) {
|
public ResponseDTO<PageResult<BankVO>> queryByPage(@RequestBody @Valid BankQueryForm queryForm) {
|
||||||
return bankService.queryByPage(queryForm);
|
return bankService.queryByPage(queryForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "根据企业ID查询银行信息列表 @author 善逸")
|
@Operation(summary = "根据企业ID查询银行信息列表 @author 善逸")
|
||||||
@GetMapping("/oa/bank/query/list/{enterpriseId}")
|
@GetMapping("/oa/bank/query/list/{enterpriseId}")
|
||||||
|
@SaCheckPermission("oa:bank:query")
|
||||||
public ResponseDTO<List<BankVO>> queryList(@PathVariable Long enterpriseId) {
|
public ResponseDTO<List<BankVO>> queryList(@PathVariable Long enterpriseId) {
|
||||||
return bankService.queryList(enterpriseId);
|
return bankService.queryList(enterpriseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询银行信息详情 @author 善逸")
|
@Operation(summary = "查询银行信息详情 @author 善逸")
|
||||||
@GetMapping("/oa/bank/get/{bankId}")
|
@GetMapping("/oa/bank/get/{bankId}")
|
||||||
|
@SaCheckPermission("oa:bank:query")
|
||||||
public ResponseDTO<BankVO> getDetail(@PathVariable Long bankId) {
|
public ResponseDTO<BankVO> getDetail(@PathVariable Long bankId) {
|
||||||
return bankService.getDetail(bankId);
|
return bankService.getDetail(bankId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "新建银行信息 @author 善逸")
|
@Operation(summary = "新建银行信息 @author 善逸")
|
||||||
@PostMapping("/oa/bank/create")
|
@PostMapping("/oa/bank/create")
|
||||||
|
@SaCheckPermission("oa:bank:add")
|
||||||
public ResponseDTO<String> createBank(@RequestBody @Valid BankCreateForm createVO) {
|
public ResponseDTO<String> createBank(@RequestBody @Valid BankCreateForm createVO) {
|
||||||
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||||
createVO.setCreateUserId(requestUser.getUserId());
|
createVO.setCreateUserId(requestUser.getUserId());
|
||||||
@ -62,12 +68,14 @@ public class BankController {
|
|||||||
|
|
||||||
@Operation(summary = "编辑银行信息 @author 善逸")
|
@Operation(summary = "编辑银行信息 @author 善逸")
|
||||||
@PostMapping("/oa/bank/update")
|
@PostMapping("/oa/bank/update")
|
||||||
|
@SaCheckPermission("oa:bank:update")
|
||||||
public ResponseDTO<String> updateBank(@RequestBody @Valid BankUpdateForm updateVO) {
|
public ResponseDTO<String> updateBank(@RequestBody @Valid BankUpdateForm updateVO) {
|
||||||
return bankService.updateBank(updateVO);
|
return bankService.updateBank(updateVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除银行信息 @author 善逸")
|
@Operation(summary = "删除银行信息 @author 善逸")
|
||||||
@GetMapping("/oa/bank/delete/{bankId}")
|
@GetMapping("/oa/bank/delete/{bankId}")
|
||||||
|
@SaCheckPermission("oa:bank:delete")
|
||||||
public ResponseDTO<String> deleteBank(@PathVariable Long bankId) {
|
public ResponseDTO<String> deleteBank(@PathVariable Long bankId) {
|
||||||
return bankService.deleteBank(bankId);
|
return bankService.deleteBank(bankId);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.bank;
|
package net.lab1024.sa.admin.module.business.oa.bank.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@ -7,7 +7,6 @@ import net.lab1024.sa.admin.module.business.oa.bank.domain.BankQueryForm;
|
|||||||
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankVO;
|
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,8 +1,9 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.bank;
|
package net.lab1024.sa.admin.module.business.oa.bank.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.lab1024.sa.admin.module.business.oa.bank.dao.BankDao;
|
||||||
import net.lab1024.sa.admin.module.business.oa.bank.domain.*;
|
import net.lab1024.sa.admin.module.business.oa.bank.domain.*;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.dao.EnterpriseDao;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.dao.EnterpriseDao;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.entity.EnterpriseEntity;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.entity.EnterpriseEntity;
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.enterprise;
|
package net.lab1024.sa.admin.module.business.oa.enterprise.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -8,6 +8,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
|
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
|
||||||
|
import net.lab1024.sa.admin.module.business.oa.enterprise.service.EnterpriseService;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.form.*;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.form.*;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseEmployeeVO;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseEmployeeVO;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseExcelVO;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseExcelVO;
|
||||||
@ -100,6 +101,7 @@ public class EnterpriseController {
|
|||||||
|
|
||||||
@Operation(summary = "按照类型查询企业 @author 开云")
|
@Operation(summary = "按照类型查询企业 @author 开云")
|
||||||
@GetMapping("/oa/enterprise/query/list")
|
@GetMapping("/oa/enterprise/query/list")
|
||||||
|
@SaCheckPermission("oa:enterprise:query")
|
||||||
public ResponseDTO<List<EnterpriseListVO>> queryList(@RequestParam(value = "type", required = false) Integer type) {
|
public ResponseDTO<List<EnterpriseListVO>> queryList(@RequestParam(value = "type", required = false) Integer type) {
|
||||||
return enterpriseService.queryList(type);
|
return enterpriseService.queryList(type);
|
||||||
}
|
}
|
||||||
@ -114,12 +116,14 @@ public class EnterpriseController {
|
|||||||
|
|
||||||
@Operation(summary = "查询企业全部员工 @author 罗伊")
|
@Operation(summary = "查询企业全部员工 @author 罗伊")
|
||||||
@PostMapping("/oa/enterprise/employee/list")
|
@PostMapping("/oa/enterprise/employee/list")
|
||||||
|
@SaCheckPermission("oa:enterprise:queryEmployee")
|
||||||
public ResponseDTO<List<EnterpriseEmployeeVO>> employeeList(@RequestBody @Valid List<Long> enterpriseIdList) {
|
public ResponseDTO<List<EnterpriseEmployeeVO>> employeeList(@RequestBody @Valid List<Long> enterpriseIdList) {
|
||||||
return ResponseDTO.ok(enterpriseService.employeeList(enterpriseIdList));
|
return ResponseDTO.ok(enterpriseService.employeeList(enterpriseIdList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "分页查询企业员工 @author 卓大")
|
@Operation(summary = "分页查询企业员工 @author 卓大")
|
||||||
@PostMapping("/oa/enterprise/employee/queryPage")
|
@PostMapping("/oa/enterprise/employee/queryPage")
|
||||||
|
@SaCheckPermission("oa:enterprise:queryEmployee")
|
||||||
public ResponseDTO<PageResult<EnterpriseEmployeeVO>> queryPageEmployeeList(@RequestBody @Valid EnterpriseEmployeeQueryForm queryForm) {
|
public ResponseDTO<PageResult<EnterpriseEmployeeVO>> queryPageEmployeeList(@RequestBody @Valid EnterpriseEmployeeQueryForm queryForm) {
|
||||||
return ResponseDTO.ok(enterpriseService.queryPageEmployeeList(queryForm));
|
return ResponseDTO.ok(enterpriseService.queryPageEmployeeList(queryForm));
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.enterprise;
|
package net.lab1024.sa.admin.module.business.oa.enterprise.manager;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.dao.EnterpriseEmployeeDao;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.dao.EnterpriseEmployeeDao;
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.enterprise;
|
package net.lab1024.sa.admin.module.business.oa.enterprise.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -13,6 +13,7 @@ import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseEm
|
|||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseExcelVO;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseExcelVO;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseListVO;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseListVO;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseVO;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseVO;
|
||||||
|
import net.lab1024.sa.admin.module.business.oa.enterprise.manager.EnterpriseEmployeeManager;
|
||||||
import net.lab1024.sa.admin.module.system.department.service.DepartmentService;
|
import net.lab1024.sa.admin.module.system.department.service.DepartmentService;
|
||||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||||
import net.lab1024.sa.base.common.domain.PageResult;
|
import net.lab1024.sa.base.common.domain.PageResult;
|
@ -1,11 +1,13 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.invoice;
|
package net.lab1024.sa.admin.module.business.oa.invoice.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
|
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
|
||||||
|
import net.lab1024.sa.admin.module.business.oa.invoice.service.InvoiceService;
|
||||||
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceAddForm;
|
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceAddForm;
|
||||||
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceQueryForm;
|
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceQueryForm;
|
||||||
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceUpdateForm;
|
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceUpdateForm;
|
||||||
@ -38,18 +40,21 @@ public class InvoiceController {
|
|||||||
|
|
||||||
@Operation(summary = "分页查询发票信息 @author 善逸")
|
@Operation(summary = "分页查询发票信息 @author 善逸")
|
||||||
@PostMapping("/oa/invoice/page/query")
|
@PostMapping("/oa/invoice/page/query")
|
||||||
|
@SaCheckPermission("oa:invoice:query")
|
||||||
public ResponseDTO<PageResult<InvoiceVO>> queryByPage(@RequestBody @Valid InvoiceQueryForm queryForm) {
|
public ResponseDTO<PageResult<InvoiceVO>> queryByPage(@RequestBody @Valid InvoiceQueryForm queryForm) {
|
||||||
return invoiceService.queryByPage(queryForm);
|
return invoiceService.queryByPage(queryForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询发票信息详情 @author 善逸")
|
@Operation(summary = "查询发票信息详情 @author 善逸")
|
||||||
@GetMapping("/oa/invoice/get/{invoiceId}")
|
@GetMapping("/oa/invoice/get/{invoiceId}")
|
||||||
|
@SaCheckPermission("oa:invoice:query")
|
||||||
public ResponseDTO<InvoiceVO> getDetail(@PathVariable Long invoiceId) {
|
public ResponseDTO<InvoiceVO> getDetail(@PathVariable Long invoiceId) {
|
||||||
return invoiceService.getDetail(invoiceId);
|
return invoiceService.getDetail(invoiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "新建发票信息 @author 善逸")
|
@Operation(summary = "新建发票信息 @author 善逸")
|
||||||
@PostMapping("/oa/invoice/create")
|
@PostMapping("/oa/invoice/create")
|
||||||
|
@SaCheckPermission("oa:invoice:add")
|
||||||
public ResponseDTO<String> createInvoice(@RequestBody @Valid InvoiceAddForm createVO) {
|
public ResponseDTO<String> createInvoice(@RequestBody @Valid InvoiceAddForm createVO) {
|
||||||
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||||
createVO.setCreateUserId(requestUser.getUserId());
|
createVO.setCreateUserId(requestUser.getUserId());
|
||||||
@ -57,21 +62,24 @@ public class InvoiceController {
|
|||||||
return invoiceService.createInvoice(createVO);
|
return invoiceService.createInvoice(createVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateLog
|
||||||
@Operation(summary = "编辑发票信息 @author 善逸")
|
@Operation(summary = "编辑发票信息 @author 善逸")
|
||||||
@PostMapping("/oa/invoice/update")
|
@PostMapping("/oa/invoice/update")
|
||||||
@OperateLog
|
@SaCheckPermission("oa:invoice:update")
|
||||||
public ResponseDTO<String> updateInvoice(@RequestBody @Valid InvoiceUpdateForm updateVO) {
|
public ResponseDTO<String> updateInvoice(@RequestBody @Valid InvoiceUpdateForm updateVO) {
|
||||||
return invoiceService.updateInvoice(updateVO);
|
return invoiceService.updateInvoice(updateVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除发票信息 @author 善逸")
|
@Operation(summary = "删除发票信息 @author 善逸")
|
||||||
@GetMapping("/invoice/delete/{invoiceId}")
|
@GetMapping("/invoice/delete/{invoiceId}")
|
||||||
|
@SaCheckPermission("oa:invoice:delete")
|
||||||
public ResponseDTO<String> deleteInvoice(@PathVariable Long invoiceId) {
|
public ResponseDTO<String> deleteInvoice(@PathVariable Long invoiceId) {
|
||||||
return invoiceService.deleteInvoice(invoiceId);
|
return invoiceService.deleteInvoice(invoiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询列表 @author lidoudou")
|
@Operation(summary = "查询列表 @author lidoudou")
|
||||||
@GetMapping("/oa/invoice/query/list/{enterpriseId}")
|
@GetMapping("/oa/invoice/query/list/{enterpriseId}")
|
||||||
|
@SaCheckPermission("oa:invoice:query")
|
||||||
public ResponseDTO<List<InvoiceVO>> queryList(@PathVariable Long enterpriseId) {
|
public ResponseDTO<List<InvoiceVO>> queryList(@PathVariable Long enterpriseId) {
|
||||||
return invoiceService.queryList(enterpriseId);
|
return invoiceService.queryList(enterpriseId);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.invoice;
|
package net.lab1024.sa.admin.module.business.oa.invoice.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@ -7,7 +7,6 @@ import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceQueryForm;
|
|||||||
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceVO;
|
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,10 +1,11 @@
|
|||||||
package net.lab1024.sa.admin.module.business.oa.invoice;
|
package net.lab1024.sa.admin.module.business.oa.invoice.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.EnterpriseService;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.service.EnterpriseService;
|
||||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseVO;
|
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseVO;
|
||||||
|
import net.lab1024.sa.admin.module.business.oa.invoice.dao.InvoiceDao;
|
||||||
import net.lab1024.sa.admin.module.business.oa.invoice.domain.*;
|
import net.lab1024.sa.admin.module.business.oa.invoice.domain.*;
|
||||||
import net.lab1024.sa.base.common.domain.PageResult;
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
@ -230,7 +230,7 @@ public class NoticeService {
|
|||||||
noticeVisibleRange.setDataName(employeeEntity == null ? StringConst.EMPTY : employeeEntity.getActualName());
|
noticeVisibleRange.setDataName(employeeEntity == null ? StringConst.EMPTY : employeeEntity.getActualName());
|
||||||
} else {
|
} else {
|
||||||
DepartmentVO departmentVO = departmentService.getDepartmentById(noticeVisibleRange.getDataId());
|
DepartmentVO departmentVO = departmentService.getDepartmentById(noticeVisibleRange.getDataId());
|
||||||
noticeVisibleRange.setDataName(departmentVO == null ? StringConst.EMPTY : departmentVO.getName());
|
noticeVisibleRange.setDataName(departmentVO == null ? StringConst.EMPTY : departmentVO.getDepartmentName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateFormVO.setVisibleRangeList(noticeVisibleRangeList);
|
updateFormVO.setVisibleRangeList(noticeVisibleRangeList);
|
||||||
|
@ -5,7 +5,6 @@ import net.lab1024.sa.admin.module.system.department.domain.entity.DepartmentEnt
|
|||||||
import net.lab1024.sa.admin.module.system.department.domain.vo.DepartmentVO;
|
import net.lab1024.sa.admin.module.system.department.domain.vo.DepartmentVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -32,4 +31,5 @@ public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
|||||||
*/
|
*/
|
||||||
List<DepartmentVO> listAll();
|
List<DepartmentVO> listAll();
|
||||||
|
|
||||||
|
DepartmentVO selectDepartmentVO(@Param("departmentId")Long departmentId);
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@ public class DepartmentEntity {
|
|||||||
/**
|
/**
|
||||||
* 部门名称
|
* 部门名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String departmentName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 负责人员工 id
|
* 负责人员工 id
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||||
private Long managerId;
|
private Long managerId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,7 @@ public class DepartmentAddForm {
|
|||||||
@Schema(description = "部门名称")
|
@Schema(description = "部门名称")
|
||||||
@Length(min = 1, max = 50, message = "请输入正确的部门名称(1-50个字符)")
|
@Length(min = 1, max = 50, message = "请输入正确的部门名称(1-50个字符)")
|
||||||
@NotNull(message = "请输入正确的部门名称(1-50个字符)")
|
@NotNull(message = "请输入正确的部门名称(1-50个字符)")
|
||||||
private String name;
|
private String departmentName;
|
||||||
|
|
||||||
@Schema(description = "排序")
|
@Schema(description = "排序")
|
||||||
@NotNull(message = "排序值")
|
@NotNull(message = "排序值")
|
||||||
|
@ -24,7 +24,7 @@ public class DepartmentVO implements Serializable {
|
|||||||
private Long departmentId;
|
private Long departmentId;
|
||||||
|
|
||||||
@Schema(description = "部门名称")
|
@Schema(description = "部门名称")
|
||||||
private String name;
|
private String departmentName;
|
||||||
|
|
||||||
@Schema(description = "部门负责人姓名")
|
@Schema(description = "部门负责人姓名")
|
||||||
private String managerName;
|
private String managerName;
|
||||||
|
@ -42,7 +42,7 @@ public class DepartmentCacheManager {
|
|||||||
log.info("clear " + cache);
|
log.info("clear " + cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CacheEvict(value = {AdminCacheConst.Department.DEPARTMENT_LIST_CACHE, AdminCacheConst.Department.DEPARTMENT_MAP_CACHE, AdminCacheConst.Department.DEPARTMENT_SELF_CHILDREN_CACHE, AdminCacheConst.Department.DEPARTMENT_TREE_CACHE, AdminCacheConst.Department.DEPARTMENT_PATH_CACHE,}, allEntries = true)
|
@CacheEvict(value = {AdminCacheConst.Department.DEPARTMENT_LIST_CACHE, AdminCacheConst.Department.DEPARTMENT_SELF_CHILDREN_CACHE, AdminCacheConst.Department.DEPARTMENT_TREE_CACHE, AdminCacheConst.Department.DEPARTMENT_PATH_CACHE,}, allEntries = true)
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
logClearInfo(AdminCacheConst.Department.DEPARTMENT_LIST_CACHE);
|
logClearInfo(AdminCacheConst.Department.DEPARTMENT_LIST_CACHE);
|
||||||
}
|
}
|
||||||
@ -56,19 +56,8 @@ public class DepartmentCacheManager {
|
|||||||
return departmentDao.listAll();
|
return departmentDao.listAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门map
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Cacheable(AdminCacheConst.Department.DEPARTMENT_MAP_CACHE)
|
|
||||||
public Map<Long, DepartmentVO> getDepartmentMap() {
|
|
||||||
return departmentDao.listAll().stream().collect(Collectors.toMap(DepartmentVO::getDepartmentId, Function.identity()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存部门树结构
|
* 缓存部门树结构
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Cacheable(AdminCacheConst.Department.DEPARTMENT_TREE_CACHE)
|
@Cacheable(AdminCacheConst.Department.DEPARTMENT_TREE_CACHE)
|
||||||
public List<DepartmentTreeVO> getDepartmentTree() {
|
public List<DepartmentTreeVO> getDepartmentTree() {
|
||||||
@ -78,7 +67,6 @@ public class DepartmentCacheManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存某个部门的下级id列表
|
* 缓存某个部门的下级id列表
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Cacheable(AdminCacheConst.Department.DEPARTMENT_SELF_CHILDREN_CACHE)
|
@Cacheable(AdminCacheConst.Department.DEPARTMENT_SELF_CHILDREN_CACHE)
|
||||||
public List<Long> getDepartmentSelfAndChildren(Long departmentId) {
|
public List<Long> getDepartmentSelfAndChildren(Long departmentId) {
|
||||||
@ -89,7 +77,6 @@ public class DepartmentCacheManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门的路径名称
|
* 部门的路径名称
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Cacheable(AdminCacheConst.Department.DEPARTMENT_PATH_CACHE)
|
@Cacheable(AdminCacheConst.Department.DEPARTMENT_PATH_CACHE)
|
||||||
public Map<Long, String> getDepartmentPathMap() {
|
public Map<Long, String> getDepartmentPathMap() {
|
||||||
@ -110,22 +97,21 @@ public class DepartmentCacheManager {
|
|||||||
*/
|
*/
|
||||||
private String buildDepartmentPath(DepartmentVO departmentVO, Map<Long, DepartmentVO> departmentMap) {
|
private String buildDepartmentPath(DepartmentVO departmentVO, Map<Long, DepartmentVO> departmentMap) {
|
||||||
if (Objects.equals(departmentVO.getParentId(), NumberUtils.LONG_ZERO)) {
|
if (Objects.equals(departmentVO.getParentId(), NumberUtils.LONG_ZERO)) {
|
||||||
return departmentVO.getName();
|
return departmentVO.getDepartmentName();
|
||||||
}
|
}
|
||||||
//父节点
|
//父节点
|
||||||
DepartmentVO parentDepartment = departmentMap.get(departmentVO.getParentId());
|
DepartmentVO parentDepartment = departmentMap.get(departmentVO.getParentId());
|
||||||
if (parentDepartment == null) {
|
if (parentDepartment == null) {
|
||||||
return departmentVO.getName();
|
return departmentVO.getDepartmentName();
|
||||||
}
|
}
|
||||||
String pathName = buildDepartmentPath(parentDepartment, departmentMap);
|
String pathName = buildDepartmentPath(parentDepartment, departmentMap);
|
||||||
return pathName + "/" + departmentVO.getName();
|
return pathName + "/" + departmentVO.getDepartmentName();
|
||||||
|
|
||||||
}
|
}
|
||||||
// ---------------------- 构造树的一些方法 ------------------------------
|
// ---------------------- 构造树的一些方法 ------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建部门树结构
|
* 构建部门树结构
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public List<DepartmentTreeVO> buildTree(List<DepartmentVO> voList) {
|
public List<DepartmentTreeVO> buildTree(List<DepartmentVO> voList) {
|
||||||
if (CollectionUtils.isEmpty(voList)) {
|
if (CollectionUtils.isEmpty(voList)) {
|
||||||
@ -192,7 +178,6 @@ public class DepartmentCacheManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取子元素
|
* 获取子元素
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private List<DepartmentTreeVO> getChildren(Long departmentId, List<DepartmentVO> voList) {
|
private List<DepartmentTreeVO> getChildren(Long departmentId, List<DepartmentVO> voList) {
|
||||||
List<DepartmentVO> childrenEntityList = voList.stream().filter(e -> departmentId.equals(e.getParentId())).collect(Collectors.toList());
|
List<DepartmentVO> childrenEntityList = voList.stream().filter(e -> departmentId.equals(e.getParentId())).collect(Collectors.toList());
|
||||||
@ -205,7 +190,6 @@ public class DepartmentCacheManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过部门id,获取当前以及下属部门
|
* 通过部门id,获取当前以及下属部门
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public List<Long> selfAndChildrenIdList(Long departmentId, List<DepartmentVO> voList) {
|
public List<Long> selfAndChildrenIdList(Long departmentId, List<DepartmentVO> voList) {
|
||||||
List<Long> selfAndChildrenIdList = Lists.newArrayList();
|
List<Long> selfAndChildrenIdList = Lists.newArrayList();
|
||||||
|
@ -14,10 +14,7 @@ import net.lab1024.sa.base.common.domain.ResponseDTO;
|
|||||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门 service
|
* 部门 service
|
||||||
@ -44,7 +41,6 @@ public class DepartmentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增添加部门
|
* 新增添加部门
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public ResponseDTO<String> addDepartment(DepartmentAddForm departmentAddForm) {
|
public ResponseDTO<String> addDepartment(DepartmentAddForm departmentAddForm) {
|
||||||
@ -57,7 +53,6 @@ public class DepartmentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新部门信息
|
* 更新部门信息
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> updateDepartment(DepartmentUpdateForm updateDTO) {
|
public ResponseDTO<String> updateDepartment(DepartmentUpdateForm updateDTO) {
|
||||||
if (updateDTO.getParentId() == null) {
|
if (updateDTO.getParentId() == null) {
|
||||||
@ -78,7 +73,6 @@ public class DepartmentService {
|
|||||||
* 根据id删除部门
|
* 根据id删除部门
|
||||||
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
||||||
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> deleteDepartment(Long departmentId) {
|
public ResponseDTO<String> deleteDepartment(Long departmentId) {
|
||||||
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
||||||
@ -122,7 +116,6 @@ public class DepartmentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 自身以及所有下级的部门id列表
|
* 自身以及所有下级的部门id列表
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public List<Long> selfAndChildrenIdList(Long departmentId) {
|
public List<Long> selfAndChildrenIdList(Long departmentId) {
|
||||||
return departmentCacheManager.getDepartmentSelfAndChildren(departmentId);
|
return departmentCacheManager.getDepartmentSelfAndChildren(departmentId);
|
||||||
@ -131,7 +124,6 @@ public class DepartmentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有部门
|
* 获取所有部门
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public List<DepartmentVO> listAll() {
|
public List<DepartmentVO> listAll() {
|
||||||
return departmentCacheManager.getDepartmentList();
|
return departmentCacheManager.getDepartmentList();
|
||||||
@ -140,10 +132,9 @@ public class DepartmentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门
|
* 获取部门
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public DepartmentVO getDepartmentById(Long departmentId) {
|
public DepartmentVO getDepartmentById(Long departmentId) {
|
||||||
return departmentCacheManager.getDepartmentMap().get(departmentId);
|
return departmentDao.selectDepartmentVO(departmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,38 +144,4 @@ public class DepartmentService {
|
|||||||
return departmentCacheManager.getDepartmentPathMap().get(departmentId);
|
return departmentCacheManager.getDepartmentPathMap().get(departmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询全部父级部门(不包含自己)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public List<DepartmentVO> queryAllParentDepartment(Long departmentId) {
|
|
||||||
List<DepartmentVO> list = new ArrayList<>();
|
|
||||||
|
|
||||||
Map<Long, DepartmentVO> departmentMap = departmentCacheManager.getDepartmentMap();
|
|
||||||
DepartmentVO departmentVO = departmentMap.get(departmentId);
|
|
||||||
while (departmentVO != null) {
|
|
||||||
list.add(departmentVO);
|
|
||||||
departmentVO = departmentMap.get(departmentVO.getParentId());
|
|
||||||
}
|
|
||||||
Collections.reverse(list);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询全部父级部门(不包含自己)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public List<Long> queryAllParentDepartmentIdList(Long departmentId) {
|
|
||||||
List<Long> list = new ArrayList<>();
|
|
||||||
|
|
||||||
Map<Long, DepartmentVO> departmentMap = departmentCacheManager.getDepartmentMap();
|
|
||||||
DepartmentVO departmentVO = departmentMap.get(departmentId);
|
|
||||||
while (departmentVO != null) {
|
|
||||||
list.add(departmentVO.getDepartmentId());
|
|
||||||
departmentVO = departmentMap.get(departmentVO.getParentId());
|
|
||||||
}
|
|
||||||
Collections.reverse(list);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,12 @@ public class EmployeeEntity {
|
|||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long employeeId;
|
private Long employeeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一id
|
||||||
|
*/
|
||||||
|
private String employeeUid;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录账号
|
* 登录账号
|
||||||
*/
|
*/
|
||||||
|
@ -2,9 +2,7 @@ package net.lab1024.sa.admin.module.system.employee.domain.form;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.Pattern;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.base.common.util.SmartVerificationUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改密码所需参数
|
* 修改密码所需参数
|
||||||
|
@ -138,16 +138,20 @@ public class EmployeeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EmployeeEntity entity = SmartBeanUtil.copy(employeeAddForm, EmployeeEntity.class);
|
EmployeeEntity entity = SmartBeanUtil.copy(employeeAddForm, EmployeeEntity.class);
|
||||||
|
// 员工uid
|
||||||
|
String employeeUid = cn.hutool.core.lang.UUID.randomUUID(true).toString(true);
|
||||||
|
entity.setEmployeeUid(employeeUid);
|
||||||
|
|
||||||
// 设置密码 默认密码
|
// 设置密码 随机密码
|
||||||
String password = securityPasswordService.randomPassword();
|
String randomPassword = securityPasswordService.randomPassword();
|
||||||
entity.setLoginPwd(SecurityPasswordService.getEncryptPwd(password));
|
String generateSaltPassword = this.generateSaltPassword(randomPassword, employeeUid);
|
||||||
|
entity.setLoginPwd(SecurityPasswordService.getEncryptPwd(generateSaltPassword));
|
||||||
|
|
||||||
// 保存数据
|
// 保存数据
|
||||||
entity.setDeletedFlag(Boolean.FALSE);
|
entity.setDeletedFlag(Boolean.FALSE);
|
||||||
employeeManager.saveEmployee(entity, employeeAddForm.getRoleIdList());
|
employeeManager.saveEmployee(entity, employeeAddForm.getRoleIdList());
|
||||||
|
|
||||||
return ResponseDTO.ok(password);
|
return ResponseDTO.ok(randomPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,9 +245,6 @@ public class EmployeeService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新登录人头像
|
* 更新登录人头像
|
||||||
*
|
|
||||||
* @param employeeUpdateAvatarForm
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> updateAvatar(EmployeeUpdateAvatarForm employeeUpdateAvatarForm) {
|
public ResponseDTO<String> updateAvatar(EmployeeUpdateAvatarForm employeeUpdateAvatarForm) {
|
||||||
Long employeeId = employeeUpdateAvatarForm.getEmployeeId();
|
Long employeeId = employeeUpdateAvatarForm.getEmployeeId();
|
||||||
@ -345,7 +346,7 @@ public class EmployeeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 校验原始密码
|
// 校验原始密码
|
||||||
if (!SecurityPasswordService.matchesPwd(updatePasswordForm.getOldPassword(),employeeEntity.getLoginPwd()) ) {
|
if (!SecurityPasswordService.matchesPwd(this.generateSaltPassword(updatePasswordForm.getOldPassword(), employeeEntity.getEmployeeUid()), employeeEntity.getLoginPwd())) {
|
||||||
return ResponseDTO.userErrorParam("原密码有误,请重新输入");
|
return ResponseDTO.userErrorParam("原密码有误,请重新输入");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,14 +362,13 @@ public class EmployeeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据三级等保规则,校验密码是否重复
|
// 根据三级等保规则,校验密码是否重复
|
||||||
ResponseDTO<String> passwordRepeatTimes = securityPasswordService.validatePasswordRepeatTimes(requestUser, updatePasswordForm.getNewPassword());
|
ResponseDTO<String> passwordRepeatTimes = securityPasswordService.validatePasswordRepeatTimes(requestUser, this.generateSaltPassword(updatePasswordForm.getNewPassword(), employeeEntity.getEmployeeUid()));
|
||||||
if (!passwordRepeatTimes.getOk()) {
|
if (!passwordRepeatTimes.getOk()) {
|
||||||
return ResponseDTO.error(passwordRepeatTimes);
|
return ResponseDTO.error(passwordRepeatTimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 更新密码
|
// 更新密码
|
||||||
String newEncryptPassword = SecurityPasswordService.getEncryptPwd(updatePasswordForm.getNewPassword());
|
String newEncryptPassword = SecurityPasswordService.getEncryptPwd(this.generateSaltPassword(updatePasswordForm.getNewPassword(), employeeEntity.getEmployeeUid()));
|
||||||
EmployeeEntity updateEntity = new EmployeeEntity();
|
EmployeeEntity updateEntity = new EmployeeEntity();
|
||||||
updateEntity.setEmployeeId(employeeId);
|
updateEntity.setEmployeeId(employeeId);
|
||||||
updateEntity.setLoginPwd(newEncryptPassword);
|
updateEntity.setLoginPwd(newEncryptPassword);
|
||||||
@ -395,7 +395,7 @@ public class EmployeeService {
|
|||||||
List<EmployeeVO> voList = employeeEntityList.stream().map(e -> {
|
List<EmployeeVO> voList = employeeEntityList.stream().map(e -> {
|
||||||
EmployeeVO employeeVO = SmartBeanUtil.copy(e, EmployeeVO.class);
|
EmployeeVO employeeVO = SmartBeanUtil.copy(e, EmployeeVO.class);
|
||||||
if (department != null) {
|
if (department != null) {
|
||||||
employeeVO.setDepartmentName(department.getName());
|
employeeVO.setDepartmentName(department.getDepartmentName());
|
||||||
}
|
}
|
||||||
return employeeVO;
|
return employeeVO;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
@ -407,8 +407,14 @@ public class EmployeeService {
|
|||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> resetPassword(Long employeeId) {
|
public ResponseDTO<String> resetPassword(Long employeeId) {
|
||||||
|
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
||||||
|
if (employeeEntity == null) {
|
||||||
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||||
|
}
|
||||||
|
|
||||||
String password = securityPasswordService.randomPassword();
|
String password = securityPasswordService.randomPassword();
|
||||||
employeeDao.updatePassword(employeeId, SecurityPasswordService.getEncryptPwd(password));
|
String saltPassword = this.generateSaltPassword(password, employeeEntity.getEmployeeUid());
|
||||||
|
employeeDao.updatePassword(employeeId, SecurityPasswordService.getEncryptPwd(saltPassword));
|
||||||
return ResponseDTO.ok(password);
|
return ResponseDTO.ok(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,4 +434,14 @@ public class EmployeeService {
|
|||||||
return employeeDao.getByLoginName(loginName, false);
|
return employeeDao.getByLoginName(loginName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成加盐密码
|
||||||
|
* 格式为:[password]_[uid大写]_[uid小写]
|
||||||
|
*/
|
||||||
|
public String generateSaltPassword(String password, String employeeUid) {
|
||||||
|
return password + StringConst.UNDERLINE +
|
||||||
|
employeeUid.toUpperCase() +
|
||||||
|
StringConst.UNDERLINE +
|
||||||
|
employeeUid.toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class LoginController {
|
|||||||
return ResponseDTO.ok(loginResult);
|
return ResponseDTO.ok(loginResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "退出登陆 @author 卓大")
|
@Operation(summary = "退出登录 @author 卓大")
|
||||||
@GetMapping("/login/logout")
|
@GetMapping("/login/logout")
|
||||||
public ResponseDTO<String> logout() {
|
public ResponseDTO<String> logout() {
|
||||||
return loginService.logout(SmartRequestUtil.getRequestUser());
|
return loginService.logout(SmartRequestUtil.getRequestUser());
|
||||||
|
@ -7,6 +7,8 @@ import net.lab1024.sa.base.common.enumeration.GenderEnum;
|
|||||||
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
|
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
|
||||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求员工登录信息
|
* 请求员工登录信息
|
||||||
*
|
*
|
||||||
@ -17,7 +19,7 @@ import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RequestEmployee implements RequestUser {
|
public class RequestEmployee implements RequestUser, Serializable {
|
||||||
|
|
||||||
@Schema(description = "员工id")
|
@Schema(description = "员工id")
|
||||||
private Long employeeId;
|
private Long employeeId;
|
||||||
|
@ -0,0 +1,173 @@
|
|||||||
|
package net.lab1024.sa.admin.module.system.login.manager;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.lab1024.sa.admin.constant.AdminCacheConst;
|
||||||
|
import net.lab1024.sa.admin.module.system.department.domain.vo.DepartmentVO;
|
||||||
|
import net.lab1024.sa.admin.module.system.department.service.DepartmentService;
|
||||||
|
import net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity;
|
||||||
|
import net.lab1024.sa.admin.module.system.employee.service.EmployeeService;
|
||||||
|
import net.lab1024.sa.admin.module.system.login.domain.RequestEmployee;
|
||||||
|
import net.lab1024.sa.admin.module.system.menu.domain.vo.MenuVO;
|
||||||
|
import net.lab1024.sa.admin.module.system.role.domain.vo.RoleVO;
|
||||||
|
import net.lab1024.sa.admin.module.system.role.service.RoleEmployeeService;
|
||||||
|
import net.lab1024.sa.admin.module.system.role.service.RoleMenuService;
|
||||||
|
import net.lab1024.sa.base.common.constant.StringConst;
|
||||||
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.sa.base.common.domain.UserPermission;
|
||||||
|
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
|
||||||
|
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||||
|
import net.lab1024.sa.base.module.support.file.service.IFileStorageService;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.CachePut;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录Manager
|
||||||
|
*
|
||||||
|
* @Author 1024创新实验室: 卓大
|
||||||
|
* @Date 2025-05-03 22:56:34
|
||||||
|
* @Wechat zhuoda1024
|
||||||
|
* @Email lab1024@163.com
|
||||||
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class LoginManager {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DepartmentService departmentService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IFileStorageService fileStorageService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EmployeeService employeeService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RoleEmployeeService roleEmployeeService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RoleMenuService roleMenuService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取请求用户信息
|
||||||
|
*/
|
||||||
|
@Cacheable(AdminCacheConst.Login.REQUEST_EMPLOYEE)
|
||||||
|
public RequestEmployee getRequestEmployee(Long requestEmployeeId ) {
|
||||||
|
if (requestEmployeeId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 员工基本信息
|
||||||
|
EmployeeEntity employeeEntity = employeeService.getById(requestEmployeeId);
|
||||||
|
if (employeeEntity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.loadLoginInfo(employeeEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录的用户信息
|
||||||
|
*/
|
||||||
|
@CachePut(value = AdminCacheConst.Login.REQUEST_EMPLOYEE, key = "#employeeEntity.employeeId")
|
||||||
|
public RequestEmployee loadLoginInfo(EmployeeEntity employeeEntity) {
|
||||||
|
// 基础信息
|
||||||
|
RequestEmployee requestEmployee = SmartBeanUtil.copy(employeeEntity, RequestEmployee.class);
|
||||||
|
requestEmployee.setUserType(UserTypeEnum.ADMIN_EMPLOYEE);
|
||||||
|
|
||||||
|
// 部门信息
|
||||||
|
DepartmentVO department = departmentService.getDepartmentById(employeeEntity.getDepartmentId());
|
||||||
|
requestEmployee.setDepartmentName(null == department ? StringConst.EMPTY : department.getDepartmentName());
|
||||||
|
|
||||||
|
// 头像信息
|
||||||
|
String avatar = employeeEntity.getAvatar();
|
||||||
|
if (StringUtils.isNotBlank(avatar)) {
|
||||||
|
ResponseDTO<String> getFileUrl = fileStorageService.getFileUrl(avatar);
|
||||||
|
if (BooleanUtils.isTrue(getFileUrl.getOk())) {
|
||||||
|
requestEmployee.setAvatar(getFileUrl.getData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return requestEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的权限(包含 角色列表、权限列表)
|
||||||
|
*/
|
||||||
|
@Cacheable(AdminCacheConst.Login.USER_PERMISSION)
|
||||||
|
public UserPermission getUserPermission(Long employeeId) {
|
||||||
|
if(null == employeeId){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.loadUserPermission(employeeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的权限(包含 角色列表、权限列表)
|
||||||
|
*/
|
||||||
|
@CachePut(AdminCacheConst.Login.USER_PERMISSION)
|
||||||
|
public UserPermission loadUserPermission(Long employeeId) {
|
||||||
|
UserPermission userPermission = new UserPermission();
|
||||||
|
userPermission.setPermissionList(new ArrayList<>());
|
||||||
|
userPermission.setRoleList(new ArrayList<>());
|
||||||
|
|
||||||
|
// 角色列表
|
||||||
|
List<RoleVO> roleList = roleEmployeeService.getRoleIdList(employeeId);
|
||||||
|
userPermission.getRoleList().addAll(roleList.stream().map(RoleVO::getRoleCode).collect(Collectors.toSet()));
|
||||||
|
|
||||||
|
// 前端菜单和功能点清单
|
||||||
|
EmployeeEntity employeeEntity = employeeService.getById(employeeId);
|
||||||
|
|
||||||
|
List<MenuVO> menuAndPointsList = roleMenuService.getMenuList(roleList.stream().map(RoleVO::getRoleId).collect(Collectors.toList()), employeeEntity.getAdministratorFlag());
|
||||||
|
|
||||||
|
// 权限列表
|
||||||
|
HashSet<String> permissionSet = new HashSet<>();
|
||||||
|
for (MenuVO menu : menuAndPointsList) {
|
||||||
|
if (menu.getPermsType() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String perms = menu.getApiPerms();
|
||||||
|
if (StringUtils.isEmpty(perms)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//接口权限
|
||||||
|
String[] split = perms.split(",");
|
||||||
|
permissionSet.addAll(Arrays.asList(split));
|
||||||
|
}
|
||||||
|
userPermission.getPermissionList().addAll(permissionSet);
|
||||||
|
|
||||||
|
return userPermission;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除用户权限
|
||||||
|
*/
|
||||||
|
@CacheEvict(value = AdminCacheConst.Login.USER_PERMISSION)
|
||||||
|
public void clearUserPermission(Long employeeId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除用户登录信息
|
||||||
|
*/
|
||||||
|
@CacheEvict(value = AdminCacheConst.Login.REQUEST_EMPLOYEE)
|
||||||
|
public void clearUserLoginInfo(Long employeeId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -6,17 +6,15 @@ import cn.hutool.core.lang.UUID;
|
|||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.extra.servlet.JakartaServletUtil;
|
import cn.hutool.extra.servlet.JakartaServletUtil;
|
||||||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.admin.module.system.department.domain.vo.DepartmentVO;
|
|
||||||
import net.lab1024.sa.admin.module.system.department.service.DepartmentService;
|
|
||||||
import net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity;
|
import net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity;
|
||||||
import net.lab1024.sa.admin.module.system.employee.service.EmployeeService;
|
import net.lab1024.sa.admin.module.system.employee.service.EmployeeService;
|
||||||
import net.lab1024.sa.admin.module.system.login.domain.LoginForm;
|
import net.lab1024.sa.admin.module.system.login.domain.LoginForm;
|
||||||
import net.lab1024.sa.admin.module.system.login.domain.LoginResultVO;
|
import net.lab1024.sa.admin.module.system.login.domain.LoginResultVO;
|
||||||
import net.lab1024.sa.admin.module.system.login.domain.RequestEmployee;
|
import net.lab1024.sa.admin.module.system.login.domain.RequestEmployee;
|
||||||
|
import net.lab1024.sa.admin.module.system.login.manager.LoginManager;
|
||||||
import net.lab1024.sa.admin.module.system.menu.domain.vo.MenuVO;
|
import net.lab1024.sa.admin.module.system.menu.domain.vo.MenuVO;
|
||||||
import net.lab1024.sa.admin.module.system.role.domain.vo.RoleVO;
|
import net.lab1024.sa.admin.module.system.role.domain.vo.RoleVO;
|
||||||
import net.lab1024.sa.admin.module.system.role.service.RoleEmployeeService;
|
import net.lab1024.sa.admin.module.system.role.service.RoleEmployeeService;
|
||||||
@ -39,7 +37,6 @@ import net.lab1024.sa.base.module.support.captcha.CaptchaService;
|
|||||||
import net.lab1024.sa.base.module.support.captcha.domain.CaptchaVO;
|
import net.lab1024.sa.base.module.support.captcha.domain.CaptchaVO;
|
||||||
import net.lab1024.sa.base.module.support.config.ConfigKeyEnum;
|
import net.lab1024.sa.base.module.support.config.ConfigKeyEnum;
|
||||||
import net.lab1024.sa.base.module.support.config.ConfigService;
|
import net.lab1024.sa.base.module.support.config.ConfigService;
|
||||||
import net.lab1024.sa.base.module.support.file.service.IFileStorageService;
|
|
||||||
import net.lab1024.sa.base.module.support.loginlog.LoginLogResultEnum;
|
import net.lab1024.sa.base.module.support.loginlog.LoginLogResultEnum;
|
||||||
import net.lab1024.sa.base.module.support.loginlog.LoginLogService;
|
import net.lab1024.sa.base.module.support.loginlog.LoginLogService;
|
||||||
import net.lab1024.sa.base.module.support.loginlog.domain.LoginLogEntity;
|
import net.lab1024.sa.base.module.support.loginlog.domain.LoginLogEntity;
|
||||||
@ -48,21 +45,22 @@ import net.lab1024.sa.base.module.support.mail.MailService;
|
|||||||
import net.lab1024.sa.base.module.support.mail.constant.MailTemplateCodeEnum;
|
import net.lab1024.sa.base.module.support.mail.constant.MailTemplateCodeEnum;
|
||||||
import net.lab1024.sa.base.module.support.redis.RedisService;
|
import net.lab1024.sa.base.module.support.redis.RedisService;
|
||||||
import net.lab1024.sa.base.module.support.securityprotect.domain.LoginFailEntity;
|
import net.lab1024.sa.base.module.support.securityprotect.domain.LoginFailEntity;
|
||||||
import net.lab1024.sa.base.module.support.securityprotect.service.*;
|
import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import net.lab1024.sa.base.module.support.securityprotect.service.SecurityLoginService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import net.lab1024.sa.base.module.support.securityprotect.service.SecurityPasswordService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*
|
*
|
||||||
* @Author 1024创新实验室: 开云
|
* @Author 1024创新实验室: 卓大
|
||||||
* @Date 2021-12-01 22:56:34
|
* @Date 2025-05-03 22:56:34
|
||||||
* @Wechat zhuoda1024
|
* @Wechat zhuoda1024
|
||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
@ -76,28 +74,9 @@ public class LoginService implements StpInterface {
|
|||||||
*/
|
*/
|
||||||
private static final String SUPER_PASSWORD_LOGIN_ID_PREFIX = "S";
|
private static final String SUPER_PASSWORD_LOGIN_ID_PREFIX = "S";
|
||||||
|
|
||||||
/**
|
|
||||||
* 最大在线缓存人数
|
|
||||||
*/
|
|
||||||
private static final long CACHE_MAX_ONLINE_PERSON_COUNT = 1000L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录信息二级缓存
|
|
||||||
*/
|
|
||||||
private final ConcurrentMap<Long, RequestEmployee> loginEmployeeCache = new ConcurrentLinkedHashMap.Builder<Long, RequestEmployee>().maximumWeightedCapacity(CACHE_MAX_ONLINE_PERSON_COUNT).build();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限 缓存
|
|
||||||
*/
|
|
||||||
private final ConcurrentMap<Long, UserPermission> permissionCache = new ConcurrentLinkedHashMap.Builder<Long, UserPermission>().maximumWeightedCapacity(CACHE_MAX_ONLINE_PERSON_COUNT).build();
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EmployeeService employeeService;
|
private EmployeeService employeeService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DepartmentService departmentService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CaptchaService captchaService;
|
private CaptchaService captchaService;
|
||||||
|
|
||||||
@ -119,9 +98,6 @@ public class LoginService implements StpInterface {
|
|||||||
@Resource
|
@Resource
|
||||||
private SecurityPasswordService protectPasswordService;
|
private SecurityPasswordService protectPasswordService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private IFileStorageService fileStorageService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ApiEncryptService apiEncryptService;
|
private ApiEncryptService apiEncryptService;
|
||||||
|
|
||||||
@ -134,6 +110,9 @@ public class LoginService implements StpInterface {
|
|||||||
@Resource
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LoginManager loginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取验证码
|
* 获取验证码
|
||||||
*/
|
*/
|
||||||
@ -142,7 +121,7 @@ public class LoginService implements StpInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工登陆
|
* 员工登录
|
||||||
*
|
*
|
||||||
* @return 返回用户登录信息
|
* @return 返回用户登录信息
|
||||||
*/
|
*/
|
||||||
@ -206,7 +185,7 @@ public class LoginService implements StpInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 密码错误
|
// 密码错误
|
||||||
if (!SecurityPasswordService.matchesPwd(requestPassword, employeeEntity.getLoginPwd())) {
|
if (!SecurityPasswordService.matchesPwd(employeeService.generateSaltPassword(requestPassword, employeeEntity.getEmployeeUid()), employeeEntity.getLoginPwd())) {
|
||||||
// 记录登录失败
|
// 记录登录失败
|
||||||
saveLoginLog(employeeEntity, ip, userAgent, "密码错误", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
saveLoginLog(employeeEntity, ip, userAgent, "密码错误", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||||
// 记录等级保护次数
|
// 记录等级保护次数
|
||||||
@ -224,10 +203,7 @@ public class LoginService implements StpInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取员工信息
|
// 获取员工信息
|
||||||
RequestEmployee requestEmployee = loadLoginInfo(employeeEntity);
|
RequestEmployee requestEmployee = loginManager.loadLoginInfo(employeeEntity);
|
||||||
|
|
||||||
// 放入缓存
|
|
||||||
loginEmployeeCache.put(employeeEntity.getEmployeeId(), requestEmployee);
|
|
||||||
|
|
||||||
// 移除登录失败
|
// 移除登录失败
|
||||||
securityLoginService.removeLoginFail(employeeEntity.getEmployeeId(), UserTypeEnum.ADMIN_EMPLOYEE);
|
securityLoginService.removeLoginFail(employeeEntity.getEmployeeId(), UserTypeEnum.ADMIN_EMPLOYEE);
|
||||||
@ -242,8 +218,8 @@ public class LoginService implements StpInterface {
|
|||||||
// 设置 token
|
// 设置 token
|
||||||
loginResultVO.setToken(token);
|
loginResultVO.setToken(token);
|
||||||
|
|
||||||
// 清除权限缓存
|
// 更新用户权限
|
||||||
permissionCache.remove(employeeEntity.getEmployeeId());
|
loginManager.loadUserPermission(employeeEntity.getEmployeeId());
|
||||||
|
|
||||||
return ResponseDTO.ok(loginResultVO);
|
return ResponseDTO.ok(loginResultVO);
|
||||||
}
|
}
|
||||||
@ -262,10 +238,6 @@ public class LoginService implements StpInterface {
|
|||||||
List<MenuVO> menuAndPointsList = roleMenuService.getMenuList(roleList.stream().map(RoleVO::getRoleId).collect(Collectors.toList()), requestEmployee.getAdministratorFlag());
|
List<MenuVO> menuAndPointsList = roleMenuService.getMenuList(roleList.stream().map(RoleVO::getRoleId).collect(Collectors.toList()), requestEmployee.getAdministratorFlag());
|
||||||
loginResultVO.setMenuList(menuAndPointsList);
|
loginResultVO.setMenuList(menuAndPointsList);
|
||||||
|
|
||||||
// 更新下后端权限缓存
|
|
||||||
UserPermission userPermission = getUserPermission(requestEmployee.getUserId());
|
|
||||||
permissionCache.put(requestEmployee.getUserId(), userPermission);
|
|
||||||
|
|
||||||
// 上次登录信息
|
// 上次登录信息
|
||||||
LoginLogVO loginLogVO = loginLogService.queryLastByUserId(requestEmployee.getEmployeeId(), UserTypeEnum.ADMIN_EMPLOYEE, LoginLogResultEnum.LOGIN_SUCCESS);
|
LoginLogVO loginLogVO = loginLogService.queryLastByUserId(requestEmployee.getEmployeeId(), UserTypeEnum.ADMIN_EMPLOYEE, LoginLogResultEnum.LOGIN_SUCCESS);
|
||||||
if (loginLogVO != null) {
|
if (loginLogVO != null) {
|
||||||
@ -290,33 +262,7 @@ public class LoginService implements StpInterface {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录的用户信息
|
* 根据登录token 获取员请求工信息
|
||||||
*/
|
|
||||||
private RequestEmployee loadLoginInfo(EmployeeEntity employeeEntity) {
|
|
||||||
|
|
||||||
// 基础信息
|
|
||||||
RequestEmployee requestEmployee = SmartBeanUtil.copy(employeeEntity, RequestEmployee.class);
|
|
||||||
requestEmployee.setUserType(UserTypeEnum.ADMIN_EMPLOYEE);
|
|
||||||
|
|
||||||
// 部门信息
|
|
||||||
DepartmentVO department = departmentService.getDepartmentById(employeeEntity.getDepartmentId());
|
|
||||||
requestEmployee.setDepartmentName(null == department ? StringConst.EMPTY : department.getName());
|
|
||||||
|
|
||||||
// 头像信息
|
|
||||||
String avatar = employeeEntity.getAvatar();
|
|
||||||
if (StringUtils.isNotBlank(avatar)) {
|
|
||||||
ResponseDTO<String> getFileUrl = fileStorageService.getFileUrl(avatar);
|
|
||||||
if (BooleanUtils.isTrue(getFileUrl.getOk())) {
|
|
||||||
requestEmployee.setAvatar(getFileUrl.getData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return requestEmployee;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据登陆token 获取员请求工信息
|
|
||||||
*/
|
*/
|
||||||
public RequestEmployee getLoginEmployee(String loginId, HttpServletRequest request) {
|
public RequestEmployee getLoginEmployee(String loginId, HttpServletRequest request) {
|
||||||
if (loginId == null) {
|
if (loginId == null) {
|
||||||
@ -328,17 +274,7 @@ public class LoginService implements StpInterface {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestEmployee requestEmployee = loginEmployeeCache.get(requestEmployeeId);
|
RequestEmployee requestEmployee = loginManager.getRequestEmployee(requestEmployeeId);
|
||||||
if (requestEmployee == null) {
|
|
||||||
// 员工基本信息
|
|
||||||
EmployeeEntity employeeEntity = employeeService.getById(requestEmployeeId);
|
|
||||||
if (employeeEntity == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
requestEmployee = this.loadLoginInfo(employeeEntity);
|
|
||||||
loginEmployeeCache.put(requestEmployeeId, requestEmployee);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新请求ip和user agent
|
// 更新请求ip和user agent
|
||||||
requestEmployee.setUserAgent(JakartaServletUtil.getHeaderIgnoreCase(request, RequestHeaderConst.USER_AGENT));
|
requestEmployee.setUserAgent(JakartaServletUtil.getHeaderIgnoreCase(request, RequestHeaderConst.USER_AGENT));
|
||||||
@ -381,8 +317,8 @@ public class LoginService implements StpInterface {
|
|||||||
// sa token 登出
|
// sa token 登出
|
||||||
StpUtil.logout();
|
StpUtil.logout();
|
||||||
|
|
||||||
// 清空登录信息缓存
|
// 清除用户登录信息缓存和权限信息
|
||||||
loginEmployeeCache.remove(requestUser.getUserId());
|
this.clearLoginEmployeeCache(requestUser.getUserId());
|
||||||
|
|
||||||
//保存登出日志
|
//保存登出日志
|
||||||
LoginLogEntity loginEntity = LoginLogEntity.builder()
|
LoginLogEntity loginEntity = LoginLogEntity.builder()
|
||||||
@ -400,14 +336,6 @@ public class LoginService implements StpInterface {
|
|||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 清除员工登录缓存
|
|
||||||
*/
|
|
||||||
public void clearLoginEmployeeCache(Long employeeId) {
|
|
||||||
// 清空登录信息缓存
|
|
||||||
loginEmployeeCache.remove(employeeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存登录日志
|
* 保存登录日志
|
||||||
*/
|
*/
|
||||||
@ -435,12 +363,7 @@ public class LoginService implements StpInterface {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserPermission userPermission = permissionCache.get(employeeId);
|
UserPermission userPermission = loginManager.getUserPermission(employeeId);
|
||||||
if (userPermission == null) {
|
|
||||||
userPermission = getUserPermission(employeeId);
|
|
||||||
permissionCache.put(employeeId, userPermission);
|
|
||||||
}
|
|
||||||
|
|
||||||
return userPermission.getPermissionList();
|
return userPermission.getPermissionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,51 +374,10 @@ public class LoginService implements StpInterface {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserPermission userPermission = permissionCache.get(employeeId);
|
UserPermission userPermission = loginManager.getUserPermission(employeeId);
|
||||||
if (userPermission == null) {
|
|
||||||
userPermission = getUserPermission(employeeId);
|
|
||||||
permissionCache.put(employeeId, userPermission);
|
|
||||||
}
|
|
||||||
return userPermission.getRoleList();
|
return userPermission.getRoleList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户的权限(包含 角色列表、权限列表)
|
|
||||||
*/
|
|
||||||
private UserPermission getUserPermission(Long employeeId) {
|
|
||||||
|
|
||||||
UserPermission userPermission = new UserPermission();
|
|
||||||
userPermission.setPermissionList(new ArrayList<>());
|
|
||||||
userPermission.setRoleList(new ArrayList<>());
|
|
||||||
|
|
||||||
// 角色列表
|
|
||||||
List<RoleVO> roleList = roleEmployeeService.getRoleIdList(employeeId);
|
|
||||||
userPermission.getRoleList().addAll(roleList.stream().map(RoleVO::getRoleCode).collect(Collectors.toSet()));
|
|
||||||
|
|
||||||
// 前端菜单和功能点清单
|
|
||||||
EmployeeEntity employeeEntity = employeeService.getById(employeeId);
|
|
||||||
|
|
||||||
List<MenuVO> menuAndPointsList = roleMenuService.getMenuList(roleList.stream().map(RoleVO::getRoleId).collect(Collectors.toList()), employeeEntity.getAdministratorFlag());
|
|
||||||
|
|
||||||
// 权限列表
|
|
||||||
HashSet<String> permissionSet = new HashSet<>();
|
|
||||||
for (MenuVO menu : menuAndPointsList) {
|
|
||||||
if (menu.getPermsType() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String perms = menu.getApiPerms();
|
|
||||||
if (StringUtils.isEmpty(perms)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//接口权限
|
|
||||||
String[] split = perms.split(",");
|
|
||||||
permissionSet.addAll(Arrays.asList(split));
|
|
||||||
}
|
|
||||||
userPermission.getPermissionList().addAll(permissionSet);
|
|
||||||
|
|
||||||
return userPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送 邮箱 验证码
|
* 发送 邮箱 验证码
|
||||||
@ -590,4 +472,9 @@ public class LoginService implements StpInterface {
|
|||||||
String redisVerificationCodeKey = redisService.generateRedisKey(RedisKeyConst.Support.LOGIN_VERIFICATION_CODE, UserTypeEnum.ADMIN_EMPLOYEE.getValue() + RedisKeyConst.SEPARATOR + employeeId);
|
String redisVerificationCodeKey = redisService.generateRedisKey(RedisKeyConst.Support.LOGIN_VERIFICATION_CODE, UserTypeEnum.ADMIN_EMPLOYEE.getValue() + RedisKeyConst.SEPARATOR + employeeId);
|
||||||
redisService.delete(redisVerificationCodeKey);
|
redisService.delete(redisVerificationCodeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearLoginEmployeeCache(Long employeeId) {
|
||||||
|
loginManager.clearUserPermission(employeeId);
|
||||||
|
loginManager.clearUserLoginInfo(employeeId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import net.lab1024.sa.base.common.code.SystemErrorCode;
|
|||||||
import net.lab1024.sa.base.common.domain.RequestUrlVO;
|
import net.lab1024.sa.base.common.domain.RequestUrlVO;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||||
|
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||||
import org.apache.commons.lang3.math.NumberUtils;
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@ -134,6 +135,10 @@ public class MenuService {
|
|||||||
* @return true 重复 false 未重复
|
* @return true 重复 false 未重复
|
||||||
*/
|
*/
|
||||||
public <T extends MenuBaseForm> Boolean validateWebPerms(T menuDTO) {
|
public <T extends MenuBaseForm> Boolean validateWebPerms(T menuDTO) {
|
||||||
|
if(SmartStringUtil.isEmpty(menuDTO.getWebPerms())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MenuEntity menu = menuDao.getByWebPerms(menuDTO.getWebPerms(), Boolean.FALSE);
|
MenuEntity menu = menuDao.getByWebPerms(menuDTO.getWebPerms(), Boolean.FALSE);
|
||||||
if (menuDTO instanceof MenuAddForm) {
|
if (menuDTO instanceof MenuAddForm) {
|
||||||
return menu != null;
|
return menu != null;
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package net.lab1024.sa.admin.module.system.message;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
|
||||||
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.sa.base.common.domain.ValidateList;
|
||||||
|
import net.lab1024.sa.base.module.support.message.domain.MessageQueryForm;
|
||||||
|
import net.lab1024.sa.base.module.support.message.domain.MessageSendForm;
|
||||||
|
import net.lab1024.sa.base.module.support.message.domain.MessageVO;
|
||||||
|
import net.lab1024.sa.base.module.support.message.service.MessageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后管 消息路由
|
||||||
|
*
|
||||||
|
* @author: 卓大
|
||||||
|
* @date: 2025/04/09 20:55
|
||||||
|
*/
|
||||||
|
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_MESSAGE)
|
||||||
|
@RestController
|
||||||
|
public class AdminMessageController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageService messageService;
|
||||||
|
|
||||||
|
@Operation(summary = "通知消息-新建 @author 卓大")
|
||||||
|
@PostMapping("/message/sendMessages")
|
||||||
|
@SaCheckPermission("system:message:send")
|
||||||
|
public ResponseDTO<String> sendMessages(@RequestBody @Valid ValidateList<MessageSendForm> messageList) {
|
||||||
|
messageService.sendMessage(messageList);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "通知消息-分页查询 @author 卓大")
|
||||||
|
@PostMapping("/message/query")
|
||||||
|
@SaCheckPermission("system:message:query")
|
||||||
|
public ResponseDTO<PageResult<MessageVO>> query(@RequestBody @Valid MessageQueryForm queryForm) {
|
||||||
|
return ResponseDTO.ok(messageService.query(queryForm));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "通知消息-删除 @author 卓大")
|
||||||
|
@GetMapping("/message/delete/{messageId}")
|
||||||
|
@SaCheckPermission("system:message:delete")
|
||||||
|
public ResponseDTO<String> delete(@PathVariable Long messageId) {
|
||||||
|
return messageService.delete(messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,7 +34,7 @@ public class PositionEntity {
|
|||||||
/**
|
/**
|
||||||
* 职级
|
* 职级
|
||||||
*/
|
*/
|
||||||
private String level;
|
private String positionLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序
|
* 排序
|
||||||
|
@ -21,7 +21,7 @@ public class PositionAddForm {
|
|||||||
private String positionName;
|
private String positionName;
|
||||||
|
|
||||||
@Schema(description = "职级")
|
@Schema(description = "职级")
|
||||||
private String level;
|
private String positionLevel;
|
||||||
|
|
||||||
@Schema(description = "排序")
|
@Schema(description = "排序")
|
||||||
@NotNull(message = "排序不能为空")
|
@NotNull(message = "排序不能为空")
|
||||||
|
@ -23,7 +23,7 @@ public class PositionVO {
|
|||||||
private String positionName;
|
private String positionName;
|
||||||
|
|
||||||
@Schema(description = "职级")
|
@Schema(description = "职级")
|
||||||
private String level;
|
private String positionLevel;
|
||||||
|
|
||||||
@Schema(description = "排序")
|
@Schema(description = "排序")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
@ -5,7 +5,6 @@ import jakarta.validation.constraints.NotEmpty;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,11 +3,7 @@ package net.lab1024.sa.admin.module.system.role.manager;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import net.lab1024.sa.admin.module.system.role.dao.RoleEmployeeDao;
|
import net.lab1024.sa.admin.module.system.role.dao.RoleEmployeeDao;
|
||||||
import net.lab1024.sa.admin.module.system.role.domain.entity.RoleEmployeeEntity;
|
import net.lab1024.sa.admin.module.system.role.domain.entity.RoleEmployeeEntity;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色员工 manager
|
* 角色员工 manager
|
||||||
|
@ -22,7 +22,6 @@ import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
|||||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -73,7 +72,7 @@ public class RoleEmployeeService {
|
|||||||
List<Long> departmentIdList = employeeList.stream().filter(e -> e != null && e.getDepartmentId() != null).map(EmployeeVO::getDepartmentId).collect(Collectors.toList());
|
List<Long> departmentIdList = employeeList.stream().filter(e -> e != null && e.getDepartmentId() != null).map(EmployeeVO::getDepartmentId).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isNotEmpty(departmentIdList)) {
|
if (CollectionUtils.isNotEmpty(departmentIdList)) {
|
||||||
List<DepartmentEntity> departmentEntities = departmentDao.selectBatchIds(departmentIdList);
|
List<DepartmentEntity> departmentEntities = departmentDao.selectBatchIds(departmentIdList);
|
||||||
Map<Long, String> departmentIdNameMap = departmentEntities.stream().collect(Collectors.toMap(DepartmentEntity::getDepartmentId, DepartmentEntity::getName));
|
Map<Long, String> departmentIdNameMap = departmentEntities.stream().collect(Collectors.toMap(DepartmentEntity::getDepartmentId, DepartmentEntity::getDepartmentName));
|
||||||
employeeList.forEach(e -> {
|
employeeList.forEach(e -> {
|
||||||
e.setDepartmentName(departmentIdNameMap.getOrDefault(e.getDepartmentId(), StringConst.EMPTY));
|
e.setDepartmentName(departmentIdNameMap.getOrDefault(e.getDepartmentId(), StringConst.EMPTY));
|
||||||
});
|
});
|
||||||
|
@ -52,43 +52,43 @@ public class AdminDictController extends SupportBaseController {
|
|||||||
|
|
||||||
@Operation(summary = "分页查询 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "分页查询 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/queryPage")
|
@PostMapping("/dict/queryPage")
|
||||||
@SaCheckPermission("dict:query")
|
@SaCheckPermission("support:dict:query")
|
||||||
public ResponseDTO<PageResult<DictVO>> queryPage(@RequestBody @Valid DictQueryForm queryForm) {
|
public ResponseDTO<PageResult<DictVO>> queryPage(@RequestBody @Valid DictQueryForm queryForm) {
|
||||||
return ResponseDTO.ok(dictService.queryPage(queryForm));
|
return ResponseDTO.ok(dictService.queryPage(queryForm));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "添加 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "添加 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/add")
|
@PostMapping("/dict/add")
|
||||||
@SaCheckPermission("dict:add")
|
@SaCheckPermission("support:dict:add")
|
||||||
public ResponseDTO<String> add(@RequestBody @Valid DictAddForm addForm) {
|
public ResponseDTO<String> add(@RequestBody @Valid DictAddForm addForm) {
|
||||||
return dictService.add(addForm);
|
return dictService.add(addForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "更新 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/update")
|
@PostMapping("/dict/update")
|
||||||
@SaCheckPermission("dict:update")
|
@SaCheckPermission("support:dict:update")
|
||||||
public ResponseDTO<String> update(@RequestBody @Valid DictUpdateForm updateForm) {
|
public ResponseDTO<String> update(@RequestBody @Valid DictUpdateForm updateForm) {
|
||||||
return dictService.update(updateForm);
|
return dictService.update(updateForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "字典数据 启用/禁用 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "启用/禁用 @author 1024创新实验室-主任-卓大")
|
||||||
@GetMapping("/dict/updateDisabled/{dictId}")
|
@GetMapping("/dict/updateDisabled/{dictId}")
|
||||||
@SaCheckPermission("dictData:updateDisabled")
|
@SaCheckPermission("support:dict:updateDisabled")
|
||||||
public ResponseDTO<String> updateDisabled(@PathVariable Long dictId) {
|
public ResponseDTO<String> updateDisabled(@PathVariable Long dictId) {
|
||||||
return dictService.updateDisabled(dictId);
|
return dictService.updateDisabled(dictId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "批量删除 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "批量删除 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/batchDelete")
|
@PostMapping("/dict/batchDelete")
|
||||||
@SaCheckPermission("dict:delete")
|
@SaCheckPermission("support:dict:delete")
|
||||||
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
|
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
|
||||||
return dictService.batchDelete(idList);
|
return dictService.batchDelete(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "单个删除 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "单个删除 @author 1024创新实验室-主任-卓大")
|
||||||
@GetMapping("/dict/delete/{dictId}")
|
@GetMapping("/dict/delete/{dictId}")
|
||||||
@SaCheckPermission("dict:delete")
|
@SaCheckPermission("support:dict:delete")
|
||||||
public ResponseDTO<String> batchDelete(@PathVariable Long dictId) {
|
public ResponseDTO<String> delete(@PathVariable Long dictId) {
|
||||||
return dictService.delete(dictId);
|
return dictService.delete(dictId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,42 +96,42 @@ public class AdminDictController extends SupportBaseController {
|
|||||||
|
|
||||||
@Operation(summary = "字典数据 分页查询 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "字典数据 分页查询 @author 1024创新实验室-主任-卓大")
|
||||||
@GetMapping("/dict/dictData/queryDictData/{dictId}")
|
@GetMapping("/dict/dictData/queryDictData/{dictId}")
|
||||||
@SaCheckPermission("dictData:query")
|
@SaCheckPermission("support:dictData:query")
|
||||||
public ResponseDTO<List<DictDataVO>> queryDictData(@PathVariable Long dictId) {
|
public ResponseDTO<List<DictDataVO>> queryDictData(@PathVariable Long dictId) {
|
||||||
return ResponseDTO.ok(dictService.queryDictData(dictId));
|
return ResponseDTO.ok(dictService.queryDictData(dictId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "字典数据 启用/禁用 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "字典数据 启用/禁用 @author 1024创新实验室-主任-卓大")
|
||||||
@GetMapping("/dict/dictData/updateDisabled/{dictDataId}")
|
@GetMapping("/dict/dictData/updateDisabled/{dictDataId}")
|
||||||
@SaCheckPermission("dictData:updateDisabled")
|
@SaCheckPermission("support:dictData:updateDisabled")
|
||||||
public ResponseDTO<String> updateDictDataDisabled(@PathVariable Long dictDataId) {
|
public ResponseDTO<String> updateDictDataDisabled(@PathVariable Long dictDataId) {
|
||||||
return dictService.updateDictDataDisabled(dictDataId);
|
return dictService.updateDictDataDisabled(dictDataId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "字典数据 添加 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "字典数据 添加 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/dictData/add")
|
@PostMapping("/dict/dictData/add")
|
||||||
@SaCheckPermission("dictData:add")
|
@SaCheckPermission("support:dictData:add")
|
||||||
public ResponseDTO<String> addDictData(@RequestBody @Valid DictDataAddForm addForm) {
|
public ResponseDTO<String> addDictData(@RequestBody @Valid DictDataAddForm addForm) {
|
||||||
return dictService.addDictData(addForm);
|
return dictService.addDictData(addForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "字典数据 更新 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "字典数据 更新 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/dictData/update")
|
@PostMapping("/dict/dictData/update")
|
||||||
@SaCheckPermission("dictData:update")
|
@SaCheckPermission("support:dictData:update")
|
||||||
public ResponseDTO<String> updateDictData(@RequestBody @Valid DictDataUpdateForm updateForm) {
|
public ResponseDTO<String> updateDictData(@RequestBody @Valid DictDataUpdateForm updateForm) {
|
||||||
return dictService.updateDictData(updateForm);
|
return dictService.updateDictData(updateForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "字典数据 批量删除 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "字典数据 批量删除 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/dictData/batchDelete")
|
@PostMapping("/dict/dictData/batchDelete")
|
||||||
@SaCheckPermission("dictData:delete")
|
@SaCheckPermission("support:dictData:delete")
|
||||||
public ResponseDTO<String> batchDeleteDictData(@RequestBody ValidateList<Long> idList) {
|
public ResponseDTO<String> batchDeleteDictData(@RequestBody ValidateList<Long> idList) {
|
||||||
return dictService.batchDeleteDictData(idList);
|
return dictService.batchDeleteDictData(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "字典数据 单个删除 @author 1024创新实验室-主任-卓大")
|
@Operation(summary = "字典数据 单个删除 @author 1024创新实验室-主任-卓大")
|
||||||
@GetMapping("/dict/dictData/delete/{dictDataId}")
|
@GetMapping("/dict/dictData/delete/{dictDataId}")
|
||||||
@SaCheckPermission("dictData:delete")
|
@SaCheckPermission("support:dictData:delete")
|
||||||
public ResponseDTO<String> deleteDictData(@PathVariable Long dictDataId) {
|
public ResponseDTO<String> deleteDictData(@PathVariable Long dictDataId) {
|
||||||
return dictService.deleteDictData(dictDataId);
|
return dictService.deleteDictData(dictDataId);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* 网络安全
|
* 网络安全
|
||||||
*
|
*
|
||||||
* @Author 1024创新实验室-主任:卓大
|
* @Author 1024创新实验室-主任:卓大
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
-->
|
-->
|
||||||
<Configuration status="INFO" monitorInterval="30">
|
<Configuration status="INFO" monitorInterval="30">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="log-directory" value="${sys:project.log-directory}"/>
|
<Property name="log-directory" value="${spring:project.log-directory}"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Appenders>
|
<Appenders>
|
||||||
<Console name="Console" target="SYSTEM_OUT">
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%blue{%d}][%highlight{%-5p}][%t][%cyan{%c{1.}:%L}] %m %n"
|
||||||
|
disableAnsi="false" noConsoleNoAnsi="false"/>
|
||||||
</Console>
|
</Console>
|
||||||
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
||||||
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
||||||
@ -18,7 +19,7 @@
|
|||||||
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -36,7 +37,7 @@
|
|||||||
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -54,7 +55,7 @@
|
|||||||
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -72,7 +73,7 @@
|
|||||||
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||||
@ -86,7 +87,7 @@
|
|||||||
</RollingFile>
|
</RollingFile>
|
||||||
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
||||||
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -101,11 +102,9 @@
|
|||||||
</Appenders>
|
</Appenders>
|
||||||
|
|
||||||
<Loggers>
|
<Loggers>
|
||||||
|
|
||||||
<logger name="com.alibaba.druid.filter.stat.StatFilter" level="ERROR" additivity="false">
|
<logger name="com.alibaba.druid.filter.stat.StatFilter" level="ERROR" additivity="false">
|
||||||
<AppenderRef ref="druidSlowSqlLog"/>
|
<AppenderRef ref="druidSlowSqlLog"/>
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
<Root level="debug">
|
<Root level="debug">
|
||||||
<AppenderRef ref="Console"/>
|
<AppenderRef ref="Console"/>
|
||||||
<AppenderRef ref="debug"/>
|
<AppenderRef ref="debug"/>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="net.lab1024.sa.admin.module.business.oa.bank.BankDao">
|
<mapper namespace="net.lab1024.sa.admin.module.business.oa.bank.dao.BankDao">
|
||||||
<update id="deleteBank">
|
<update id="deleteBank">
|
||||||
UPDATE t_oa_bank
|
UPDATE t_oa_bank
|
||||||
SET deleted_flag = #{deletedFlag}
|
SET deleted_flag = #{deletedFlag}
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<select id="queryPageEmployeeList"
|
<select id="queryPageEmployeeList"
|
||||||
resultType="net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseEmployeeVO">
|
resultType="net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseEmployeeVO">
|
||||||
select
|
select
|
||||||
t_oa_enterprise_employee.*,
|
t_oa_enterprise_employee.enterprise_id,
|
||||||
t_oa_enterprise.enterprise_name,
|
t_oa_enterprise.enterprise_name,
|
||||||
t_employee.*,
|
t_employee.*,
|
||||||
t_employee.actual_name as employeeName
|
t_employee.actual_name as employeeName
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="net.lab1024.sa.admin.module.business.oa.invoice.InvoiceDao">
|
<mapper namespace="net.lab1024.sa.admin.module.business.oa.invoice.dao.InvoiceDao">
|
||||||
<update id="deleteInvoice">
|
<update id="deleteInvoice">
|
||||||
UPDATE t_oa_invoice
|
UPDATE t_oa_invoice
|
||||||
SET deleted_flag = #{deletedFlag}
|
SET deleted_flag = #{deletedFlag}
|
||||||
|
@ -219,7 +219,7 @@
|
|||||||
<select id="queryNoticeViewRecordList" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeViewRecordVO">
|
<select id="queryNoticeViewRecordList" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeViewRecordVO">
|
||||||
select t_notice_view_record.*,
|
select t_notice_view_record.*,
|
||||||
t_employee.actual_name as employeeName,
|
t_employee.actual_name as employeeName,
|
||||||
t_department.name as departmentName
|
t_department.department_name
|
||||||
from t_notice_view_record
|
from t_notice_view_record
|
||||||
left join t_employee on t_employee.employee_id = t_notice_view_record.employee_id
|
left join t_employee on t_employee.employee_id = t_notice_view_record.employee_id
|
||||||
left join t_department on t_department.department_id = t_employee.department_id
|
left join t_department on t_department.department_id = t_employee.department_id
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<select id="listAll" resultType="net.lab1024.sa.admin.module.system.department.domain.vo.DepartmentVO">
|
<select id="listAll" resultType="net.lab1024.sa.admin.module.system.department.domain.vo.DepartmentVO">
|
||||||
SELECT t_department.*,
|
SELECT t_department.*,
|
||||||
t_employee.actual_name as managerName,
|
t_employee.actual_name as managerName,
|
||||||
parent_department.`name` as parentName
|
parent_department.department_name as parentName
|
||||||
FROM t_department
|
FROM t_department
|
||||||
left join t_employee on t_department.manager_id = t_employee.employee_id
|
left join t_employee on t_department.manager_id = t_employee.employee_id
|
||||||
left join t_department parent_department on t_department.parent_id = parent_department.department_id
|
left join t_department parent_department on t_department.parent_id = parent_department.department_id
|
||||||
@ -19,5 +19,16 @@
|
|||||||
WHERE parent_id = #{departmentId}
|
WHERE parent_id = #{departmentId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDepartmentVO"
|
||||||
|
resultType="net.lab1024.sa.admin.module.system.department.domain.vo.DepartmentVO">
|
||||||
|
SELECT t_department.*,
|
||||||
|
t_employee.actual_name as managerName,
|
||||||
|
parent_department.department_name as parentName
|
||||||
|
FROM t_department
|
||||||
|
left join t_employee on t_department.manager_id = t_employee.employee_id
|
||||||
|
left join t_department parent_department on t_department.parent_id = parent_department.department_id
|
||||||
|
where t_department.department_id = #{departmentId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -5,7 +5,7 @@
|
|||||||
<select id="queryEmployee" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
|
<select id="queryEmployee" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
|
||||||
SELECT
|
SELECT
|
||||||
t_employee.*,
|
t_employee.*,
|
||||||
t_department.name AS departmentName
|
t_department.department_name
|
||||||
FROM t_employee
|
FROM t_employee
|
||||||
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
||||||
<where>
|
<where>
|
||||||
@ -169,7 +169,7 @@
|
|||||||
|
|
||||||
<select id="getEmployeeById" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
|
<select id="getEmployeeById" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
|
||||||
SELECT t_employee.*,
|
SELECT t_employee.*,
|
||||||
t_department.name AS departmentName
|
t_department.department_name
|
||||||
FROM t_employee
|
FROM t_employee
|
||||||
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
||||||
where t_employee.employee_id = #{employeeId}
|
where t_employee.employee_id = #{employeeId}
|
||||||
@ -178,7 +178,7 @@
|
|||||||
<select id="selectEmployeeByDisabledAndDeleted" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
|
<select id="selectEmployeeByDisabledAndDeleted" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
|
||||||
SELECT
|
SELECT
|
||||||
t_employee.*,
|
t_employee.*,
|
||||||
t_department.name AS departmentName
|
t_department.department_name
|
||||||
FROM t_employee
|
FROM t_employee
|
||||||
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
||||||
<where>
|
<where>
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
-->
|
-->
|
||||||
<Configuration status="INFO" monitorInterval="30">
|
<Configuration status="INFO" monitorInterval="30">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="log-directory" value="${sys:project.log-directory}"/>
|
<Property name="log-directory" value="${spring:project.log-directory}"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Appenders>
|
<Appenders>
|
||||||
<Console name="Console" target="SYSTEM_OUT">
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
</Console>
|
</Console>
|
||||||
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
||||||
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -54,7 +54,7 @@
|
|||||||
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||||
@ -86,7 +86,7 @@
|
|||||||
</RollingFile>
|
</RollingFile>
|
||||||
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
||||||
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
-->
|
-->
|
||||||
<Configuration status="INFO" monitorInterval="30">
|
<Configuration status="INFO" monitorInterval="30">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="log-directory" value="${sys:project.log-directory}"/>
|
<Property name="log-directory" value="${spring:project.log-directory}"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Appenders>
|
<Appenders>
|
||||||
<Console name="Console" target="SYSTEM_OUT">
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
</Console>
|
</Console>
|
||||||
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
||||||
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -54,7 +54,7 @@
|
|||||||
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||||
@ -86,7 +86,7 @@
|
|||||||
</RollingFile>
|
</RollingFile>
|
||||||
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
||||||
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
-->
|
-->
|
||||||
<Configuration status="INFO" monitorInterval="30">
|
<Configuration status="INFO" monitorInterval="30">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="log-directory" value="${sys:project.log-directory}"/>
|
<Property name="log-directory" value="${spring:project.log-directory}"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Appenders>
|
<Appenders>
|
||||||
<Console name="Console" target="SYSTEM_OUT">
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
</Console>
|
</Console>
|
||||||
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
||||||
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -54,7 +54,7 @@
|
|||||||
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||||
@ -86,7 +86,7 @@
|
|||||||
</RollingFile>
|
</RollingFile>
|
||||||
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
||||||
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
||||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.1024lab</groupId>
|
<groupId>net.lab1024</groupId>
|
||||||
<artifactId>sa-parent</artifactId>
|
<artifactId>sa-parent</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
@ -64,7 +64,6 @@
|
|||||||
<groupId>cn.dev33</groupId>
|
<groupId>cn.dev33</groupId>
|
||||||
<artifactId>sa-token-redis-jackson</artifactId>
|
<artifactId>sa-token-redis-jackson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- sa-token end -->
|
<!-- sa-token end -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -118,19 +117,25 @@
|
|||||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>p6spy</groupId>
|
<groupId>p6spy</groupId>
|
||||||
<artifactId>p6spy</artifactId>
|
<artifactId>p6spy</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- knife4j & SpringDoc -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xingfudeshi</groupId>
|
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>httpclient5</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -159,10 +164,11 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.amazonaws</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>aws-java-sdk-s3</artifactId>
|
<artifactId>s3</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
@ -187,16 +193,6 @@
|
|||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
|
||||||
<artifactId>jjwt</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.auth0</groupId>
|
|
||||||
<artifactId>jwks-rsa</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity-engine-core</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
@ -220,12 +216,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.idev.excel</groupId>
|
<groupId>cn.idev.excel</groupId>
|
||||||
<artifactId>fastexcel</artifactId>
|
<artifactId>fastexcel</artifactId>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -233,11 +223,6 @@
|
|||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-scratchpad</artifactId>
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
@ -245,12 +230,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>ooxml-schemas</artifactId>
|
<artifactId>poi-ooxml-full</artifactId>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -3,6 +3,7 @@ package net.lab1024.sa.base.common.controller;
|
|||||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支撑类业务路由基类
|
* 支撑类业务路由基类
|
||||||
*
|
*
|
||||||
|
@ -2,6 +2,7 @@ package net.lab1024.sa.base.common.domain;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,7 +16,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class UserPermission {
|
public class UserPermission implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限列表
|
* 权限列表
|
||||||
|
@ -20,17 +20,25 @@ public class LongJsonSerializer extends JsonSerializer<Long> {
|
|||||||
|
|
||||||
public static final LongJsonSerializer INSTANCE = new LongJsonSerializer();
|
public static final LongJsonSerializer INSTANCE = new LongJsonSerializer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JS 安全整数范围
|
||||||
|
* 根据 JS Number.MIN_SAFE_INTEGER 与 Number.MAX_SAFE_INTEGER 得来
|
||||||
|
*/
|
||||||
|
private static final long JS_MIN_SAFE_INTEGER = -9007199254740991L;
|
||||||
|
private static final long JS_MAX_SAFE_INTEGER = 9007199254740991L;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(Long value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
|
public void serialize(Long value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
|
||||||
if (null == value) {
|
if (null == value) {
|
||||||
gen.writeNull();
|
gen.writeNull();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// js中最大安全整数16位 Number.MAX_SAFE_INTEGER
|
// 如果超出了 JavaScript 安全整数范围,则序列化为字符串
|
||||||
String longStr = String.valueOf(value);
|
if (value < JS_MIN_SAFE_INTEGER || value > JS_MAX_SAFE_INTEGER) {
|
||||||
if (longStr.length() > 16) {
|
gen.writeString(Long.toString(value));
|
||||||
gen.writeString(longStr);
|
|
||||||
} else {
|
} else {
|
||||||
|
// 否则,序列化为数字
|
||||||
gen.writeNumber(value);
|
gen.writeNumber(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,7 @@ public class SmartPageUtil {
|
|||||||
log.error("《存在SQL注入:》 : {}", sortItem.getColumn());
|
log.error("《存在SQL注入:》 : {}", sortItem.getColumn());
|
||||||
throw new BusinessException("存在SQL注入风险,请联系技术工作人员!");
|
throw new BusinessException("存在SQL注入风险,请联系技术工作人员!");
|
||||||
}
|
}
|
||||||
|
orderItemList.add(sortItem.getIsAsc() ? OrderItem.asc(sortItem.getColumn()) : OrderItem.desc(sortItem.getColumn()));
|
||||||
OrderItem orderItem = new OrderItem();
|
|
||||||
orderItem.setColumn(sortItem.getColumn());
|
|
||||||
orderItem.setAsc(sortItem.getIsAsc());
|
|
||||||
orderItemList.add(orderItem);
|
|
||||||
}
|
}
|
||||||
page.setOrders(orderItemList);
|
page.setOrders(orderItemList);
|
||||||
return page;
|
return page;
|
||||||
|
@ -18,6 +18,9 @@ public class SmartRequestUtil {
|
|||||||
private static final ThreadLocal<RequestUser> REQUEST_THREAD_LOCAL = new ThreadLocal<>();
|
private static final ThreadLocal<RequestUser> REQUEST_THREAD_LOCAL = new ThreadLocal<>();
|
||||||
|
|
||||||
public static void setRequestUser(RequestUser requestUser) {
|
public static void setRequestUser(RequestUser requestUser) {
|
||||||
|
if(requestUser == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
REQUEST_THREAD_LOCAL.set(requestUser);
|
REQUEST_THREAD_LOCAL.set(requestUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
package net.lab1024.sa.base.config;
|
package net.lab1024.sa.base.config;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import net.lab1024.sa.base.module.support.cache.CacheService;
|
import net.lab1024.sa.base.module.support.cache.CacheService;
|
||||||
import net.lab1024.sa.base.module.support.cache.CaffeineCacheServiceImpl;
|
import net.lab1024.sa.base.module.support.cache.CaffeineCacheServiceImpl;
|
||||||
import net.lab1024.sa.base.module.support.cache.RedisCacheServiceImpl;
|
import net.lab1024.sa.base.module.support.cache.RedisCacheServiceImpl;
|
||||||
|
import net.lab1024.sa.base.module.support.redis.CustomRedisCacheManager;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存配置
|
* 缓存配置
|
||||||
*
|
*
|
||||||
* @author zhoumingfa
|
|
||||||
* @date 2025/03/28
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class CacheConfig {
|
public class CacheConfig {
|
||||||
@ -20,6 +26,35 @@ public class CacheConfig {
|
|||||||
private static final String CAFFEINE_CACHE = "caffeine";
|
private static final String CAFFEINE_CACHE = "caffeine";
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisConnectionFactory redisConnectionFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建自定义Redis缓存管理器Bean 整合spring-cache
|
||||||
|
* Redis连接工厂,用于建立与Redis服务器的连接
|
||||||
|
*
|
||||||
|
* @return CacheManager Redis缓存管理器实例
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = REDIS_CACHE)
|
||||||
|
public CacheManager cacheManager() {
|
||||||
|
// 使用非阻塞模式的缓存写入器,适用于大多数高并发场景
|
||||||
|
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory);
|
||||||
|
|
||||||
|
// 构建默认缓存配置
|
||||||
|
RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig()
|
||||||
|
// 禁止缓存 null 值,避免缓存穿透
|
||||||
|
.disableCachingNullValues()
|
||||||
|
.computePrefixWith(name -> "cache:" + name + ":")
|
||||||
|
// 使用 FastJSON 序列化缓存值,支持复杂对象
|
||||||
|
.serializeValuesWith(RedisSerializationContext.SerializationPair
|
||||||
|
.fromSerializer(new GenericFastJsonRedisSerializer()));
|
||||||
|
|
||||||
|
// 返回自定义缓存管理器,支持 cacheName#ttl 格式与永久缓存(#-1)
|
||||||
|
return new CustomRedisCacheManager(redisCacheWriter, defaultCacheConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = REDIS_CACHE)
|
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = REDIS_CACHE)
|
||||||
public CacheService redisCacheService() {
|
public CacheService redisCacheService() {
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
package net.lab1024.sa.base.config;
|
package net.lab1024.sa.base.config;
|
||||||
|
|
||||||
import com.amazonaws.ClientConfiguration;
|
|
||||||
import com.amazonaws.Protocol;
|
|
||||||
import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
|
||||||
import com.amazonaws.auth.BasicAWSCredentials;
|
|
||||||
import com.amazonaws.client.builder.AwsClientBuilder;
|
|
||||||
import com.amazonaws.services.s3.AmazonS3;
|
|
||||||
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.base.module.support.file.service.FileStorageCloudServiceImpl;
|
import net.lab1024.sa.base.module.support.file.service.FileStorageCloudServiceImpl;
|
||||||
import net.lab1024.sa.base.module.support.file.service.FileStorageLocalServiceImpl;
|
import net.lab1024.sa.base.module.support.file.service.FileStorageLocalServiceImpl;
|
||||||
@ -17,6 +10,13 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
|
||||||
|
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
|
||||||
|
import software.amazon.awssdk.regions.Region;
|
||||||
|
import software.amazon.awssdk.services.s3.S3Client;
|
||||||
|
import software.amazon.awssdk.services.s3.S3Configuration;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传 配置
|
* 文件上传 配置
|
||||||
@ -31,6 +31,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class FileConfig implements WebMvcConfigurer {
|
public class FileConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
private static final String HTTPS = "https://";
|
||||||
|
|
||||||
|
private static final String HTTP = "http://";
|
||||||
|
|
||||||
private static final String MODE_CLOUD = "cloud";
|
private static final String MODE_CLOUD = "cloud";
|
||||||
|
|
||||||
private static final String MODE_LOCAL = "local";
|
private static final String MODE_LOCAL = "local";
|
||||||
@ -69,15 +73,17 @@ public class FileConfig implements WebMvcConfigurer {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = MODE_CLOUD)
|
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = MODE_CLOUD)
|
||||||
public AmazonS3 initAmazonS3() {
|
public S3Client initAmazonS3() {
|
||||||
ClientConfiguration clientConfig = new ClientConfiguration();
|
return S3Client.builder()
|
||||||
clientConfig.setProtocol(Protocol.HTTPS);
|
.region(Region.AWS_GLOBAL)
|
||||||
return AmazonS3ClientBuilder.standard()
|
.endpointOverride(URI.create((urlPrefix.startsWith(HTTPS) ? HTTPS : HTTP) + endpoint))
|
||||||
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)))
|
.credentialsProvider(
|
||||||
.withClientConfiguration(clientConfig)
|
StaticCredentialsProvider.create(
|
||||||
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region))
|
AwsBasicCredentials.create(accessKey, secretKey)))
|
||||||
.withPathStyleAccessEnabled(false)
|
.serviceConfiguration(S3Configuration.builder()
|
||||||
.withChunkedEncodingDisabled(true)
|
.pathStyleAccessEnabled(true)
|
||||||
|
.chunkedEncodingEnabled(false)
|
||||||
|
.build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package net.lab1024.sa.base.config;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||||
@ -13,6 +14,8 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
@ -37,6 +40,9 @@ public class JsonConfig {
|
|||||||
builder.serializers(new LocalDateSerializer(DatePattern.NORM_DATE_FORMAT.getDateTimeFormatter()));
|
builder.serializers(new LocalDateSerializer(DatePattern.NORM_DATE_FORMAT.getDateTimeFormatter()));
|
||||||
builder.serializers(new LocalDateTimeSerializer(DatePattern.NORM_DATETIME_FORMAT.getDateTimeFormatter()));
|
builder.serializers(new LocalDateTimeSerializer(DatePattern.NORM_DATETIME_FORMAT.getDateTimeFormatter()));
|
||||||
builder.serializerByType(Long.class, LongJsonSerializer.INSTANCE);
|
builder.serializerByType(Long.class, LongJsonSerializer.INSTANCE);
|
||||||
|
builder.serializerByType(Long.TYPE, LongJsonSerializer.INSTANCE);
|
||||||
|
builder.serializerByType(BigInteger.class, ToStringSerializer.instance);
|
||||||
|
builder.serializerByType(BigDecimal.class, ToStringSerializer.instance);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package net.lab1024.sa.base.config;
|
package net.lab1024.sa.base.config;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.lab1024.sa.base.common.constant.StringConst;
|
import net.lab1024.sa.base.common.constant.StringConst;
|
||||||
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
||||||
import net.lab1024.sa.base.module.support.repeatsubmit.RepeatSubmitAspect;
|
import net.lab1024.sa.base.module.support.repeatsubmit.RepeatSubmitAspect;
|
||||||
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitRedisTicket;
|
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitRedisTicket;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重复提交配置
|
* 重复提交配置
|
||||||
@ -22,22 +23,22 @@ import org.springframework.data.redis.core.ValueOperations;
|
|||||||
public class RepeatSubmitConfig {
|
public class RepeatSubmitConfig {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ValueOperations<String, String> valueOperations;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RepeatSubmitAspect repeatSubmitAspect() {
|
public RepeatSubmitAspect repeatSubmitAspect() {
|
||||||
RepeatSubmitRedisTicket caffeineTicket = new RepeatSubmitRedisTicket(valueOperations, this::ticket);
|
RepeatSubmitRedisTicket ticket = new RepeatSubmitRedisTicket(redisTemplate, this::ticket);
|
||||||
return new RepeatSubmitAspect(caffeineTicket);
|
return new RepeatSubmitAspect(ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指明某个用户的凭证
|
* 获取指明某个用户的凭证
|
||||||
*/
|
*/
|
||||||
private String ticket(String servletPath) {
|
private String ticket(HttpServletRequest request) {
|
||||||
Long userId = SmartRequestUtil.getRequestUserId();
|
Long userId = SmartRequestUtil.getRequestUserId();
|
||||||
if (null == userId) {
|
if (null == userId) {
|
||||||
return StringConst.EMPTY;
|
return StringConst.EMPTY;
|
||||||
}
|
}
|
||||||
return servletPath + "_" + userId;
|
return request.getServletPath() + "_" + userId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
package net.lab1024.sa.base.config;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||||
|
import org.apache.hc.client5.http.classic.HttpClient;
|
||||||
|
import org.apache.hc.client5.http.config.TlsConfig;
|
||||||
|
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||||
|
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
|
||||||
|
import org.apache.hc.core5.util.TimeValue;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
|
import org.springframework.web.client.RestClient;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http请求配置
|
||||||
|
*
|
||||||
|
* @Author 1024创新实验室: 卓大
|
||||||
|
* @Date 2025-07-26 21:22:12
|
||||||
|
* @Wechat zhuoda1024
|
||||||
|
* @Email lab1024@163.com
|
||||||
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RestClientConfig {
|
||||||
|
|
||||||
|
@Value("${http.pool.max-total}")
|
||||||
|
private Integer maxTotal;
|
||||||
|
|
||||||
|
@Value("${http.pool.connect-timeout}")
|
||||||
|
private Integer connectTimeout;
|
||||||
|
|
||||||
|
@Value("${http.pool.read-timeout}")
|
||||||
|
private Integer readTimeout;
|
||||||
|
|
||||||
|
@Value("${http.pool.write-timeout}")
|
||||||
|
private Integer writeTimeout;
|
||||||
|
|
||||||
|
@Value("${http.pool.keep-alive}")
|
||||||
|
private Integer keepAlive;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestClient restClient() {
|
||||||
|
|
||||||
|
HttpComponentsClientHttpRequestFactory factory =
|
||||||
|
new HttpComponentsClientHttpRequestFactory();
|
||||||
|
factory.setConnectTimeout(connectTimeout);
|
||||||
|
factory.setConnectionRequestTimeout(connectTimeout);
|
||||||
|
factory.setReadTimeout(readTimeout);
|
||||||
|
|
||||||
|
PoolingHttpClientConnectionManager cm =
|
||||||
|
new PoolingHttpClientConnectionManager();
|
||||||
|
|
||||||
|
cm.setMaxTotal(this.maxTotal);
|
||||||
|
cm.setDefaultTlsConfig(TlsConfig.DEFAULT);
|
||||||
|
|
||||||
|
HttpClient httpClient = HttpClients.custom()
|
||||||
|
.setConnectionManager(cm)
|
||||||
|
.setKeepAliveStrategy((response, context) -> TimeValue.of(this.keepAlive, TimeUnit.MICROSECONDS))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
factory.setHttpClient(httpClient);
|
||||||
|
|
||||||
|
return RestClient.builder()
|
||||||
|
.requestFactory(factory)
|
||||||
|
.messageConverters(converters())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HttpMessageConverter<?>> converters() {
|
||||||
|
List<HttpMessageConverter<?>> converters = new ArrayList<>();
|
||||||
|
HttpMessageConverter<?> converter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
|
||||||
|
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||||
|
List<MediaType> fastMediaTypes = new ArrayList<>();
|
||||||
|
fastMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
fastMediaTypes.add(MediaType.APPLICATION_JSON);
|
||||||
|
fastConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||||
|
converters.add(converter);
|
||||||
|
converters.add(fastConverter);
|
||||||
|
return converters;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,130 +0,0 @@
|
|||||||
package net.lab1024.sa.base.config;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|
||||||
import okhttp3.ConnectionPool;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
|
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.security.KeyManagementException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http请求配置
|
|
||||||
*
|
|
||||||
* @Author 1024创新实验室: 罗伊
|
|
||||||
* @Date 2022-05-30 21:22:12
|
|
||||||
* @Wechat zhuoda1024
|
|
||||||
* @Email lab1024@163.com
|
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class RestTemplateConfig {
|
|
||||||
|
|
||||||
@Value("${http.pool.max-total}")
|
|
||||||
private Integer maxTotal;
|
|
||||||
|
|
||||||
@Value("${http.pool.connect-timeout}")
|
|
||||||
private Integer connectTimeout;
|
|
||||||
|
|
||||||
@Value("${http.pool.read-timeout}")
|
|
||||||
private Integer readTimeout;
|
|
||||||
|
|
||||||
@Value("${http.pool.write-timeout}")
|
|
||||||
private Integer writeTimeout;
|
|
||||||
|
|
||||||
@Value("${http.pool.keep-alive}")
|
|
||||||
private Integer keepAlive;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RestTemplate restTemplate() {
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
restTemplate.setRequestFactory(this.clientHttpRequestFactory());
|
|
||||||
List<HttpMessageConverter<?>> messageConverterList = restTemplate.getMessageConverters();
|
|
||||||
messageConverterList.add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
|
||||||
messageConverterList.addAll(this.converters());
|
|
||||||
return restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<HttpMessageConverter<?>> converters() {
|
|
||||||
List<HttpMessageConverter<?>> converters = new ArrayList<>();
|
|
||||||
HttpMessageConverter<?> converter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
|
|
||||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
|
||||||
List<MediaType> fastMediaTypes = new ArrayList<>();
|
|
||||||
fastMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
|
|
||||||
fastMediaTypes.add(MediaType.APPLICATION_JSON);
|
|
||||||
fastConverter.setSupportedMediaTypes(fastMediaTypes);
|
|
||||||
converters.add(converter);
|
|
||||||
converters.add(fastConverter);
|
|
||||||
return converters;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public OkHttp3ClientHttpRequestFactory clientHttpRequestFactory() {
|
|
||||||
return new OkHttp3ClientHttpRequestFactory(httpClientBuilder());
|
|
||||||
}
|
|
||||||
|
|
||||||
public OkHttpClient httpClientBuilder() {
|
|
||||||
return new OkHttpClient.Builder()
|
|
||||||
.retryOnConnectionFailure(true)
|
|
||||||
.connectionPool(this.pool())
|
|
||||||
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
|
||||||
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
|
|
||||||
.writeTimeout(writeTimeout, TimeUnit.MILLISECONDS)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConnectionPool pool() {
|
|
||||||
return new ConnectionPool(maxTotal, keepAlive, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public X509TrustManager x509TrustManager() {
|
|
||||||
return new X509TrustManager() {
|
|
||||||
@Override
|
|
||||||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return new X509Certificate[0];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public SSLSocketFactory sslSocketFactory() {
|
|
||||||
try {
|
|
||||||
//信任任何链接
|
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
|
||||||
sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom());
|
|
||||||
return sslContext.getSocketFactory();
|
|
||||||
} catch (NoSuchAlgorithmException | KeyManagementException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -12,6 +12,7 @@ import net.lab1024.sa.base.common.constant.RequestHeaderConst;
|
|||||||
import net.lab1024.sa.base.common.swagger.SmartOperationCustomizer;
|
import net.lab1024.sa.base.common.swagger.SmartOperationCustomizer;
|
||||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
|
||||||
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
|
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
|
||||||
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
|
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
|
||||||
import org.springdoc.core.models.GroupedOpenApi;
|
import org.springdoc.core.models.GroupedOpenApi;
|
||||||
@ -24,6 +25,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -80,6 +83,21 @@ public class SwaggerConfig {
|
|||||||
.addSecuritySchemes(RequestHeaderConst.TOKEN, new SecurityScheme().scheme("Bearer").description("请输入token,格式为[Bearer xxxxxxxx]").type(SecurityScheme.Type.APIKEY).in(SecurityScheme.In.HEADER).name(RequestHeaderConst.TOKEN));
|
.addSecuritySchemes(RequestHeaderConst.TOKEN, new SecurityScheme().scheme("Bearer").description("请输入token,格式为[Bearer xxxxxxxx]").type(SecurityScheme.Type.APIKEY).in(SecurityScheme.In.HEADER).name(RequestHeaderConst.TOKEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public GlobalOpenApiCustomizer orderGlobalOpenApiCustomizer() {
|
||||||
|
return openApi -> {
|
||||||
|
// 全局添加鉴权参数
|
||||||
|
if(openApi.getPaths()!=null){
|
||||||
|
openApi.getPaths().forEach((s, pathItem) -> {
|
||||||
|
// 为所有接口添加鉴权
|
||||||
|
pathItem.readOperations().forEach(operation -> {
|
||||||
|
operation.addSecurityItem(new SecurityRequirement().addList(HttpHeaders.AUTHORIZATION));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public GroupedOpenApi businessApi() {
|
public GroupedOpenApi businessApi() {
|
||||||
return GroupedOpenApi.builder()
|
return GroupedOpenApi.builder()
|
||||||
@ -122,11 +140,11 @@ public class SwaggerConfig {
|
|||||||
Optional<JavadocProvider> javadocProvider) {
|
Optional<JavadocProvider> javadocProvider) {
|
||||||
List<ServerBaseUrlCustomizer> list = Lists.newArrayList(new ServerBaseUrlCustomizer() {
|
List<ServerBaseUrlCustomizer> list = Lists.newArrayList(new ServerBaseUrlCustomizer() {
|
||||||
@Override
|
@Override
|
||||||
public String customize(String baseUrl) {
|
public String customize(String serverBaseUrl, HttpRequest request) {
|
||||||
if (StringUtils.isNotBlank(serverBaseUrl)) {
|
if (StringUtils.isNotBlank(serverBaseUrl)) {
|
||||||
return serverBaseUrl;
|
return serverBaseUrl;
|
||||||
}
|
}
|
||||||
return baseUrl;
|
return serverBaseUrl;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return new OpenAPIService(openAPI, securityParser, springDocConfigProperties,
|
return new OpenAPIService(openAPI, securityParser, springDocConfigProperties,
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
package net.lab1024.sa.base.module.support.cache;
|
package net.lab1024.sa.base.module.support.cache;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import net.lab1024.sa.base.constant.ReloadConst;
|
|
||||||
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
|
|
||||||
import org.springframework.cache.caffeine.CaffeineCache;
|
|
||||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存服务
|
* 缓存服务
|
||||||
|
@ -3,10 +3,10 @@ package net.lab1024.sa.base.module.support.captcha;
|
|||||||
import cn.hutool.captcha.CaptchaUtil;
|
import cn.hutool.captcha.CaptchaUtil;
|
||||||
import cn.hutool.captcha.LineCaptcha;
|
import cn.hutool.captcha.LineCaptcha;
|
||||||
import cn.hutool.core.img.ImgUtil;
|
import cn.hutool.core.img.ImgUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.base.common.constant.StringConst;
|
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.common.domain.SystemEnvironment;
|
import net.lab1024.sa.base.common.domain.SystemEnvironment;
|
||||||
import net.lab1024.sa.base.constant.RedisKeyConst;
|
import net.lab1024.sa.base.constant.RedisKeyConst;
|
||||||
@ -18,7 +18,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图形验证码 服务
|
* 图形验证码 服务
|
||||||
@ -70,7 +69,7 @@ public class CaptchaService {
|
|||||||
* 图片 base64格式
|
* 图片 base64格式
|
||||||
*/
|
*/
|
||||||
// uuid 唯一标识
|
// uuid 唯一标识
|
||||||
String uuid = UUID.randomUUID().toString().replace("-", StringConst.EMPTY);
|
String uuid = IdUtil.fastSimpleUUID();
|
||||||
|
|
||||||
CaptchaVO captchaVO = new CaptchaVO();
|
CaptchaVO captchaVO = new CaptchaVO();
|
||||||
captchaVO.setCaptchaUuid(uuid);
|
captchaVO.setCaptchaUuid(uuid);
|
||||||
|
@ -28,7 +28,7 @@ public class ChangeLogEntity {
|
|||||||
/**
|
/**
|
||||||
* 版本
|
* 版本
|
||||||
*/
|
*/
|
||||||
private String version;
|
private String updateVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]
|
* 更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]
|
||||||
|
@ -23,7 +23,7 @@ public class ChangeLogAddForm {
|
|||||||
|
|
||||||
@Schema(description = "版本", required = true)
|
@Schema(description = "版本", required = true)
|
||||||
@NotBlank(message = "版本 不能为空")
|
@NotBlank(message = "版本 不能为空")
|
||||||
private String version;
|
private String updateVersion;
|
||||||
|
|
||||||
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
||||||
@CheckEnum(value = ChangeLogTypeEnum.class, message = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复] 错误", required = true)
|
@CheckEnum(value = ChangeLogTypeEnum.class, message = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复] 错误", required = true)
|
||||||
|
@ -27,7 +27,7 @@ public class ChangeLogUpdateForm {
|
|||||||
|
|
||||||
@Schema(description = "版本", required = true)
|
@Schema(description = "版本", required = true)
|
||||||
@NotBlank(message = "版本 不能为空")
|
@NotBlank(message = "版本 不能为空")
|
||||||
private String version;
|
private String updateVersion;
|
||||||
|
|
||||||
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
||||||
@CheckEnum(value = ChangeLogTypeEnum.class, message = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复] 错误", required = true)
|
@CheckEnum(value = ChangeLogTypeEnum.class, message = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复] 错误", required = true)
|
||||||
|
@ -23,7 +23,7 @@ public class ChangeLogVO {
|
|||||||
private Long changeLogId;
|
private Long changeLogId;
|
||||||
|
|
||||||
@Schema(description = "版本")
|
@Schema(description = "版本")
|
||||||
private String version;
|
private String updateVersion;
|
||||||
|
|
||||||
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
@ -44,7 +44,7 @@ public class ChangeLogService {
|
|||||||
* 添加
|
* 添加
|
||||||
*/
|
*/
|
||||||
public synchronized ResponseDTO<String> add(ChangeLogAddForm addForm) {
|
public synchronized ResponseDTO<String> add(ChangeLogAddForm addForm) {
|
||||||
ChangeLogEntity existVersion = changeLogDao.selectByVersion(addForm.getVersion());
|
ChangeLogEntity existVersion = changeLogDao.selectByVersion(addForm.getUpdateVersion());
|
||||||
if (existVersion != null) {
|
if (existVersion != null) {
|
||||||
return ResponseDTO.userErrorParam("此版本已经存在");
|
return ResponseDTO.userErrorParam("此版本已经存在");
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ public class ChangeLogService {
|
|||||||
* 更新
|
* 更新
|
||||||
*/
|
*/
|
||||||
public synchronized ResponseDTO<String> update(ChangeLogUpdateForm updateForm) {
|
public synchronized ResponseDTO<String> update(ChangeLogUpdateForm updateForm) {
|
||||||
ChangeLogEntity existVersion = changeLogDao.selectByVersion(updateForm.getVersion());
|
ChangeLogEntity existVersion = changeLogDao.selectByVersion(updateForm.getUpdateVersion());
|
||||||
if (existVersion != null && !updateForm.getChangeLogId().equals(existVersion.getChangeLogId())) {
|
if (existVersion != null && !updateForm.getChangeLogId().equals(existVersion.getChangeLogId())) {
|
||||||
return ResponseDTO.userErrorParam("此版本已经存在");
|
return ResponseDTO.userErrorParam("此版本已经存在");
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,6 @@ package net.lab1024.sa.base.module.support.codegenerator.constant;
|
|||||||
*/
|
*/
|
||||||
public class CodeGeneratorConstant {
|
public class CodeGeneratorConstant {
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键
|
|
||||||
*/
|
|
||||||
public final static String PRIMARY_KEY = "PRI";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自增
|
|
||||||
*/
|
|
||||||
public final static String AUTO_INCREMENT = "auto_increment";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认逻辑删除字段名称
|
* 默认逻辑删除字段名称
|
||||||
*/
|
*/
|
||||||
|
@ -23,20 +23,26 @@ public class TableColumnVO {
|
|||||||
@Schema(description = "列描述")
|
@Schema(description = "列描述")
|
||||||
private String columnComment;
|
private String columnComment;
|
||||||
|
|
||||||
@Schema(description = "columnKey")
|
|
||||||
private String columnKey;
|
|
||||||
|
|
||||||
@Schema(description = "extra")
|
|
||||||
private String extra;
|
|
||||||
|
|
||||||
@Schema(description = "是否为空")
|
|
||||||
private String isNullable;
|
|
||||||
|
|
||||||
@Schema(description = "数据类型varchar")
|
@Schema(description = "数据类型varchar")
|
||||||
private String dataType;
|
private String dataType;
|
||||||
|
|
||||||
@Schema(description = "列类型varchar(50)")
|
@Schema(description = "是否为空")
|
||||||
private String columnType;
|
private Boolean nullableFlag;
|
||||||
|
|
||||||
|
@Schema(description = "是否为主键")
|
||||||
|
private Boolean primaryKeyFlag;
|
||||||
|
|
||||||
|
@Schema(description = "是否递增")
|
||||||
|
private Boolean autoIncreaseFlag;
|
||||||
|
|
||||||
|
// --------------- 临时字段 -------------------
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private String columnKey;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private String isNullable;
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,6 @@ public class TableVO {
|
|||||||
@Schema(description = "表备注")
|
@Schema(description = "表备注")
|
||||||
private String tableComment;
|
private String tableComment;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
@Schema(description = "更新时间")
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
@Schema(description = "配置时间")
|
@Schema(description = "配置时间")
|
||||||
private LocalDateTime configTime;
|
private LocalDateTime configTime;
|
||||||
|
|
||||||
|
@ -40,6 +40,12 @@ import java.util.Optional;
|
|||||||
@Service
|
@Service
|
||||||
public class CodeGeneratorService {
|
public class CodeGeneratorService {
|
||||||
|
|
||||||
|
private static final String COLUMN_NO_NULLABLE_IDENTIFY = "NO";
|
||||||
|
|
||||||
|
private static final String COLUMN_PRIMARY_KEY = "PRI";
|
||||||
|
|
||||||
|
private static final String COLUMN_AUTO_INCREASE = "auto_increment";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CodeGeneratorDao codeGeneratorDao;
|
private CodeGeneratorDao codeGeneratorDao;
|
||||||
|
|
||||||
@ -57,7 +63,13 @@ public class CodeGeneratorService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<TableColumnVO> getTableColumns(String tableName) {
|
public List<TableColumnVO> getTableColumns(String tableName) {
|
||||||
return codeGeneratorDao.selectTableColumn(tableName);
|
List<TableColumnVO> tableColumns = codeGeneratorDao.selectTableColumn(tableName);
|
||||||
|
for (TableColumnVO tableColumn : tableColumns) {
|
||||||
|
tableColumn.setNullableFlag(!COLUMN_NO_NULLABLE_IDENTIFY.equalsIgnoreCase(tableColumn.getIsNullable()));
|
||||||
|
tableColumn.setPrimaryKeyFlag(COLUMN_PRIMARY_KEY.equalsIgnoreCase(tableColumn.getColumnKey()));
|
||||||
|
tableColumn.setAutoIncreaseFlag(SmartStringUtil.isNotEmpty(tableColumn.getExtra()) && COLUMN_AUTO_INCREASE.equalsIgnoreCase(tableColumn.getExtra()));
|
||||||
|
}
|
||||||
|
return tableColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +162,7 @@ public class CodeGeneratorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 校验表必须有主键
|
// 校验表必须有主键
|
||||||
if(!tableColumns.stream().filter( e -> "PRI".equalsIgnoreCase(e.getColumnKey())).findAny().isPresent()){
|
if (tableColumns.stream().noneMatch(e -> COLUMN_PRIMARY_KEY.equalsIgnoreCase(e.getColumnKey()))) {
|
||||||
return ResponseDTO.userErrorParam("表必须有主键,请联系后端查看下数据库表结构");
|
return ResponseDTO.userErrorParam("表必须有主键,请联系后端查看下数据库表结构");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +211,7 @@ public class CodeGeneratorService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载代码
|
* 下载代码
|
||||||
|
*
|
||||||
* @param tableName
|
* @param tableName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ZipUtil;
|
import cn.hutool.core.util.ZipUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
@ -33,9 +34,11 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,10 +78,15 @@ public class CodeGeneratorTemplateService {
|
|||||||
map.put("js/const.js", new ConstVariableService());
|
map.put("js/const.js", new ConstVariableService());
|
||||||
map.put("js/list.vue", new ListVariableService());
|
map.put("js/list.vue", new ListVariableService());
|
||||||
map.put("js/form.vue", new FormVariableService());
|
map.put("js/form.vue", new FormVariableService());
|
||||||
|
// ts前端
|
||||||
|
map.put("ts/api.ts", new ApiVariableService());
|
||||||
|
map.put("ts/const.ts", new ConstVariableService());
|
||||||
|
map.put("ts/list.vue", new ListVariableService());
|
||||||
|
map.put("ts/form.vue", new FormVariableService());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zipGeneratedFiles(OutputStream outputStream, String tableName, CodeGeneratorConfigEntity codeGeneratorConfigEntity) {
|
public void zipGeneratedFiles(OutputStream outputStream, String tableName, CodeGeneratorConfigEntity codeGeneratorConfigEntity) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = IdUtil.fastSimpleUUID();
|
||||||
File dir = new File(uuid);
|
File dir = new File(uuid);
|
||||||
|
|
||||||
// 1、生产文件
|
// 1、生产文件
|
||||||
@ -159,7 +167,7 @@ public class CodeGeneratorTemplateService {
|
|||||||
CodeDelete deleteInfo = JSON.parseObject(codeGeneratorConfigEntity.getDeleteInfo(), CodeDelete.class);
|
CodeDelete deleteInfo = JSON.parseObject(codeGeneratorConfigEntity.getDeleteInfo(), CodeDelete.class);
|
||||||
List<CodeQueryField> queryFields = JSONArray.parseArray(codeGeneratorConfigEntity.getQueryFields(), CodeQueryField.class);
|
List<CodeQueryField> queryFields = JSONArray.parseArray(codeGeneratorConfigEntity.getQueryFields(), CodeQueryField.class);
|
||||||
List<CodeTableField> tableFields = JSONArray.parseArray(codeGeneratorConfigEntity.getTableFields(), CodeTableField.class);
|
List<CodeTableField> tableFields = JSONArray.parseArray(codeGeneratorConfigEntity.getTableFields(), CodeTableField.class);
|
||||||
tableFields.stream().forEach(e -> e.setWidth(e.getWidth() == null ? 0 : e.getWidth()));
|
tableFields.forEach(e -> e.setWidth(e.getWidth() == null ? 0 : e.getWidth()));
|
||||||
|
|
||||||
CodeGeneratorConfigForm form = CodeGeneratorConfigForm.builder().basic(basic).fields(fields).insertAndUpdate(insertAndUpdate).deleteInfo(deleteInfo).queryFields(queryFields).tableFields(tableFields).deleteInfo(deleteInfo).build();
|
CodeGeneratorConfigForm form = CodeGeneratorConfigForm.builder().basic(basic).fields(fields).insertAndUpdate(insertAndUpdate).deleteInfo(deleteInfo).queryFields(queryFields).tableFields(tableFields).deleteInfo(deleteInfo).build();
|
||||||
form.setTableName(tableName);
|
form.setTableName(tableName);
|
||||||
|
@ -64,8 +64,7 @@ public abstract class CodeGenerateBaseVariableService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fields.stream().filter(e -> columnName.equals(e.getColumnName()))
|
return fields.stream().filter(e -> SmartStringUtil.equals(columnName, e.getColumnName())).findFirst().orElse(null);
|
||||||
.findFirst().get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ public abstract class CodeGenerateBaseVariableService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CodeInsertAndUpdateField field = first.get();
|
CodeInsertAndUpdateField field = first.get();
|
||||||
return SmartStringUtil.equals(field.getFrontComponent(), CodeFrontComponentEnum.FILE_UPLOAD.getValue());
|
return CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,8 +113,7 @@ public abstract class CodeGenerateBaseVariableService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<CodeField> first = fields.stream().filter(e -> columnName.equals(e.getColumnName())).findFirst();
|
return fields.stream().filter(e -> columnName.equals(e.getColumnName())).findFirst().orElse(null);
|
||||||
return first.orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,9 +103,9 @@ public class AddFormVariableService extends CodeGenerateBaseVariableService {
|
|||||||
|
|
||||||
//字典
|
//字典
|
||||||
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
||||||
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictValueVoDeserializer.class)");
|
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictDataDeserializer.class)");
|
||||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
||||||
packageList.add("import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;");
|
packageList.add("import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;");
|
||||||
}
|
}
|
||||||
|
|
||||||
//文件上传
|
//文件上传
|
||||||
|
@ -3,10 +3,8 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable.backen
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
|
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeInsertAndUpdateField;
|
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryField;
|
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryField;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -106,9 +106,9 @@ public class QueryFormVariableService extends CodeGenerateBaseVariableService {
|
|||||||
case DICT:
|
case DICT:
|
||||||
codeField = getCodeFieldByColumnName(field.getColumnNameList().get(0), form);
|
codeField = getCodeFieldByColumnName(field.getColumnNameList().get(0), form);
|
||||||
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
||||||
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictValueVoDeserializer.class)");
|
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictDataDeserializer.class)");
|
||||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
||||||
packageList.add("import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;");
|
packageList.add("import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;");
|
||||||
}
|
}
|
||||||
finalFieldMap.put("javaType", "String");
|
finalFieldMap.put("javaType", "String");
|
||||||
default:
|
default:
|
||||||
|
@ -118,9 +118,9 @@ public class UpdateFormVariableService extends CodeGenerateBaseVariableService {
|
|||||||
|
|
||||||
//字典
|
//字典
|
||||||
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
||||||
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictValueVoDeserializer.class)");
|
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictDataDeserializer.class)");
|
||||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
||||||
packageList.add("import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;");
|
packageList.add("import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;");
|
||||||
}
|
}
|
||||||
|
|
||||||
//文件上传
|
//文件上传
|
||||||
|
@ -67,6 +67,7 @@ public class FormVariableService extends CodeGenerateBaseVariableService {
|
|||||||
|
|
||||||
if (CodeFrontComponentEnum.DICT_SELECT.equalsValue(field.getFrontComponent())) {
|
if (CodeFrontComponentEnum.DICT_SELECT.equalsValue(field.getFrontComponent())) {
|
||||||
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
|
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
|
||||||
|
frontImportSet.add("import { DICT_CODE_ENUM } from '/@/constants/support/dict-const.js';");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent())) {
|
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent())) {
|
||||||
|
@ -2,10 +2,14 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable.front;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
|
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||||
|
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeFrontComponentEnum;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
|
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
|
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
|
||||||
|
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeInsertAndUpdateField;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryField;
|
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryField;
|
||||||
|
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeTableField;
|
||||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -29,34 +33,81 @@ public class ListVariableService extends CodeGenerateBaseVariableService {
|
|||||||
public Map<String, Object> getInjectVariablesMap(CodeGeneratorConfigForm form) {
|
public Map<String, Object> getInjectVariablesMap(CodeGeneratorConfigForm form) {
|
||||||
Map<String, Object> variablesMap = new HashMap<>();
|
Map<String, Object> variablesMap = new HashMap<>();
|
||||||
|
|
||||||
List<Map<String, Object>> variableList = new ArrayList<>();
|
|
||||||
List<CodeQueryField> queryFields = form.getQueryFields();
|
|
||||||
HashSet<String> frontImportSet = new HashSet<>();
|
HashSet<String> frontImportSet = new HashSet<>();
|
||||||
frontImportSet.add("import " + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, form.getBasic().getModuleName()) + "Form from './" + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getBasic().getModuleName()) + "-form.vue';");
|
frontImportSet.add("import " + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, form.getBasic().getModuleName()) + "Form from './" + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getBasic().getModuleName()) + "-form.vue';");
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
List<Map<String, Object>> queryVariable = new ArrayList<>();
|
||||||
|
List<CodeQueryField> queryFields = form.getQueryFields();
|
||||||
|
|
||||||
for (CodeQueryField queryField : queryFields) {
|
for (CodeQueryField queryField : queryFields) {
|
||||||
Map<String, Object> objectMap = BeanUtil.beanToMap(queryField);
|
Map<String, Object> objectMap = BeanUtil.beanToMap(queryField);
|
||||||
|
|
||||||
CodeField codeField = getCodeFieldByColumnName(queryField.getColumnNameList().get(0), form);
|
CodeField codeField = getCodeFieldByColumnName(queryField.getColumnNameList().get(0), form);
|
||||||
objectMap.put("frontEnumName", codeField.getEnumName());
|
|
||||||
objectMap.put("dict", codeField.getDict());
|
|
||||||
|
|
||||||
if(CodeQueryFieldQueryTypeEnum.ENUM.equalsValue(queryField.getQueryTypeEnum())){
|
if (CodeQueryFieldQueryTypeEnum.ENUM.equalsValue(queryField.getQueryTypeEnum()) && SmartStringUtil.isNotBlank(codeField.getEnumName())) {
|
||||||
|
String upperUnderscoreEnum = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codeField.getEnumName());
|
||||||
|
objectMap.put("frontEnumName", upperUnderscoreEnum);
|
||||||
frontImportSet.add("import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';");
|
frontImportSet.add("import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())) {
|
if (CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())) {
|
||||||
|
objectMap.put("dict", codeField.getDict());
|
||||||
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
|
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodeQueryFieldQueryTypeEnum.DATE_RANGE.equalsValue(queryField.getQueryTypeEnum())) {
|
if (CodeQueryFieldQueryTypeEnum.DATE_RANGE.equalsValue(queryField.getQueryTypeEnum())) {
|
||||||
frontImportSet.add("import { defaultTimeRanges } from '/@/lib/default-time-ranges';");
|
frontImportSet.add("import { defaultTimeRanges } from '/@/lib/default-time-ranges';");
|
||||||
}
|
}
|
||||||
variableList.add(objectMap);
|
queryVariable.add(objectMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
variablesMap.put("queryFields",variableList);
|
|
||||||
|
// 表格列表
|
||||||
|
List<Map<String, Object>> listVariable = new ArrayList<>();
|
||||||
|
// 过滤掉不显示的字段
|
||||||
|
List<CodeTableField> tableFields = form.getTableFields().stream().filter(CodeTableField::getShowFlag).toList();
|
||||||
|
|
||||||
|
for (CodeTableField tableField : tableFields) {
|
||||||
|
Map<String, Object> objectMap = BeanUtil.beanToMap(tableField);
|
||||||
|
objectMap.put("fieldName", tableField.getFieldName());
|
||||||
|
|
||||||
|
CodeField codeField = getCodeFieldByColumnName(tableField.getColumnName(), form);
|
||||||
|
if (codeField == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否存在枚举
|
||||||
|
if (SmartStringUtil.isNotBlank(codeField.getEnumName())) {
|
||||||
|
String upperUnderscoreEnum = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, codeField.getEnumName());
|
||||||
|
objectMap.put("frontEnumPlugin", "$smartEnumPlugin.getDescByValue('" + upperUnderscoreEnum + "', text)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否存在字典
|
||||||
|
if (SmartStringUtil.isNotBlank(codeField.getDict())) {
|
||||||
|
objectMap.put("dict", codeField.getDict());
|
||||||
|
frontImportSet.add("import { DICT_CODE_ENUM } from '/@/constants/support/dict-const.js';");
|
||||||
|
frontImportSet.add("import DictLabel from '/@/components/support/dict-label/index.vue';");
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeInsertAndUpdateField codeInsertAndUpdateField = form.getInsertAndUpdate().getFieldList().stream().filter(e -> SmartStringUtil.equals(tableField.getColumnName(), e.getColumnName())).findFirst().orElse(null);
|
||||||
|
if (codeInsertAndUpdateField == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否存在上传组件
|
||||||
|
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(codeInsertAndUpdateField.getFrontComponent())) {
|
||||||
|
objectMap.put("frontComponent", codeInsertAndUpdateField.getFrontComponent());
|
||||||
|
frontImportSet.add("import FilePreview from '/@/components/support/file-preview/index.vue';");
|
||||||
|
}
|
||||||
|
|
||||||
|
listVariable.add(objectMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
variablesMap.put("queryFields", queryVariable);
|
||||||
|
variablesMap.put("listFields", listVariable);
|
||||||
variablesMap.put("frontImportList", new ArrayList<>(frontImportSet));
|
variablesMap.put("frontImportList", new ArrayList<>(frontImportSet));
|
||||||
|
|
||||||
return variablesMap;
|
return variablesMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,16 @@ public class DataTracerChangeContentService {
|
|||||||
return "【原数据】:<br/>" + oldContent + "<br/>" + "【新数据】:<br/>" + newContent;
|
return "【原数据】:<br/>" + oldContent + "<br/>" + "【新数据】:<br/>" + newContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析批量bean的内容
|
||||||
|
*
|
||||||
|
* @param objectList 对象列表
|
||||||
|
* @return 单个内容
|
||||||
|
*/
|
||||||
|
public <T> String getChangeContent(List<T> objectList) {
|
||||||
|
return this.getObjectListContent(objectList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取一个对象的内容信息
|
* 获取一个对象的内容信息
|
||||||
*
|
*
|
||||||
|
@ -3,6 +3,7 @@ package net.lab1024.sa.base.module.support.dict.domain.vo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,7 +15,7 @@ import java.time.LocalDateTime;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class DictDataVO {
|
public class DictDataVO implements Serializable {
|
||||||
|
|
||||||
@Schema(description = "字典数据id")
|
@Schema(description = "字典数据id")
|
||||||
private Long dictDataId;
|
private Long dictDataId;
|
||||||
@ -25,6 +26,12 @@ public class DictDataVO {
|
|||||||
@Schema(description = "字典编码")
|
@Schema(description = "字典编码")
|
||||||
private String dictCode;
|
private String dictCode;
|
||||||
|
|
||||||
|
@Schema(description = "字典名字")
|
||||||
|
private String dictName;
|
||||||
|
|
||||||
|
@Schema(description = "字典禁用状态")
|
||||||
|
private Boolean dictDisabledFlag;
|
||||||
|
|
||||||
@Schema(description = "字典项值")
|
@Schema(description = "字典项值")
|
||||||
private String dataValue;
|
private String dataValue;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public class DictVO {
|
|||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "禁用状态")
|
@Schema(description = "禁用状态")
|
||||||
private Integer disabledFlag;
|
private Boolean disabledFlag;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
@ -55,9 +55,6 @@ public class FileService {
|
|||||||
@Resource
|
@Resource
|
||||||
private FileDao fileDao;
|
private FileDao fileDao;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RedisService redisService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SecurityFileService securityFileService;
|
private SecurityFileService securityFileService;
|
||||||
|
|
||||||
|
@ -2,10 +2,7 @@ package net.lab1024.sa.base.module.support.file.service;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import com.amazonaws.services.s3.AmazonS3;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.amazonaws.services.s3.model.CannedAccessControlList;
|
|
||||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
|
||||||
import com.amazonaws.services.s3.model.S3Object;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.base.common.code.SystemErrorCode;
|
import net.lab1024.sa.base.common.code.SystemErrorCode;
|
||||||
@ -22,21 +19,27 @@ import net.lab1024.sa.base.module.support.file.domain.vo.FileVO;
|
|||||||
import net.lab1024.sa.base.module.support.redis.RedisService;
|
import net.lab1024.sa.base.module.support.redis.RedisService;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.util.FileCopyUtils;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import software.amazon.awssdk.core.ResponseBytes;
|
||||||
|
import software.amazon.awssdk.core.sync.RequestBody;
|
||||||
|
import software.amazon.awssdk.core.sync.ResponseTransformer;
|
||||||
|
import software.amazon.awssdk.regions.Region;
|
||||||
|
import software.amazon.awssdk.services.s3.S3Client;
|
||||||
|
import software.amazon.awssdk.services.s3.model.*;
|
||||||
|
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
|
||||||
|
import software.amazon.awssdk.services.s3.presigner.model.GetObjectPresignRequest;
|
||||||
|
import software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 云计算 实现
|
* 云计算 实现
|
||||||
@ -66,7 +69,7 @@ public class FileStorageCloudServiceImpl implements IFileStorageService {
|
|||||||
private static final String USER_METADATA_FILE_SIZE = "file-size";
|
private static final String USER_METADATA_FILE_SIZE = "file-size";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AmazonS3 amazonS3;
|
private S3Client s3Client;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FileConfig cloudConfig;
|
private FileConfig cloudConfig;
|
||||||
@ -86,44 +89,47 @@ public class FileStorageCloudServiceImpl implements IFileStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String fileType = FilenameUtils.getExtension(originalFileName);
|
String fileType = FilenameUtils.getExtension(originalFileName);
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuid = IdUtil.fastSimpleUUID();
|
||||||
String time = LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_FORMATTER);
|
String time = LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_FORMATTER);
|
||||||
String fileKey = path + uuid + "_" + time + "." + fileType;
|
String fileKey = path + uuid + "_" + time + "." + fileType;
|
||||||
|
|
||||||
// 文件名称 URL 编码
|
// 文件名称 URL 编码
|
||||||
String urlEncoderFilename;
|
String urlEncoderFilename;
|
||||||
try {
|
urlEncoderFilename = URLEncoder.encode(originalFileName, StandardCharsets.UTF_8);
|
||||||
urlEncoderFilename = URLEncoder.encode(originalFileName, StandardCharsets.UTF_8.name());
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
log.error("文件上传服务URL ENCODE-发生异常:", e);
|
|
||||||
return ResponseDTO.error(SystemErrorCode.SYSTEM_ERROR, "上传失败");
|
|
||||||
}
|
|
||||||
ObjectMetadata meta = new ObjectMetadata();
|
|
||||||
meta.setContentEncoding(StandardCharsets.UTF_8.name());
|
|
||||||
meta.setContentDisposition("attachment;filename=" + urlEncoderFilename);
|
|
||||||
Map<String, String> userMetadata = new HashMap<>(10);
|
Map<String, String> userMetadata = new HashMap<>(10);
|
||||||
userMetadata.put(USER_METADATA_FILE_NAME, urlEncoderFilename);
|
userMetadata.put(USER_METADATA_FILE_NAME, urlEncoderFilename);
|
||||||
userMetadata.put(USER_METADATA_FILE_FORMAT, fileType);
|
userMetadata.put(USER_METADATA_FILE_FORMAT, fileType);
|
||||||
userMetadata.put(USER_METADATA_FILE_SIZE, String.valueOf(file.getSize()));
|
userMetadata.put(USER_METADATA_FILE_SIZE, String.valueOf(file.getSize()));
|
||||||
meta.setUserMetadata(userMetadata);
|
|
||||||
meta.setContentLength(file.getSize());
|
// 根据文件路径获取并设置访问权限
|
||||||
meta.setContentType(this.getContentType(fileType));
|
ObjectCannedACL acl = this.getACL(path);
|
||||||
|
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
||||||
|
.bucket(cloudConfig.getBucketName())
|
||||||
|
.key(fileKey)
|
||||||
|
.metadata(userMetadata)
|
||||||
|
.contentLength(file.getSize())
|
||||||
|
.contentType(this.getContentType(fileType))
|
||||||
|
.contentEncoding(StandardCharsets.UTF_8.name())
|
||||||
|
.contentDisposition("attachment;filename=" + urlEncoderFilename)
|
||||||
|
.acl(acl)
|
||||||
|
.build();
|
||||||
|
InputStream inputStream = null;
|
||||||
try {
|
try {
|
||||||
amazonS3.putObject(cloudConfig.getBucketName(), fileKey, file.getInputStream(), meta);
|
inputStream = file.getInputStream();
|
||||||
|
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(inputStream, file.getSize()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("文件上传-发生异常:", e);
|
log.error("文件上传-发生异常:", e);
|
||||||
return ResponseDTO.error(SystemErrorCode.SYSTEM_ERROR, "上传失败");
|
return ResponseDTO.error(SystemErrorCode.SYSTEM_ERROR, "上传失败");
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(inputStream);
|
||||||
}
|
}
|
||||||
// 根据文件路径获取并设置访问权限
|
|
||||||
CannedAccessControlList acl = this.getACL(path);
|
|
||||||
amazonS3.setObjectAcl(cloudConfig.getBucketName(), fileKey, acl);
|
|
||||||
// 返回上传结果
|
// 返回上传结果
|
||||||
FileUploadVO uploadVO = new FileUploadVO();
|
FileUploadVO uploadVO = new FileUploadVO();
|
||||||
uploadVO.setFileName(originalFileName);
|
uploadVO.setFileName(originalFileName);
|
||||||
uploadVO.setFileType(fileType);
|
uploadVO.setFileType(fileType);
|
||||||
// 根据 访问权限 返回不同的 URL
|
// 根据 访问权限 返回不同的 URL
|
||||||
String url = cloudConfig.getUrlPrefix() + fileKey;
|
String url = cloudConfig.getUrlPrefix() + fileKey;
|
||||||
if (CannedAccessControlList.Private.equals(acl)) {
|
if (ObjectCannedACL.PRIVATE.equals(acl)) {
|
||||||
// 获取临时访问的URL
|
// 获取临时访问的URL
|
||||||
url = this.getFileUrl(fileKey).getData();
|
url = this.getFileUrl(fileKey).getData();
|
||||||
}
|
}
|
||||||
@ -136,8 +142,8 @@ public class FileStorageCloudServiceImpl implements IFileStorageService {
|
|||||||
/**
|
/**
|
||||||
* 获取文件url
|
* 获取文件url
|
||||||
*
|
*
|
||||||
* @param fileKey
|
* @param fileKey 文件key
|
||||||
* @return
|
* @return url
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ResponseDTO<String> getFileUrl(String fileKey) {
|
public ResponseDTO<String> getFileUrl(String fileKey) {
|
||||||
@ -159,10 +165,14 @@ public class FileStorageCloudServiceImpl implements IFileStorageService {
|
|||||||
if (fileVO == null) {
|
if (fileVO == null) {
|
||||||
return ResponseDTO.userErrorParam("文件不存在");
|
return ResponseDTO.userErrorParam("文件不存在");
|
||||||
}
|
}
|
||||||
|
GetObjectRequest getUrlRequest = GetObjectRequest.builder().bucket(cloudConfig.getBucketName()).key(fileKey).build();
|
||||||
|
GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder().signatureDuration(Duration.ofSeconds(cloudConfig.getPrivateUrlExpireSeconds())).getObjectRequest(getUrlRequest).build();
|
||||||
|
|
||||||
Date expiration = new Date(System.currentTimeMillis() + cloudConfig.getPrivateUrlExpireSeconds() * 1000L);
|
S3Presigner presigner = S3Presigner.builder().region(Region.of(cloudConfig.getRegion())).build();
|
||||||
URL url = amazonS3.generatePresignedUrl(cloudConfig.getBucketName(), fileKey, expiration);
|
|
||||||
fileVO.setFileUrl(url.toString());
|
PresignedGetObjectRequest presignedGetObjectRequest = presigner.presignGetObject(getObjectPresignRequest);
|
||||||
|
String url = presignedGetObjectRequest.url().toString();
|
||||||
|
fileVO.setFileUrl(url);
|
||||||
redisService.set(fileRedisKey, fileVO, cloudConfig.getPrivateUrlExpireSeconds() - 5);
|
redisService.set(fileRedisKey, fileVO, cloudConfig.getPrivateUrlExpireSeconds() - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,11 +185,11 @@ public class FileStorageCloudServiceImpl implements IFileStorageService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ResponseDTO<FileDownloadVO> download(String key) {
|
public ResponseDTO<FileDownloadVO> download(String key) {
|
||||||
//获取oss对象
|
|
||||||
S3Object s3Object = amazonS3.getObject(cloudConfig.getBucketName(), key);
|
|
||||||
// 获取文件 meta
|
// 获取文件 meta
|
||||||
ObjectMetadata metadata = s3Object.getObjectMetadata();
|
HeadObjectRequest objectRequest = HeadObjectRequest.builder().bucket(this.cloudConfig.getBucketName()).key(key).build();
|
||||||
Map<String, String> userMetadata = metadata.getUserMetadata();
|
HeadObjectResponse headObjectResponse = s3Client.headObject(objectRequest);
|
||||||
|
Map<String, String> userMetadata = headObjectResponse.metadata();
|
||||||
FileMetadataVO metadataDTO = null;
|
FileMetadataVO metadataDTO = null;
|
||||||
if (MapUtils.isNotEmpty(userMetadata)) {
|
if (MapUtils.isNotEmpty(userMetadata)) {
|
||||||
metadataDTO = new FileMetadataVO();
|
metadataDTO = new FileMetadataVO();
|
||||||
@ -190,43 +200,31 @@ public class FileStorageCloudServiceImpl implements IFileStorageService {
|
|||||||
metadataDTO.setFileSize(fileSize);
|
metadataDTO.setFileSize(fileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获得输入流
|
//获取oss对象
|
||||||
InputStream objectContent = s3Object.getObjectContent();
|
GetObjectRequest getObjectRequest = GetObjectRequest.builder().bucket(cloudConfig.getBucketName()).key(key).build();
|
||||||
try {
|
ResponseBytes<GetObjectResponse> s3ClientObject = s3Client.getObject(getObjectRequest, ResponseTransformer.toBytes());
|
||||||
// 输入流转换为字节流
|
|
||||||
byte[] buffer = FileCopyUtils.copyToByteArray(objectContent);
|
|
||||||
|
|
||||||
|
// 输入流转换为字节流
|
||||||
|
byte[] buffer = s3ClientObject.asByteArray();
|
||||||
FileDownloadVO fileDownloadVO = new FileDownloadVO();
|
FileDownloadVO fileDownloadVO = new FileDownloadVO();
|
||||||
fileDownloadVO.setData(buffer);
|
fileDownloadVO.setData(buffer);
|
||||||
fileDownloadVO.setMetadata(metadataDTO);
|
fileDownloadVO.setMetadata(metadataDTO);
|
||||||
return ResponseDTO.ok(fileDownloadVO);
|
return ResponseDTO.ok(fileDownloadVO);
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("文件下载-发生异常:", e);
|
|
||||||
return ResponseDTO.error(SystemErrorCode.SYSTEM_ERROR, "下载失败");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
// 关闭输入流
|
|
||||||
objectContent.close();
|
|
||||||
s3Object.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("文件下载-发生异常:", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文件夹路径 返回对应的访问权限
|
* 根据文件夹路径 返回对应的访问权限
|
||||||
*
|
*
|
||||||
* @param fileKey
|
* @param fileKey 文件key
|
||||||
* @return
|
* @return 权限
|
||||||
*/
|
*/
|
||||||
private CannedAccessControlList getACL(String fileKey) {
|
private ObjectCannedACL getACL(String fileKey) {
|
||||||
// 公用读
|
// 公用读
|
||||||
if (fileKey.contains(FileFolderTypeEnum.FOLDER_PUBLIC)) {
|
if (fileKey.contains(FileFolderTypeEnum.FOLDER_PUBLIC)) {
|
||||||
return CannedAccessControlList.PublicRead;
|
return ObjectCannedACL.PUBLIC_READ;
|
||||||
}
|
}
|
||||||
// 其他默认私有读写
|
// 其他默认私有读写
|
||||||
return CannedAccessControlList.Private;
|
return ObjectCannedACL.PRIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,11 +233,11 @@ public class FileStorageCloudServiceImpl implements IFileStorageService {
|
|||||||
* ps:不能删除fileKey不为空的文件夹
|
* ps:不能删除fileKey不为空的文件夹
|
||||||
*
|
*
|
||||||
* @param fileKey 文件or文件夹
|
* @param fileKey 文件or文件夹
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ResponseDTO<String> delete(String fileKey) {
|
public ResponseDTO<String> delete(String fileKey) {
|
||||||
amazonS3.deleteObject(cloudConfig.getBucketName(), fileKey);
|
DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder().bucket(cloudConfig.getBucketName()).key(fileKey).build();
|
||||||
|
s3Client.deleteObject(deleteObjectRequest);
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ public class HelpDocCatalogEntity {
|
|||||||
/**
|
/**
|
||||||
* 排序
|
* 排序
|
||||||
*/
|
*/
|
||||||
@TableField("`sort`")
|
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ public class HelpDocEntity {
|
|||||||
/**
|
/**
|
||||||
* 排序
|
* 排序
|
||||||
*/
|
*/
|
||||||
@TableField("`sort`")
|
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
package net.lab1024.sa.base.module.support.job.api.domain;
|
package net.lab1024.sa.base.module.support.job.api.domain;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
|
||||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
|
||||||
import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum;
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务 更新
|
* 定时任务 更新
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.lab1024.sa.base.module.support.mail;
|
package net.lab1024.sa.base.module.support.mail;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.UUID;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import freemarker.cache.StringTemplateLoader;
|
import freemarker.cache.StringTemplateLoader;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import freemarker.template.Template;
|
import freemarker.template.Template;
|
||||||
@ -19,7 +19,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.apache.commons.text.StringSubstitutor;
|
import org.apache.commons.text.StringSubstitutor;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
@ -33,7 +32,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 发生邮件:<br/>
|
* 发送邮件:<br/>
|
||||||
* 1、支持直接发送 <br/>
|
* 1、支持直接发送 <br/>
|
||||||
* 2、支持使用邮件模板发送
|
* 2、支持使用邮件模板发送
|
||||||
*
|
*
|
||||||
@ -47,7 +46,7 @@ import java.util.Map;
|
|||||||
@Component
|
@Component
|
||||||
public class MailService {
|
public class MailService {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private JavaMailSender javaMailSender;
|
private JavaMailSender javaMailSender;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -163,7 +162,7 @@ public class MailService {
|
|||||||
private String freemarkerResolverContent(String htmlTemplate, Map<String, Object> templateParamsMap) {
|
private String freemarkerResolverContent(String htmlTemplate, Map<String, Object> templateParamsMap) {
|
||||||
Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
|
Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
|
||||||
StringTemplateLoader stringLoader = new StringTemplateLoader();
|
StringTemplateLoader stringLoader = new StringTemplateLoader();
|
||||||
String templateName = UUID.fastUUID().toString(true);
|
String templateName = IdUtil.fastSimpleUUID();
|
||||||
stringLoader.putTemplate(templateName, htmlTemplate);
|
stringLoader.putTemplate(templateName, htmlTemplate);
|
||||||
configuration.setTemplateLoader(stringLoader);
|
configuration.setTemplateLoader(stringLoader);
|
||||||
try {
|
try {
|
||||||
|
@ -36,9 +36,9 @@ public class MessageQueryForm extends PageParam {
|
|||||||
@Schema(description = "查询结束时间")
|
@Schema(description = "查询结束时间")
|
||||||
private LocalDate endDate;
|
private LocalDate endDate;
|
||||||
|
|
||||||
@Schema(hidden = true)
|
@Schema(description = "接收人")
|
||||||
private Long receiverUserId;
|
private Long receiverUserId;
|
||||||
|
|
||||||
@Schema(hidden = true)
|
@Schema(description = "接收人类型")
|
||||||
private Integer receiverUserType;
|
private Integer receiverUserType;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package net.lab1024.sa.base.module.support.message.domain;
|
package net.lab1024.sa.base.module.support.message.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
|
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
|
||||||
import net.lab1024.sa.base.module.support.message.constant.MessageTemplateEnum;
|
import net.lab1024.sa.base.module.support.message.constant.MessageTemplateEnum;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,6 +28,10 @@ public class MessageTemplateSendForm {
|
|||||||
@NotNull(message = "接收者id不能为空")
|
@NotNull(message = "接收者id不能为空")
|
||||||
private Long receiverUserId;
|
private Long receiverUserId;
|
||||||
|
|
||||||
|
@Schema(description = "接收者id")
|
||||||
|
@NotEmpty(message = "接收者id不能为空")
|
||||||
|
private List<Long> receiverUserIdList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 相关业务id | 可选
|
* 相关业务id | 可选
|
||||||
* 用于跳转具体业务
|
* 用于跳转具体业务
|
||||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import net.lab1024.sa.base.common.domain.PageResult;
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
|
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
|
||||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||||
@ -105,4 +106,13 @@ public class MessageService {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
messageManager.saveBatch(messageEntityList);
|
messageManager.saveBatch(messageEntityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除消息
|
||||||
|
public ResponseDTO<String> delete(Long messageId) {
|
||||||
|
if(messageId == null){
|
||||||
|
return ResponseDTO.userErrorParam();
|
||||||
|
}
|
||||||
|
messageDao.deleteById(messageId);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.base.common.constant.StringConst;
|
import net.lab1024.sa.base.common.constant.StringConst;
|
||||||
import net.lab1024.sa.base.common.domain.RequestUser;
|
import net.lab1024.sa.base.common.domain.RequestUser;
|
||||||
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.common.util.SmartIpUtil;
|
import net.lab1024.sa.base.common.util.SmartIpUtil;
|
||||||
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
||||||
import net.lab1024.sa.base.module.support.operatelog.OperateLogDao;
|
import net.lab1024.sa.base.module.support.operatelog.OperateLogDao;
|
||||||
@ -71,14 +72,14 @@ public abstract class OperateLogAspect {
|
|||||||
public void logPointCut() {
|
public void logPointCut() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterReturning(pointcut = "logPointCut()")
|
@AfterReturning(pointcut = "logPointCut()", returning = "responseDTO")
|
||||||
public void doAfterReturning(JoinPoint joinPoint) {
|
public void doAfterReturning(JoinPoint joinPoint, Object responseDTO) {
|
||||||
handleLog(joinPoint, null);
|
handleLog(joinPoint, null, responseDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterThrowing(value = "logPointCut()", throwing = "e")
|
@AfterThrowing(value = "logPointCut()", throwing = "e")
|
||||||
public void doAfterThrowing(JoinPoint joinPoint, Exception e) {
|
public void doAfterThrowing(JoinPoint joinPoint, Exception e) {
|
||||||
handleLog(joinPoint, e);
|
handleLog(joinPoint, e, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,16 +110,15 @@ public abstract class OperateLogAspect {
|
|||||||
taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
|
taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleLog(final JoinPoint joinPoint, final Exception e) {
|
protected void handleLog(final JoinPoint joinPoint, final Exception e, Object responseDTO) {
|
||||||
try {
|
try {
|
||||||
OperateLog operateLog = this.getAnnotationLog(joinPoint);
|
OperateLog operateLog = this.getAnnotationLog(joinPoint);
|
||||||
if (operateLog == null) {
|
if (operateLog == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.submitLog(joinPoint, e);
|
this.submitLog(joinPoint, e, responseDTO);
|
||||||
} catch (Exception exp) {
|
} catch (Exception exp) {
|
||||||
log.error("保存操作日志异常:{}", exp.getMessage());
|
log.error("保存操作日志异常:{}", exp.getMessage());
|
||||||
exp.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,11 +173,8 @@ public abstract class OperateLogAspect {
|
|||||||
/**
|
/**
|
||||||
* 提交存储操作日志
|
* 提交存储操作日志
|
||||||
*
|
*
|
||||||
* @param joinPoint
|
|
||||||
* @param e
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
private void submitLog(final JoinPoint joinPoint, final Throwable e) throws Exception {
|
private void submitLog(final JoinPoint joinPoint, final Throwable e, Object responseDTO) {
|
||||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||||
//设置用户信息
|
//设置用户信息
|
||||||
RequestUser user = SmartRequestUtil.getRequestUser();
|
RequestUser user = SmartRequestUtil.getRequestUser();
|
||||||
@ -191,7 +188,7 @@ public abstract class OperateLogAspect {
|
|||||||
String methodName = joinPoint.getSignature().getName();
|
String methodName = joinPoint.getSignature().getName();
|
||||||
String operateMethod = className + "." + methodName;
|
String operateMethod = className + "." + methodName;
|
||||||
String failReason = null;
|
String failReason = null;
|
||||||
Boolean successFlag = true;
|
boolean successFlag = true;
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
successFlag = false;
|
successFlag = false;
|
||||||
failReason = getExceptionString(e);
|
failReason = getExceptionString(e);
|
||||||
@ -210,15 +207,32 @@ public abstract class OperateLogAspect {
|
|||||||
.userAgent(user.getUserAgent())
|
.userAgent(user.getUserAgent())
|
||||||
.failReason(failReason)
|
.failReason(failReason)
|
||||||
.successFlag(successFlag).build();
|
.successFlag(successFlag).build();
|
||||||
|
|
||||||
Operation apiOperation = this.getApiOperation(joinPoint);
|
Operation apiOperation = this.getApiOperation(joinPoint);
|
||||||
if (apiOperation != null) {
|
if (apiOperation != null) {
|
||||||
operateLogEntity.setContent(apiOperation.summary());
|
operateLogEntity.setContent(apiOperation.summary());
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag api = this.getApi(joinPoint);
|
Tag api = this.getApi(joinPoint);
|
||||||
if (api != null) {
|
if (api != null) {
|
||||||
String name = api.name();
|
String name = api.name();
|
||||||
operateLogEntity.setModule(StrUtil.join(",", name));
|
operateLogEntity.setModule(StrUtil.join(",", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理返回值 ResponseDTO
|
||||||
|
if(responseDTO instanceof ResponseDTO) {
|
||||||
|
ResponseDTO response = (ResponseDTO) responseDTO;
|
||||||
|
ResponseDTO logResponseDTO = new ResponseDTO(
|
||||||
|
response.getCode(),
|
||||||
|
response.getLevel(),
|
||||||
|
response.getOk(),
|
||||||
|
response.getMsg(),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
logResponseDTO.setDataType(response.getDataType());
|
||||||
|
operateLogEntity.setResponse(JSON.toJSONString(logResponseDTO));
|
||||||
|
}
|
||||||
|
|
||||||
taskExecutor.execute(() -> {
|
taskExecutor.execute(() -> {
|
||||||
this.saveLog(operateLogEntity);
|
this.saveLog(operateLogEntity);
|
||||||
});
|
});
|
||||||
|
@ -71,6 +71,11 @@ public class OperateLogEntity {
|
|||||||
*/
|
*/
|
||||||
private String param;
|
private String param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回值
|
||||||
|
*/
|
||||||
|
private String response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户ip
|
* 客户ip
|
||||||
*/
|
*/
|
||||||
|
@ -47,6 +47,9 @@ public class OperateLogVO {
|
|||||||
@Schema(description = "请求参数")
|
@Schema(description = "请求参数")
|
||||||
private String param;
|
private String param;
|
||||||
|
|
||||||
|
@Schema(description = "返回值")
|
||||||
|
private String response;
|
||||||
|
|
||||||
@Schema(description = "客户ip")
|
@Schema(description = "客户ip")
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
|
@ -0,0 +1,145 @@
|
|||||||
|
package net.lab1024.sa.base.module.support.redis;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.convert.DurationStyle;
|
||||||
|
import org.springframework.data.redis.cache.*;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import static net.lab1024.sa.base.common.constant.StringConst.COLON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义 RedisCacheManager,支持在 cacheName 中通过 '#' 指定 TTL(过期时间)。
|
||||||
|
*
|
||||||
|
* @Author CoderKK
|
||||||
|
* @Date 2025-08-15 13:01:01
|
||||||
|
* <p>
|
||||||
|
* 支持格式:{@code cacheName#ttl},其中 ttl 支持 Spring 的 Duration 格式。
|
||||||
|
* 特殊值:{@code -1} 表示永久缓存(永不过期)。
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <h3>使用示例:</h3>
|
||||||
|
* <pre>
|
||||||
|
* // 10 秒后过期
|
||||||
|
* @Cacheable(value = "user#10s", key = "#id")
|
||||||
|
* // 2 小时后过期
|
||||||
|
* @Cacheable(value = "report#2h", key = "#date")
|
||||||
|
* // 30 分钟后过期
|
||||||
|
* @Cacheable(value = "session#30m", key = "#token")
|
||||||
|
* // 永不过期(永久缓存),适用于极少变化的配置数据
|
||||||
|
* @Cacheable(value = "appConfig#-1", key = "'globalSettings'")
|
||||||
|
* // 无 TTL,使用全局默认过期时间(如 7 天)
|
||||||
|
* @Cacheable(value = "product", key = "#productId")
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <h3>生成的 Redis Key 格式:</h3>
|
||||||
|
* <pre>
|
||||||
|
* cache:cacheName:key
|
||||||
|
* 例如:cache:user:123
|
||||||
|
* cache:appConfig:globalSettings
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <h3>支持的 TTL 单位:</h3>
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code ms} / {@code millis} / {@code milliseconds} - 毫秒</li>
|
||||||
|
* <li>{@code s} / {@code secs} / {@code seconds} - 秒</li>
|
||||||
|
* <li>{@code m} / {@code mins} / {@code minutes} - 分钟</li>
|
||||||
|
* <li>{@code h} / {@code hrs} / {@code hours} - 小时</li>
|
||||||
|
* <li>{@code d} / {@code days} - 天</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <h3>注意事项:</h3>
|
||||||
|
* <ul>
|
||||||
|
* <li>不写单位默认为毫秒</li>
|
||||||
|
* <li>永久缓存(#-1)不会自动过期,请配合 @CacheEvict 手动清理。</li>
|
||||||
|
* <li>避免对频繁更新的数据使用永久缓存,防止数据陈旧。</li>
|
||||||
|
* <li>cacheName 中的 '#' 只解析第一个,后续字符将作为 TTL 处理。</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class CustomRedisCacheManager extends RedisCacheManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存全局前缀
|
||||||
|
*/
|
||||||
|
private static final String CACHE_PREFIX = "cache";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义 TTL 分隔符,用于在 cacheName 后附加过期时间
|
||||||
|
*/
|
||||||
|
private static final String CUSTOM_TTL_SEPARATOR = "#";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认缓存过期时间:7 天
|
||||||
|
*/
|
||||||
|
private static final Duration DEFAULT_TTL = Duration.ofDays(7);
|
||||||
|
|
||||||
|
public CustomRedisCacheManager(RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) {
|
||||||
|
super(cacheWriter, defaultCacheConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建 RedisCache 实例,支持从 cacheName 解析 TTL
|
||||||
|
*
|
||||||
|
* @param name 缓存名称(支持 name#ttl 格式)
|
||||||
|
* @param cacheConfig 默认缓存配置
|
||||||
|
* @return RedisCache
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected RedisCache createRedisCache(String name, RedisCacheConfiguration cacheConfig) {
|
||||||
|
Duration ttl = parseTtlFromCacheName(name);
|
||||||
|
if (ttl == null) {
|
||||||
|
ttl = DEFAULT_TTL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheKeyPrefix keyPrefix = cacheName -> {
|
||||||
|
if (StrUtil.isBlank(cacheName)) {
|
||||||
|
return CACHE_PREFIX + COLON;
|
||||||
|
}
|
||||||
|
String[] parts = cacheName.split(CUSTOM_TTL_SEPARATOR, 2);
|
||||||
|
String cleanName = StrUtil.trim(parts[0]);
|
||||||
|
return CACHE_PREFIX + COLON + cleanName + COLON;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 构建最终缓存配置:设置 key 前缀 + TTL
|
||||||
|
RedisCacheConfiguration config = cacheConfig.computePrefixWith(keyPrefix).entryTtl(ttl);
|
||||||
|
|
||||||
|
return super.createRedisCache(name, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 cacheName 中解析 TTL
|
||||||
|
*
|
||||||
|
* @param name 缓存名称,格式如:users#10m, products#2h, config#-1(永久)
|
||||||
|
* @return 解析出的 Duration若无效则返回 null;若为 -1,则返回 Duration.ofMillis(-1) 表示永久缓存
|
||||||
|
*/
|
||||||
|
private Duration parseTtlFromCacheName(String name) {
|
||||||
|
if (StrUtil.isBlank(name)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = name.split(CUSTOM_TTL_SEPARATOR, 2);
|
||||||
|
if (parts.length < 2) {
|
||||||
|
return null; // 无 TTL 部分
|
||||||
|
}
|
||||||
|
|
||||||
|
String ttlStr = StrUtil.trim(parts[1]);
|
||||||
|
if (StrUtil.isBlank(ttlStr)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 特殊处理:-1 表示永久缓存
|
||||||
|
if ("-1".equals(ttlStr)) {
|
||||||
|
return Duration.ofMillis(-1); // Spring Redis 中负数 Duration 表示永不过期
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Duration ttl = DurationStyle.detectAndParse(ttlStr);
|
||||||
|
return ttl.getSeconds() > 0 ? ttl : null;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.error("解析缓存 TTL 失败,cacheName='{}', ttl='{}', 错误: {}", name, ttlStr, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,9 +11,6 @@ import net.lab1024.sa.base.module.support.reload.core.thread.SmartReloadRunnable
|
|||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
|
||||||
import org.springframework.context.event.ContextRefreshedEvent;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package net.lab1024.sa.base.module.support.reload.core.thread;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.base.module.support.reload.core.AbstractSmartReloadCommand;
|
import net.lab1024.sa.base.module.support.reload.core.AbstractSmartReloadCommand;
|
||||||
import net.lab1024.sa.base.module.support.reload.core.SmartReloadManager;
|
|
||||||
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadItem;
|
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadItem;
|
||||||
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadObject;
|
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadObject;
|
||||||
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadResult;
|
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadResult;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user