mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-23 05:46:40 +08:00
Compare commits
No commits in common. "master" and "v3.14" have entirely different histories.
@ -4,18 +4,16 @@
|
||||
|
||||
**<font color="#DC143C">国内首个满足《网络安全-三级等保》、《数据安全》</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">JavaScript和TypeScript双版本</font>**,后端提供 **<font color="#DC143C">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>** !
|
||||
### **技术体系**
|
||||
|
||||
- 前端:JavaScript/TypeScript + Vue3 + Vite5 + Pinia + Ant Design Vue 4.X
|
||||
- 移动端:uniapp (vue3版本) + uni-ui + (同时支持APP、小程序、H5)
|
||||
- 后端:Java8/17 + SpringBoot2/3 + Sa Token + Mybatis-plus + 主流数据库/国产数据库
|
||||
- 官方文档:[https://smartadmin.vip](https://smartadmin.vip)
|
||||
- 后端:Java8/17 + SpringBoot2/3 + Sa Token + Mybatis-plus + 多种数据库
|
||||
- 电脑在线预览:[https://preview.smartadmin.vip](https://preview.smartadmin.vip)
|
||||
- 官方文档:[https://smartadmin.vip](https://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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.lab1024</groupId>
|
||||
<groupId>net.1024lab</groupId>
|
||||
<artifactId>sa-parent</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<packaging>pom</packaging>
|
||||
@ -16,49 +16,55 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>17</java.version>
|
||||
<springboot.version>3.5.4</springboot.version>
|
||||
<spring-security-crypto.version>6.5.1</spring-security-crypto.version>
|
||||
<mybatis-plus.version>3.5.12</mybatis-plus.version>
|
||||
<springboot.version>3.3.1</springboot.version>
|
||||
<spring-mock.version>2.0.8</spring-mock.version>
|
||||
<spring-security-crypto.version>6.4.3</spring-security-crypto.version>
|
||||
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
||||
<p6spy.version>3.9.1</p6spy.version>
|
||||
<springdoc-openapi.version>2.8.9</springdoc-openapi.version>
|
||||
<knife4j.version>4.6.0</knife4j.version>
|
||||
<fastjson.version>2.0.57</fastjson.version>
|
||||
<druid.version>1.2.25</druid.version>
|
||||
<knife4j.version>4.4.0</knife4j.version>
|
||||
<fastjson.version>2.0.52</fastjson.version>
|
||||
<druid.version>1.2.23</druid.version>
|
||||
<google-linkedhashmap.version>1.4.2</google-linkedhashmap.version>
|
||||
<google-guava.version>20.0</google-guava.version>
|
||||
<reflections.version>0.10.2</reflections.version>
|
||||
<commons-io.version>2.19.0</commons-io.version>
|
||||
<commons-lang3.version>3.18.0</commons-lang3.version>
|
||||
<commons-collections4.version>4.5.0</commons-collections4.version>
|
||||
<commons-compress.version>1.27.1</commons-compress.version>
|
||||
<commons-codec.version>1.18.0</commons-codec.version>
|
||||
<commons-text.version>1.13.1</commons-text.version>
|
||||
<fast-excel.version>1.2.0</fast-excel.version>
|
||||
<poi.version>5.4.1</poi.version>
|
||||
<awssdk-s3.version>2.31.78</awssdk-s3.version>
|
||||
<mysql-connector-j.version>9.3.0</mysql-connector-j.version>
|
||||
<hutool.version>5.8.39</hutool.version>
|
||||
<velocity-engine-core.version>2.4.1</velocity-engine-core.version>
|
||||
<user-agent-utils.version>1.21</user-agent-utils.version>
|
||||
<reflections.version>0.9.11</reflections.version>
|
||||
<commons-io.version>2.15.0</commons-io.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<commons-collections4.version>4.4</commons-collections4.version>
|
||||
<commons-compress.version>1.26.0</commons-compress.version>
|
||||
<commons-codec.version>1.13</commons-codec.version>
|
||||
<commons-text.version>1.9</commons-text.version>
|
||||
<xerces.version>2.12.0</xerces.version>
|
||||
<fast-excel.version>1.0.0</fast-excel.version>
|
||||
<poi.version>5.2.4</poi.version>
|
||||
<ooxml-schemas.version>1.4</ooxml-schemas.version>
|
||||
<aws-java-sdk.version>1.11.842</aws-java-sdk.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>
|
||||
<sa-token.version>1.44.0</sa-token.version>
|
||||
<sa-token.version>1.37.0</sa-token.version>
|
||||
<ip2region.version>2.7.0</ip2region.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>
|
||||
<redisson.version>3.50.0</redisson.version>
|
||||
<snakeyaml.version>2.4</snakeyaml.version>
|
||||
<freemarker.version>2.3.34</freemarker.version>
|
||||
<jsoup.version>1.21.1</jsoup.version>
|
||||
<redisson.version>3.25.0</redisson.version>
|
||||
<snakeyaml.version>2.2</snakeyaml.version>
|
||||
<freemarker.version>2.3.33</freemarker.version>
|
||||
<jsoup.version>1.18.1</jsoup.version>
|
||||
<tika.version>3.1.0</tika.version>
|
||||
<httpcomponents.version>5.5</httpcomponents.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<!--SpringBoot BOM begin-->
|
||||
<!--BOM begin-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
@ -66,16 +72,19 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!--SpringBoot BOM end-->
|
||||
<!--mybatis-plus BOM begin-->
|
||||
<!--BOM end-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-bom</artifactId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--mybatis-plus BOM end-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
@ -83,12 +92,6 @@
|
||||
<version>${spring-security-crypto.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>${mysql-connector-j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>p6spy</groupId>
|
||||
<artifactId>p6spy</artifactId>
|
||||
@ -96,7 +99,7 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xingfudeshi</groupId>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
@ -107,6 +110,7 @@
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||
@ -125,6 +129,12 @@
|
||||
<version>${google-guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
<version>${user-agent-utils.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
@ -168,9 +178,9 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3</artifactId>
|
||||
<version>${awssdk-s3.version}</version>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<version>${aws-java-sdk.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
@ -190,6 +200,19 @@
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</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-->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
@ -216,7 +239,6 @@
|
||||
<artifactId>sa-token-redis-jackson</artifactId>
|
||||
<version>${sa-token.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- sa-token end -->
|
||||
|
||||
<!--ip 地址-->
|
||||
@ -241,10 +263,6 @@
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
@ -254,6 +272,12 @@
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
@ -262,8 +286,20 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-full</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
<artifactId>ooxml-schemas</artifactId>
|
||||
<version>${ooxml-schemas.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>
|
||||
@ -277,25 +313,6 @@
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
<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>
|
||||
@ -322,12 +339,6 @@
|
||||
<version>${tika.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<version>${httpcomponents.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>net.lab1024</groupId>
|
||||
<groupId>net.1024lab</groupId>
|
||||
<artifactId>sa-parent</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.lab1024</groupId>
|
||||
<groupId>net.1024lab</groupId>
|
||||
<artifactId>sa-base</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
@ -20,6 +20,11 @@ public class AdminCacheConst extends CacheKeyConst {
|
||||
*/
|
||||
public static final String DEPARTMENT_LIST_CACHE = "department_list_cache";
|
||||
|
||||
/**
|
||||
* 部门map
|
||||
*/
|
||||
public static final String DEPARTMENT_MAP_CACHE = "department_map_cache";
|
||||
|
||||
/**
|
||||
* 部门树
|
||||
*/
|
||||
@ -49,20 +54,4 @@ public class AdminCacheConst extends CacheKeyConst {
|
||||
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,8 +51,6 @@ public class AdminSwaggerTagConst extends SwaggerTagConst {
|
||||
|
||||
public static final String SYSTEM_POSITION = "系统-职务管理";
|
||||
|
||||
public static final String SYSTEM_MESSAGE = "系统-消息";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,8 +2,9 @@ package net.lab1024.sa.admin.interceptor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
import cn.dev33.satoken.strategy.SaStrategy;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.strategy.SaAnnotationStrategy;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@ -67,8 +68,7 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
Method method = ((HandlerMethod) handler).getMethod();
|
||||
NoNeedLogin noNeedLogin = ((HandlerMethod) handler).getMethodAnnotation(NoNeedLogin.class);
|
||||
if (noNeedLogin != null) {
|
||||
updateActiveTimeout(requestEmployee);
|
||||
SmartRequestUtil.setRequestUser(requestEmployee);
|
||||
checkActiveTimeout(requestEmployee);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -77,14 +77,14 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 更新活跃
|
||||
updateActiveTimeout(requestEmployee);
|
||||
// 检测token 活跃频率
|
||||
checkActiveTimeout(requestEmployee);
|
||||
|
||||
|
||||
// --------------- 第三步: 校验 权限 ---------------
|
||||
|
||||
SmartRequestUtil.setRequestUser(requestEmployee);
|
||||
if (SaAnnotationStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||
if (SaStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
return true;
|
||||
}
|
||||
|
||||
SaAnnotationStrategy.instance.checkMethodAnnotation.accept(method);
|
||||
SaStrategy.instance.checkMethodAnnotation.accept(method);
|
||||
|
||||
} catch (SaTokenException e) {
|
||||
/*
|
||||
@ -123,19 +123,26 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
|
||||
|
||||
/**
|
||||
* 更新活跃时间
|
||||
* 检测:token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结
|
||||
*/
|
||||
private void updateActiveTimeout(RequestEmployee requestEmployee) {
|
||||
private void checkActiveTimeout(RequestEmployee requestEmployee) {
|
||||
|
||||
// 用户不在线,也不用检测
|
||||
if (requestEmployee == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
StpUtil.checkActiveTimeout();
|
||||
StpUtil.updateLastActiveToNow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
// 清除上下文
|
||||
SmartRequestUtil.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.lab1024.sa.admin.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* admin 应用启动加载
|
||||
*
|
||||
* @Author 1024创新实验室-主任:卓大
|
||||
* @Date 2021-08-26 18:46:32
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AdminStartupRunner implements CommandLineRunner {
|
||||
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface CategoryDao extends BaseMapper<CategoryEntity> {
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.category.constant.CategoryTypeEnum;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@ -16,13 +15,11 @@ import java.time.LocalDateTime;
|
||||
* @Date 2021/08/05 21:26:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
@TableName("t_category")
|
||||
public class CategoryEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class CategoryEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long categoryId;
|
||||
|
@ -3,7 +3,6 @@ package net.lab1024.sa.admin.module.business.category.domain.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -13,12 +12,10 @@ import java.util.List;
|
||||
* @Date 2021/08/05 21:26:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class CategoryTreeVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class CategoryTreeVO {
|
||||
|
||||
@Schema(description = "类目id")
|
||||
private Long categoryId;
|
||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface GoodsDao extends BaseMapper<GoodsEntity> {
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,7 @@ import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
|
||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||
|
||||
@ -39,7 +39,7 @@ public class GoodsAddForm {
|
||||
|
||||
@Schema(description = "产地")
|
||||
@NotBlank(message = "产地 不能为空 ")
|
||||
@JsonDeserialize(using = DictDataDeserializer.class)
|
||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
||||
private String place;
|
||||
|
||||
@Schema(description = "商品价格")
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
|
||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@ -34,7 +34,7 @@ public class GoodsQueryForm extends PageParam {
|
||||
private Integer goodsStatus;
|
||||
|
||||
@Schema(description = "产地")
|
||||
@JsonDeserialize(using = DictDataDeserializer.class)
|
||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
||||
private String place;
|
||||
|
||||
@Schema(description = "上架状态")
|
||||
|
@ -1,5 +1,6 @@
|
||||
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 lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||
|
@ -26,6 +26,7 @@ import net.lab1024.sa.base.common.util.SmartEnumUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import net.lab1024.sa.base.module.support.datatracer.constant.DataTracerTypeEnum;
|
||||
import net.lab1024.sa.base.module.support.datatracer.service.DataTracerService;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -59,7 +60,7 @@ public class GoodsService {
|
||||
private DataTracerService dataTracerService;
|
||||
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
private DictCacheService dictCacheService;
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
@ -193,13 +194,13 @@ public class GoodsService {
|
||||
*/
|
||||
public List<GoodsExcelVO> getAllGoods() {
|
||||
List<GoodsEntity> goodsEntityList = goodsDao.selectList(null);
|
||||
String dictCode = "GOODS_PLACE";
|
||||
String keyCode="GODOS_PLACE";
|
||||
return goodsEntityList.stream()
|
||||
.map(e ->
|
||||
GoodsExcelVO.builder()
|
||||
.goodsStatus(SmartEnumUtil.getEnumDescByValue(e.getGoodsStatus(), GoodsStatusEnum.class))
|
||||
.categoryName(categoryQueryService.queryCategoryName(e.getCategoryId()))
|
||||
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictService.getDictDataLabel(dictCode, code)).collect(Collectors.joining(",")))
|
||||
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictCacheService.selectValueNameByValueCode(keyCode,code)).collect(Collectors.joining(",")))
|
||||
.price(e.getPrice())
|
||||
.goodsName(e.getGoodsName())
|
||||
.remark(e.getRemark())
|
||||
|
@ -1,12 +1,10 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.bank.controller;
|
||||
package net.lab1024.sa.admin.module.business.oa.bank;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
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.BankQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankUpdateForm;
|
||||
@ -37,28 +35,24 @@ public class BankController {
|
||||
|
||||
@Operation(summary = "分页查询银行信息 @author 善逸")
|
||||
@PostMapping("/oa/bank/page/query")
|
||||
@SaCheckPermission("oa:bank:query")
|
||||
public ResponseDTO<PageResult<BankVO>> queryByPage(@RequestBody @Valid BankQueryForm queryForm) {
|
||||
return bankService.queryByPage(queryForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据企业ID查询银行信息列表 @author 善逸")
|
||||
@GetMapping("/oa/bank/query/list/{enterpriseId}")
|
||||
@SaCheckPermission("oa:bank:query")
|
||||
public ResponseDTO<List<BankVO>> queryList(@PathVariable Long enterpriseId) {
|
||||
return bankService.queryList(enterpriseId);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询银行信息详情 @author 善逸")
|
||||
@GetMapping("/oa/bank/get/{bankId}")
|
||||
@SaCheckPermission("oa:bank:query")
|
||||
public ResponseDTO<BankVO> getDetail(@PathVariable Long bankId) {
|
||||
return bankService.getDetail(bankId);
|
||||
}
|
||||
|
||||
@Operation(summary = "新建银行信息 @author 善逸")
|
||||
@PostMapping("/oa/bank/create")
|
||||
@SaCheckPermission("oa:bank:add")
|
||||
public ResponseDTO<String> createBank(@RequestBody @Valid BankCreateForm createVO) {
|
||||
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||
createVO.setCreateUserId(requestUser.getUserId());
|
||||
@ -68,14 +62,12 @@ public class BankController {
|
||||
|
||||
@Operation(summary = "编辑银行信息 @author 善逸")
|
||||
@PostMapping("/oa/bank/update")
|
||||
@SaCheckPermission("oa:bank:update")
|
||||
public ResponseDTO<String> updateBank(@RequestBody @Valid BankUpdateForm updateVO) {
|
||||
return bankService.updateBank(updateVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除银行信息 @author 善逸")
|
||||
@GetMapping("/oa/bank/delete/{bankId}")
|
||||
@SaCheckPermission("oa:bank:delete")
|
||||
public ResponseDTO<String> deleteBank(@PathVariable Long bankId) {
|
||||
return bankService.deleteBank(bankId);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.bank.dao;
|
||||
package net.lab1024.sa.admin.module.business.oa.bank;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -7,6 +7,7 @@ import net.lab1024.sa.admin.module.business.oa.bank.domain.BankQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.oa.bank.domain.BankVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -20,6 +21,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface BankDao extends BaseMapper<BankEntity> {
|
||||
|
||||
/**
|
@ -1,9 +1,8 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.bank.service;
|
||||
package net.lab1024.sa.admin.module.business.oa.bank;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
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.enterprise.dao.EnterpriseDao;
|
||||
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.controller;
|
||||
package net.lab1024.sa.admin.module.business.oa.enterprise;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -8,7 +8,6 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.vo.EnterpriseEmployeeVO;
|
||||
import net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseExcelVO;
|
||||
@ -101,7 +100,6 @@ public class EnterpriseController {
|
||||
|
||||
@Operation(summary = "按照类型查询企业 @author 开云")
|
||||
@GetMapping("/oa/enterprise/query/list")
|
||||
@SaCheckPermission("oa:enterprise:query")
|
||||
public ResponseDTO<List<EnterpriseListVO>> queryList(@RequestParam(value = "type", required = false) Integer type) {
|
||||
return enterpriseService.queryList(type);
|
||||
}
|
||||
@ -116,14 +114,12 @@ public class EnterpriseController {
|
||||
|
||||
@Operation(summary = "查询企业全部员工 @author 罗伊")
|
||||
@PostMapping("/oa/enterprise/employee/list")
|
||||
@SaCheckPermission("oa:enterprise:queryEmployee")
|
||||
public ResponseDTO<List<EnterpriseEmployeeVO>> employeeList(@RequestBody @Valid List<Long> enterpriseIdList) {
|
||||
return ResponseDTO.ok(enterpriseService.employeeList(enterpriseIdList));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询企业员工 @author 卓大")
|
||||
@PostMapping("/oa/enterprise/employee/queryPage")
|
||||
@SaCheckPermission("oa:enterprise:queryEmployee")
|
||||
public ResponseDTO<PageResult<EnterpriseEmployeeVO>> queryPageEmployeeList(@RequestBody @Valid EnterpriseEmployeeQueryForm queryForm) {
|
||||
return ResponseDTO.ok(enterpriseService.queryPageEmployeeList(queryForm));
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.enterprise.manager;
|
||||
package net.lab1024.sa.admin.module.business.oa.enterprise;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.lab1024.sa.admin.module.business.oa.enterprise.dao.EnterpriseEmployeeDao;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.enterprise.service;
|
||||
package net.lab1024.sa.admin.module.business.oa.enterprise;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -13,7 +13,6 @@ 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.EnterpriseListVO;
|
||||
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.base.common.code.UserErrorCode;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface EnterpriseDao extends BaseMapper<EnterpriseEntity> {
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface EnterpriseEmployeeDao extends BaseMapper<EnterpriseEmployeeEntity> {
|
||||
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.invoice.controller;
|
||||
package net.lab1024.sa.admin.module.business.oa.invoice;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.InvoiceQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceUpdateForm;
|
||||
@ -40,21 +38,18 @@ public class InvoiceController {
|
||||
|
||||
@Operation(summary = "分页查询发票信息 @author 善逸")
|
||||
@PostMapping("/oa/invoice/page/query")
|
||||
@SaCheckPermission("oa:invoice:query")
|
||||
public ResponseDTO<PageResult<InvoiceVO>> queryByPage(@RequestBody @Valid InvoiceQueryForm queryForm) {
|
||||
return invoiceService.queryByPage(queryForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询发票信息详情 @author 善逸")
|
||||
@GetMapping("/oa/invoice/get/{invoiceId}")
|
||||
@SaCheckPermission("oa:invoice:query")
|
||||
public ResponseDTO<InvoiceVO> getDetail(@PathVariable Long invoiceId) {
|
||||
return invoiceService.getDetail(invoiceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "新建发票信息 @author 善逸")
|
||||
@PostMapping("/oa/invoice/create")
|
||||
@SaCheckPermission("oa:invoice:add")
|
||||
public ResponseDTO<String> createInvoice(@RequestBody @Valid InvoiceAddForm createVO) {
|
||||
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||
createVO.setCreateUserId(requestUser.getUserId());
|
||||
@ -62,24 +57,21 @@ public class InvoiceController {
|
||||
return invoiceService.createInvoice(createVO);
|
||||
}
|
||||
|
||||
@OperateLog
|
||||
@Operation(summary = "编辑发票信息 @author 善逸")
|
||||
@PostMapping("/oa/invoice/update")
|
||||
@SaCheckPermission("oa:invoice:update")
|
||||
@OperateLog
|
||||
public ResponseDTO<String> updateInvoice(@RequestBody @Valid InvoiceUpdateForm updateVO) {
|
||||
return invoiceService.updateInvoice(updateVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除发票信息 @author 善逸")
|
||||
@GetMapping("/invoice/delete/{invoiceId}")
|
||||
@SaCheckPermission("oa:invoice:delete")
|
||||
public ResponseDTO<String> deleteInvoice(@PathVariable Long invoiceId) {
|
||||
return invoiceService.deleteInvoice(invoiceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询列表 @author lidoudou")
|
||||
@GetMapping("/oa/invoice/query/list/{enterpriseId}")
|
||||
@SaCheckPermission("oa:invoice:query")
|
||||
public ResponseDTO<List<InvoiceVO>> queryList(@PathVariable Long enterpriseId) {
|
||||
return invoiceService.queryList(enterpriseId);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.invoice.dao;
|
||||
package net.lab1024.sa.admin.module.business.oa.invoice;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -7,6 +7,7 @@ import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.oa.invoice.domain.InvoiceVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -20,6 +21,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface InvoiceDao extends BaseMapper<InvoiceEntity> {
|
||||
|
||||
/**
|
@ -1,11 +1,10 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.invoice.service;
|
||||
package net.lab1024.sa.admin.module.business.oa.invoice;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.admin.module.business.oa.enterprise.service.EnterpriseService;
|
||||
import net.lab1024.sa.admin.module.business.oa.enterprise.EnterpriseService;
|
||||
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.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
@ -27,6 +27,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
||||
|
||||
// ================================= 数据范围相关 【子表】 =================================
|
||||
|
@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface NoticeTypeDao extends BaseMapper<NoticeTypeEntity> {
|
||||
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public class NoticeService {
|
||||
noticeVisibleRange.setDataName(employeeEntity == null ? StringConst.EMPTY : employeeEntity.getActualName());
|
||||
} else {
|
||||
DepartmentVO departmentVO = departmentService.getDepartmentById(noticeVisibleRange.getDataId());
|
||||
noticeVisibleRange.setDataName(departmentVO == null ? StringConst.EMPTY : departmentVO.getDepartmentName());
|
||||
noticeVisibleRange.setDataName(departmentVO == null ? StringConst.EMPTY : departmentVO.getName());
|
||||
}
|
||||
}
|
||||
updateFormVO.setVisibleRangeList(noticeVisibleRangeList);
|
||||
|
@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @Date 2020/11/28 20:59:17
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -89,6 +89,7 @@ public class DataScopeSqlConfigService {
|
||||
|
||||
/**
|
||||
* 根据调用的方法获取,此方法的配置信息
|
||||
*
|
||||
*/
|
||||
public DataScopeSqlConfig getSqlConfig(String method) {
|
||||
return this.dataScopeMethodMap.get(method);
|
||||
@ -124,7 +125,7 @@ public class DataScopeSqlConfigService {
|
||||
log.warn("data scope custom strategy class:{} ,bean is null", sqlConfigDTO.getJoinSqlImplClazz());
|
||||
return "";
|
||||
}
|
||||
return powerStrategy.getCondition(viewTypeEnum, paramMap, sqlConfigDTO);
|
||||
return powerStrategy.getCondition(viewTypeEnum,paramMap, sqlConfigDTO);
|
||||
}
|
||||
if (DataScopeWhereInTypeEnum.EMPLOYEE == sqlConfigDTO.getDataScopeWhereInType()) {
|
||||
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(viewTypeEnum, employeeId);
|
||||
|
@ -56,7 +56,6 @@ public class DataScopeViewService {
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||
return this.getDepartmentAndSubEmployeeIdList(employeeId);
|
||||
}
|
||||
// 可以查看所有员工数据
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.lab1024.sa.admin.module.system.department.domain.entity.DepartmentEnt
|
||||
import net.lab1024.sa.admin.module.system.department.domain.vo.DepartmentVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -17,6 +18,7 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
||||
|
||||
@ -31,5 +33,4 @@ public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
||||
*/
|
||||
List<DepartmentVO> listAll();
|
||||
|
||||
DepartmentVO selectDepartmentVO(@Param("departmentId")Long departmentId);
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ public class DepartmentEntity {
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String departmentName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 负责人员工 id
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private Long managerId;
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@ public class DepartmentAddForm {
|
||||
@Schema(description = "部门名称")
|
||||
@Length(min = 1, max = 50, message = "请输入正确的部门名称(1-50个字符)")
|
||||
@NotNull(message = "请输入正确的部门名称(1-50个字符)")
|
||||
private String departmentName;
|
||||
private String name;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@NotNull(message = "排序值")
|
||||
|
@ -3,7 +3,6 @@ package net.lab1024.sa.admin.module.system.department.domain.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@ -13,18 +12,16 @@ import java.time.LocalDateTime;
|
||||
* @Date 2022-01-12 20:37:48
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DepartmentVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class DepartmentVO {
|
||||
|
||||
@Schema(description = "部门id")
|
||||
private Long departmentId;
|
||||
|
||||
@Schema(description = "部门名称")
|
||||
private String departmentName;
|
||||
private String name;
|
||||
|
||||
@Schema(description = "部门负责人姓名")
|
||||
private String managerName;
|
||||
|
@ -29,7 +29,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022-01-12 20:37:48
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -42,7 +42,7 @@ public class DepartmentCacheManager {
|
||||
log.info("clear " + cache);
|
||||
}
|
||||
|
||||
@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)
|
||||
@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)
|
||||
public void clearCache() {
|
||||
logClearInfo(AdminCacheConst.Department.DEPARTMENT_LIST_CACHE);
|
||||
}
|
||||
@ -56,8 +56,19 @@ public class DepartmentCacheManager {
|
||||
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)
|
||||
public List<DepartmentTreeVO> getDepartmentTree() {
|
||||
@ -67,6 +78,7 @@ public class DepartmentCacheManager {
|
||||
|
||||
/**
|
||||
* 缓存某个部门的下级id列表
|
||||
*
|
||||
*/
|
||||
@Cacheable(AdminCacheConst.Department.DEPARTMENT_SELF_CHILDREN_CACHE)
|
||||
public List<Long> getDepartmentSelfAndChildren(Long departmentId) {
|
||||
@ -77,6 +89,7 @@ public class DepartmentCacheManager {
|
||||
|
||||
/**
|
||||
* 部门的路径名称
|
||||
*
|
||||
*/
|
||||
@Cacheable(AdminCacheConst.Department.DEPARTMENT_PATH_CACHE)
|
||||
public Map<Long, String> getDepartmentPathMap() {
|
||||
@ -97,21 +110,22 @@ public class DepartmentCacheManager {
|
||||
*/
|
||||
private String buildDepartmentPath(DepartmentVO departmentVO, Map<Long, DepartmentVO> departmentMap) {
|
||||
if (Objects.equals(departmentVO.getParentId(), NumberUtils.LONG_ZERO)) {
|
||||
return departmentVO.getDepartmentName();
|
||||
return departmentVO.getName();
|
||||
}
|
||||
//父节点
|
||||
DepartmentVO parentDepartment = departmentMap.get(departmentVO.getParentId());
|
||||
if (parentDepartment == null) {
|
||||
return departmentVO.getDepartmentName();
|
||||
return departmentVO.getName();
|
||||
}
|
||||
String pathName = buildDepartmentPath(parentDepartment, departmentMap);
|
||||
return pathName + "/" + departmentVO.getDepartmentName();
|
||||
return pathName + "/" + departmentVO.getName();
|
||||
|
||||
}
|
||||
// ---------------------- 构造树的一些方法 ------------------------------
|
||||
|
||||
/**
|
||||
* 构建部门树结构
|
||||
*
|
||||
*/
|
||||
public List<DepartmentTreeVO> buildTree(List<DepartmentVO> voList) {
|
||||
if (CollectionUtils.isEmpty(voList)) {
|
||||
@ -126,7 +140,7 @@ public class DepartmentCacheManager {
|
||||
return treeVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 构建所有根节点的下级树形结构
|
||||
* 返回值为层序遍历结果
|
||||
* [由于departmentDao中listAll给出数据根据Sort降序 所以同一层中Sort值较大的优先遍历]
|
||||
@ -134,7 +148,7 @@ public class DepartmentCacheManager {
|
||||
private List<Long> recursiveBuildTree(List<DepartmentTreeVO> nodeList, List<DepartmentVO> allDepartmentList) {
|
||||
int nodeSize = nodeList.size();
|
||||
List<Long> childIdList = new ArrayList<>();
|
||||
for (int i = 0; i < nodeSize; i++) {
|
||||
for(int i = 0; i < nodeSize; i++) {
|
||||
int preIndex = i - 1;
|
||||
int nextIndex = i + 1;
|
||||
DepartmentTreeVO node = nodeList.get(i);
|
||||
@ -153,14 +167,14 @@ public class DepartmentCacheManager {
|
||||
tempChildIdList = this.recursiveBuildTree(children, allDepartmentList);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(node.getSelfAndAllChildrenIdList())) {
|
||||
if(CollectionUtils.isEmpty(node.getSelfAndAllChildrenIdList())) {
|
||||
node.setSelfAndAllChildrenIdList(
|
||||
new ArrayList<>()
|
||||
);
|
||||
}
|
||||
node.getSelfAndAllChildrenIdList().add(node.getDepartmentId());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(tempChildIdList)) {
|
||||
if(CollectionUtils.isNotEmpty(tempChildIdList)) {
|
||||
node.getSelfAndAllChildrenIdList().addAll(tempChildIdList);
|
||||
childIdList.addAll(tempChildIdList);
|
||||
}
|
||||
@ -168,7 +182,7 @@ public class DepartmentCacheManager {
|
||||
}
|
||||
|
||||
// 保证本层遍历顺序
|
||||
for (int i = nodeSize - 1; i >= 0; i--) {
|
||||
for(int i = nodeSize - 1; i >= 0; i--) {
|
||||
childIdList.add(0, nodeList.get(i).getDepartmentId());
|
||||
}
|
||||
|
||||
@ -178,6 +192,7 @@ public class DepartmentCacheManager {
|
||||
|
||||
/**
|
||||
* 获取子元素
|
||||
*
|
||||
*/
|
||||
private List<DepartmentTreeVO> getChildren(Long departmentId, List<DepartmentVO> voList) {
|
||||
List<DepartmentVO> childrenEntityList = voList.stream().filter(e -> departmentId.equals(e.getParentId())).collect(Collectors.toList());
|
||||
@ -190,6 +205,7 @@ public class DepartmentCacheManager {
|
||||
|
||||
/**
|
||||
* 通过部门id,获取当前以及下属部门
|
||||
*
|
||||
*/
|
||||
public List<Long> selfAndChildrenIdList(Long departmentId, List<DepartmentVO> voList) {
|
||||
List<Long> selfAndChildrenIdList = Lists.newArrayList();
|
||||
|
@ -14,7 +14,10 @@ import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 部门 service
|
||||
@ -23,7 +26,7 @@ import java.util.List;
|
||||
* @Date 2022-01-12 20:37:48
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Service
|
||||
public class DepartmentService {
|
||||
@ -41,6 +44,7 @@ public class DepartmentService {
|
||||
|
||||
/**
|
||||
* 新增添加部门
|
||||
*
|
||||
*/
|
||||
|
||||
public ResponseDTO<String> addDepartment(DepartmentAddForm departmentAddForm) {
|
||||
@ -53,6 +57,7 @@ public class DepartmentService {
|
||||
|
||||
/**
|
||||
* 更新部门信息
|
||||
*
|
||||
*/
|
||||
public ResponseDTO<String> updateDepartment(DepartmentUpdateForm updateDTO) {
|
||||
if (updateDTO.getParentId() == null) {
|
||||
@ -73,6 +78,7 @@ public class DepartmentService {
|
||||
* 根据id删除部门
|
||||
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
||||
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
||||
*
|
||||
*/
|
||||
public ResponseDTO<String> deleteDepartment(Long departmentId) {
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
||||
@ -116,6 +122,7 @@ public class DepartmentService {
|
||||
|
||||
/**
|
||||
* 自身以及所有下级的部门id列表
|
||||
*
|
||||
*/
|
||||
public List<Long> selfAndChildrenIdList(Long departmentId) {
|
||||
return departmentCacheManager.getDepartmentSelfAndChildren(departmentId);
|
||||
@ -124,6 +131,7 @@ public class DepartmentService {
|
||||
|
||||
/**
|
||||
* 获取所有部门
|
||||
*
|
||||
*/
|
||||
public List<DepartmentVO> listAll() {
|
||||
return departmentCacheManager.getDepartmentList();
|
||||
@ -132,9 +140,10 @@ public class DepartmentService {
|
||||
|
||||
/**
|
||||
* 获取部门
|
||||
*
|
||||
*/
|
||||
public DepartmentVO getDepartmentById(Long departmentId) {
|
||||
return departmentDao.selectDepartmentVO(departmentId);
|
||||
return departmentCacheManager.getDepartmentMap().get(departmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,4 +153,38 @@ public class DepartmentService {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class EmployeeController {
|
||||
@Operation(summary = "查询员工-根据部门id @author 卓大")
|
||||
@GetMapping("/employee/getAllEmployeeByDepartmentId/{departmentId}")
|
||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(@PathVariable Long departmentId) {
|
||||
return employeeService.getAllEmployeeByDepartmentId(departmentId);
|
||||
return employeeService.getAllEmployeeByDepartmentId(departmentId, Boolean.FALSE);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询所有员工 @author 卓大")
|
||||
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
/**
|
||||
* 查询员工列表
|
||||
@ -34,7 +35,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
List<EmployeeVO> selectEmployeeByDisabledAndDeleted(@Param("disabledFlag") Boolean disabledFlag, @Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 更新单个
|
||||
* 更新禁用状态
|
||||
*/
|
||||
void updateDisableFlag(@Param("employeeId") Long employeeId, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
|
@ -23,12 +23,6 @@ public class EmployeeEntity {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long employeeId;
|
||||
|
||||
/**
|
||||
* 唯一id
|
||||
*/
|
||||
private String employeeUid;
|
||||
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
*/
|
||||
|
@ -53,4 +53,4 @@ public class EmployeeUpdateCenterForm {
|
||||
@Schema(description = "备注")
|
||||
@Length(max = 200, message = "备注最多200字符")
|
||||
private String remark;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package net.lab1024.sa.admin.module.system.employee.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.base.common.util.SmartVerificationUtil;
|
||||
|
||||
/**
|
||||
* 修改密码所需参数
|
||||
|
@ -138,20 +138,16 @@ public class EmployeeService {
|
||||
}
|
||||
|
||||
EmployeeEntity entity = SmartBeanUtil.copy(employeeAddForm, EmployeeEntity.class);
|
||||
// 员工uid
|
||||
String employeeUid = cn.hutool.core.lang.UUID.randomUUID(true).toString(true);
|
||||
entity.setEmployeeUid(employeeUid);
|
||||
|
||||
// 设置密码 随机密码
|
||||
String randomPassword = securityPasswordService.randomPassword();
|
||||
String generateSaltPassword = this.generateSaltPassword(randomPassword, employeeUid);
|
||||
entity.setLoginPwd(SecurityPasswordService.getEncryptPwd(generateSaltPassword));
|
||||
// 设置密码 默认密码
|
||||
String password = securityPasswordService.randomPassword();
|
||||
entity.setLoginPwd(SecurityPasswordService.getEncryptPwd(password));
|
||||
|
||||
// 保存数据
|
||||
entity.setDeletedFlag(Boolean.FALSE);
|
||||
employeeManager.saveEmployee(entity, employeeAddForm.getRoleIdList());
|
||||
|
||||
return ResponseDTO.ok(randomPassword);
|
||||
return ResponseDTO.ok(password);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,8 +239,12 @@ public class EmployeeService {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新登录人头像
|
||||
*
|
||||
* @param employeeUpdateAvatarForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> updateAvatar(EmployeeUpdateAvatarForm employeeUpdateAvatarForm) {
|
||||
Long employeeId = employeeUpdateAvatarForm.getEmployeeId();
|
||||
@ -346,12 +346,12 @@ public class EmployeeService {
|
||||
}
|
||||
|
||||
// 校验原始密码
|
||||
if (!SecurityPasswordService.matchesPwd(this.generateSaltPassword(updatePasswordForm.getOldPassword(), employeeEntity.getEmployeeUid()), employeeEntity.getLoginPwd())) {
|
||||
if (!SecurityPasswordService.matchesPwd(updatePasswordForm.getOldPassword(),employeeEntity.getLoginPwd()) ) {
|
||||
return ResponseDTO.userErrorParam("原密码有误,请重新输入");
|
||||
}
|
||||
|
||||
// 新旧密码相同
|
||||
if (Objects.equals(updatePasswordForm.getOldPassword(), updatePasswordForm.getNewPassword())) {
|
||||
if (Objects.equals(updatePasswordForm.getOldPassword(), updatePasswordForm.getNewPassword()) ){
|
||||
return ResponseDTO.userErrorParam("新密码与原始密码相同,请重新输入");
|
||||
}
|
||||
|
||||
@ -362,13 +362,14 @@ public class EmployeeService {
|
||||
}
|
||||
|
||||
// 根据三级等保规则,校验密码是否重复
|
||||
ResponseDTO<String> passwordRepeatTimes = securityPasswordService.validatePasswordRepeatTimes(requestUser, this.generateSaltPassword(updatePasswordForm.getNewPassword(), employeeEntity.getEmployeeUid()));
|
||||
ResponseDTO<String> passwordRepeatTimes = securityPasswordService.validatePasswordRepeatTimes(requestUser, updatePasswordForm.getNewPassword());
|
||||
if (!passwordRepeatTimes.getOk()) {
|
||||
return ResponseDTO.error(passwordRepeatTimes);
|
||||
}
|
||||
|
||||
|
||||
// 更新密码
|
||||
String newEncryptPassword = SecurityPasswordService.getEncryptPwd(this.generateSaltPassword(updatePasswordForm.getNewPassword(), employeeEntity.getEmployeeUid()));
|
||||
String newEncryptPassword = SecurityPasswordService.getEncryptPwd(updatePasswordForm.getNewPassword());
|
||||
EmployeeEntity updateEntity = new EmployeeEntity();
|
||||
updateEntity.setEmployeeId(employeeId);
|
||||
updateEntity.setLoginPwd(newEncryptPassword);
|
||||
@ -383,8 +384,11 @@ public class EmployeeService {
|
||||
/**
|
||||
* 获取某个部门的员工信息
|
||||
*/
|
||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId) {
|
||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, Boolean.FALSE);
|
||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId, Boolean disabledFlag) {
|
||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, disabledFlag);
|
||||
if (disabledFlag != null) {
|
||||
employeeEntityList = employeeEntityList.stream().filter(e -> e.getDisabledFlag().equals(disabledFlag)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(employeeEntityList)) {
|
||||
return ResponseDTO.ok(Collections.emptyList());
|
||||
@ -395,7 +399,7 @@ public class EmployeeService {
|
||||
List<EmployeeVO> voList = employeeEntityList.stream().map(e -> {
|
||||
EmployeeVO employeeVO = SmartBeanUtil.copy(e, EmployeeVO.class);
|
||||
if (department != null) {
|
||||
employeeVO.setDepartmentName(department.getDepartmentName());
|
||||
employeeVO.setDepartmentName(department.getName());
|
||||
}
|
||||
return employeeVO;
|
||||
}).collect(Collectors.toList());
|
||||
@ -407,14 +411,8 @@ public class EmployeeService {
|
||||
* 重置密码
|
||||
*/
|
||||
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 saltPassword = this.generateSaltPassword(password, employeeEntity.getEmployeeUid());
|
||||
employeeDao.updatePassword(employeeId, SecurityPasswordService.getEncryptPwd(saltPassword));
|
||||
employeeDao.updatePassword(employeeId, SecurityPasswordService.getEncryptPwd(password));
|
||||
return ResponseDTO.ok(password);
|
||||
}
|
||||
|
||||
@ -431,17 +429,7 @@ public class EmployeeService {
|
||||
* 根据登录名获取员工
|
||||
*/
|
||||
public EmployeeEntity getByLoginName(String loginName) {
|
||||
return employeeDao.getByLoginName(loginName, false);
|
||||
return employeeDao.getByLoginName(loginName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成加盐密码
|
||||
* 格式为:[password]_[uid大写]_[uid小写]
|
||||
*/
|
||||
public String generateSaltPassword(String password, String employeeUid) {
|
||||
return password + StringConst.UNDERLINE +
|
||||
employeeUid.toUpperCase() +
|
||||
StringConst.UNDERLINE +
|
||||
employeeUid.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
* @Date 2021-12-15 21:05:46
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@RestController
|
||||
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_LOGIN)
|
||||
@ -57,7 +57,7 @@ public class LoginController {
|
||||
return ResponseDTO.ok(loginResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "退出登录 @author 卓大")
|
||||
@Operation(summary = "退出登陆 @author 卓大")
|
||||
@GetMapping("/login/logout")
|
||||
public ResponseDTO<String> logout() {
|
||||
return loginService.logout(SmartRequestUtil.getRequestUser());
|
||||
|
@ -7,8 +7,6 @@ import net.lab1024.sa.base.common.enumeration.GenderEnum;
|
||||
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
|
||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 请求员工登录信息
|
||||
*
|
||||
@ -19,7 +17,7 @@ import java.io.Serializable;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class RequestEmployee implements RequestUser, Serializable {
|
||||
public class RequestEmployee implements RequestUser {
|
||||
|
||||
@Schema(description = "员工id")
|
||||
private Long employeeId;
|
||||
|
@ -1,173 +0,0 @@
|
||||
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,15 +6,17 @@ import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.extra.servlet.JakartaServletUtil;
|
||||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
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.service.EmployeeService;
|
||||
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.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.role.domain.vo.RoleVO;
|
||||
import net.lab1024.sa.admin.module.system.role.service.RoleEmployeeService;
|
||||
@ -37,6 +39,7 @@ 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.config.ConfigKeyEnum;
|
||||
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.LoginLogService;
|
||||
import net.lab1024.sa.base.module.support.loginlog.domain.LoginLogEntity;
|
||||
@ -45,22 +48,21 @@ 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.redis.RedisService;
|
||||
import net.lab1024.sa.base.module.support.securityprotect.domain.LoginFailEntity;
|
||||
import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService;
|
||||
import net.lab1024.sa.base.module.support.securityprotect.service.SecurityLoginService;
|
||||
import net.lab1024.sa.base.module.support.securityprotect.service.SecurityPasswordService;
|
||||
import net.lab1024.sa.base.module.support.securityprotect.service.*;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @Author 1024创新实验室: 卓大
|
||||
* @Date 2025-05-03 22:56:34
|
||||
* @Author 1024创新实验室: 开云
|
||||
* @Date 2021-12-01 22:56:34
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
@ -74,9 +76,28 @@ public class LoginService implements StpInterface {
|
||||
*/
|
||||
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
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private CaptchaService captchaService;
|
||||
|
||||
@ -98,6 +119,9 @@ public class LoginService implements StpInterface {
|
||||
@Resource
|
||||
private SecurityPasswordService protectPasswordService;
|
||||
|
||||
@Resource
|
||||
private IFileStorageService fileStorageService;
|
||||
|
||||
@Resource
|
||||
private ApiEncryptService apiEncryptService;
|
||||
|
||||
@ -110,9 +134,6 @@ public class LoginService implements StpInterface {
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Resource
|
||||
private LoginManager loginManager;
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
@ -121,7 +142,7 @@ public class LoginService implements StpInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* 员工登录
|
||||
* 员工登陆
|
||||
*
|
||||
* @return 返回用户登录信息
|
||||
*/
|
||||
@ -146,12 +167,12 @@ public class LoginService implements StpInterface {
|
||||
|
||||
// 验证账号状态
|
||||
if (employeeEntity.getDeletedFlag()) {
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已删除", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已删除", LoginLogResultEnum.LOGIN_FAIL);
|
||||
return ResponseDTO.userErrorParam("您的账号已被删除,请联系工作人员!");
|
||||
}
|
||||
|
||||
if (employeeEntity.getDisabledFlag()) {
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已禁用", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已禁用", LoginLogResultEnum.LOGIN_FAIL);
|
||||
return ResponseDTO.userErrorParam("您的账号已被禁用,请联系工作人员!");
|
||||
}
|
||||
|
||||
@ -185,9 +206,9 @@ public class LoginService implements StpInterface {
|
||||
}
|
||||
|
||||
// 密码错误
|
||||
if (!SecurityPasswordService.matchesPwd(employeeService.generateSaltPassword(requestPassword, employeeEntity.getEmployeeUid()), employeeEntity.getLoginPwd())) {
|
||||
if ( !SecurityPasswordService.matchesPwd(requestPassword,employeeEntity.getLoginPwd()) ) {
|
||||
// 记录登录失败
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "密码错误", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "密码错误", LoginLogResultEnum.LOGIN_FAIL);
|
||||
// 记录等级保护次数
|
||||
String msg = securityLoginService.recordLoginFail(employeeEntity.getEmployeeId(), UserTypeEnum.ADMIN_EMPLOYEE, employeeEntity.getLoginName(), loginFailEntityResponseDTO.getData());
|
||||
return msg == null ? ResponseDTO.userErrorParam("登录名或密码错误!") : ResponseDTO.error(UserErrorCode.LOGIN_FAIL_WILL_LOCK, msg);
|
||||
@ -203,7 +224,10 @@ public class LoginService implements StpInterface {
|
||||
}
|
||||
|
||||
// 获取员工信息
|
||||
RequestEmployee requestEmployee = loginManager.loadLoginInfo(employeeEntity);
|
||||
RequestEmployee requestEmployee = loadLoginInfo(employeeEntity);
|
||||
|
||||
// 放入缓存
|
||||
loginEmployeeCache.put(employeeEntity.getEmployeeId(), requestEmployee);
|
||||
|
||||
// 移除登录失败
|
||||
securityLoginService.removeLoginFail(employeeEntity.getEmployeeId(), UserTypeEnum.ADMIN_EMPLOYEE);
|
||||
@ -213,13 +237,13 @@ public class LoginService implements StpInterface {
|
||||
LoginResultVO loginResultVO = getLoginResult(requestEmployee, token);
|
||||
|
||||
//保存登录记录
|
||||
saveLoginLog(employeeEntity, ip, userAgent, superPasswordFlag ? "万能密码登录" : StringConst.EMPTY, LoginLogResultEnum.LOGIN_SUCCESS, loginDeviceEnum);
|
||||
saveLoginLog(employeeEntity, ip, userAgent, superPasswordFlag ? "万能密码登录" : loginDeviceEnum.getDesc(), LoginLogResultEnum.LOGIN_SUCCESS);
|
||||
|
||||
// 设置 token
|
||||
loginResultVO.setToken(token);
|
||||
|
||||
// 更新用户权限
|
||||
loginManager.loadUserPermission(employeeEntity.getEmployeeId());
|
||||
// 清除权限缓存
|
||||
permissionCache.remove(employeeEntity.getEmployeeId());
|
||||
|
||||
return ResponseDTO.ok(loginResultVO);
|
||||
}
|
||||
@ -238,6 +262,10 @@ public class LoginService implements StpInterface {
|
||||
List<MenuVO> menuAndPointsList = roleMenuService.getMenuList(roleList.stream().map(RoleVO::getRoleId).collect(Collectors.toList()), requestEmployee.getAdministratorFlag());
|
||||
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);
|
||||
if (loginLogVO != null) {
|
||||
@ -262,7 +290,33 @@ 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) {
|
||||
if (loginId == null) {
|
||||
@ -274,7 +328,17 @@ public class LoginService implements StpInterface {
|
||||
return null;
|
||||
}
|
||||
|
||||
RequestEmployee requestEmployee = loginManager.getRequestEmployee(requestEmployeeId);
|
||||
RequestEmployee requestEmployee = loginEmployeeCache.get(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
|
||||
requestEmployee.setUserAgent(JakartaServletUtil.getHeaderIgnoreCase(request, RequestHeaderConst.USER_AGENT));
|
||||
@ -317,8 +381,8 @@ public class LoginService implements StpInterface {
|
||||
// sa token 登出
|
||||
StpUtil.logout();
|
||||
|
||||
// 清除用户登录信息缓存和权限信息
|
||||
this.clearLoginEmployeeCache(requestUser.getUserId());
|
||||
// 清空登录信息缓存
|
||||
loginEmployeeCache.remove(requestUser.getUserId());
|
||||
|
||||
//保存登出日志
|
||||
LoginLogEntity loginEntity = LoginLogEntity.builder()
|
||||
@ -336,10 +400,18 @@ public class LoginService implements StpInterface {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除员工登录缓存
|
||||
*/
|
||||
public void clearLoginEmployeeCache(Long employeeId) {
|
||||
// 清空登录信息缓存
|
||||
loginEmployeeCache.remove(employeeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存登录日志
|
||||
*/
|
||||
private void saveLoginLog(EmployeeEntity employeeEntity, String ip, String userAgent, String remark, LoginLogResultEnum result, LoginDeviceEnum loginDeviceEnum) {
|
||||
private void saveLoginLog(EmployeeEntity employeeEntity, String ip, String userAgent, String remark, LoginLogResultEnum result) {
|
||||
LoginLogEntity loginEntity = LoginLogEntity.builder()
|
||||
.userId(employeeEntity.getEmployeeId())
|
||||
.userType(UserTypeEnum.ADMIN_EMPLOYEE.getValue())
|
||||
@ -348,7 +420,6 @@ public class LoginService implements StpInterface {
|
||||
.loginIp(ip)
|
||||
.loginIpRegion(SmartIpUtil.getRegion(ip))
|
||||
.remark(remark)
|
||||
.loginDevice(loginDeviceEnum.getDesc())
|
||||
.loginResult(result.getValue())
|
||||
.createTime(LocalDateTime.now())
|
||||
.build();
|
||||
@ -363,7 +434,12 @@ public class LoginService implements StpInterface {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
UserPermission userPermission = loginManager.getUserPermission(employeeId);
|
||||
UserPermission userPermission = permissionCache.get(employeeId);
|
||||
if (userPermission == null) {
|
||||
userPermission = getUserPermission(employeeId);
|
||||
permissionCache.put(employeeId, userPermission);
|
||||
}
|
||||
|
||||
return userPermission.getPermissionList();
|
||||
}
|
||||
|
||||
@ -374,10 +450,51 @@ public class LoginService implements StpInterface {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
UserPermission userPermission = loginManager.getUserPermission(employeeId);
|
||||
UserPermission userPermission = permissionCache.get(employeeId);
|
||||
if (userPermission == null) {
|
||||
userPermission = getUserPermission(employeeId);
|
||||
permissionCache.put(employeeId, userPermission);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送 邮箱 验证码
|
||||
@ -472,9 +589,4 @@ public class LoginService implements StpInterface {
|
||||
String redisVerificationCodeKey = redisService.generateRedisKey(RedisKeyConst.Support.LOGIN_VERIFICATION_CODE, UserTypeEnum.ADMIN_EMPLOYEE.getValue() + RedisKeyConst.SEPARATOR + employeeId);
|
||||
redisService.delete(redisVerificationCodeKey);
|
||||
}
|
||||
|
||||
public void clearLoginEmployeeCache(Long employeeId) {
|
||||
loginManager.clearUserPermission(employeeId);
|
||||
loginManager.clearUserLoginInfo(employeeId);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface MenuDao extends BaseMapper<MenuEntity> {
|
||||
|
||||
/**
|
||||
|
@ -15,7 +15,6 @@ import net.lab1024.sa.base.common.code.SystemErrorCode;
|
||||
import net.lab1024.sa.base.common.domain.RequestUrlVO;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
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.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -135,10 +134,6 @@ public class MenuService {
|
||||
* @return true 重复 false 未重复
|
||||
*/
|
||||
public <T extends MenuBaseForm> Boolean validateWebPerms(T menuDTO) {
|
||||
if(SmartStringUtil.isEmpty(menuDTO.getWebPerms())){
|
||||
return false;
|
||||
}
|
||||
|
||||
MenuEntity menu = menuDao.getByWebPerms(menuDTO.getWebPerms(), Boolean.FALSE);
|
||||
if (menuDTO instanceof MenuAddForm) {
|
||||
return menu != null;
|
||||
|
@ -1,54 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface PositionDao extends BaseMapper<PositionEntity> {
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ public class PositionEntity {
|
||||
/**
|
||||
* 职级
|
||||
*/
|
||||
private String positionLevel;
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
|
@ -21,7 +21,7 @@ public class PositionAddForm {
|
||||
private String positionName;
|
||||
|
||||
@Schema(description = "职级")
|
||||
private String positionLevel;
|
||||
private String level;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@NotNull(message = "排序不能为空")
|
||||
|
@ -23,7 +23,7 @@ public class PositionVO {
|
||||
private String positionName;
|
||||
|
||||
@Schema(description = "职级")
|
||||
private String positionLevel;
|
||||
private String level;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
@ -16,6 +16,7 @@ import net.lab1024.sa.admin.module.system.role.domain.entity.RoleEntity;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface RoleDao extends BaseMapper<RoleEntity> {
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface RoleDataScopeDao extends BaseMapper<RoleDataScopeEntity> {
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,7 @@ import java.util.Set;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface RoleEmployeeDao extends BaseMapper<RoleEmployeeEntity> {
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface RoleMenuDao extends BaseMapper<RoleMenuEntity> {
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,11 @@ package net.lab1024.sa.admin.module.system.role.manager;
|
||||
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.domain.entity.RoleEmployeeEntity;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色员工 manager
|
||||
|
@ -22,6 +22,7 @@ import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -72,7 +73,7 @@ public class RoleEmployeeService {
|
||||
List<Long> departmentIdList = employeeList.stream().filter(e -> e != null && e.getDepartmentId() != null).map(EmployeeVO::getDepartmentId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(departmentIdList)) {
|
||||
List<DepartmentEntity> departmentEntities = departmentDao.selectBatchIds(departmentIdList);
|
||||
Map<Long, String> departmentIdNameMap = departmentEntities.stream().collect(Collectors.toMap(DepartmentEntity::getDepartmentId, DepartmentEntity::getDepartmentName));
|
||||
Map<Long, String> departmentIdNameMap = departmentEntities.stream().collect(Collectors.toMap(DepartmentEntity::getDepartmentId, DepartmentEntity::getName));
|
||||
employeeList.forEach(e -> {
|
||||
e.setDepartmentName(departmentIdNameMap.getOrDefault(e.getDepartmentId(), StringConst.EMPTY));
|
||||
});
|
||||
|
@ -8,24 +8,26 @@ import jakarta.validation.Valid;
|
||||
import net.lab1024.sa.base.common.controller.SupportBaseController;
|
||||
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.constant.SwaggerTagConst;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.*;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据字典 Controller
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Tag(name = SwaggerTagConst.Support.DICT)
|
||||
@RestController
|
||||
@ -34,106 +36,60 @@ public class AdminDictController extends SupportBaseController {
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
|
||||
// ------------------- 获取全部数据 -------------------
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
|
||||
@Operation(summary = "获取全部数据(供前端缓存使用) @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/getAllDictData")
|
||||
public ResponseDTO<List<DictDataVO>> getAll() {
|
||||
return ResponseDTO.ok(dictService.getAll());
|
||||
@Operation(summary = "分页查询数据字典KEY - @author 罗伊")
|
||||
@PostMapping("/dict/key/query")
|
||||
public ResponseDTO<PageResult<DictKeyVO>> keyQuery(@Valid @RequestBody DictKeyQueryForm queryForm) {
|
||||
return dictService.keyQuery(queryForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有字典code @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/getAllDict")
|
||||
public ResponseDTO<List<DictVO>> getAllDict() {
|
||||
return ResponseDTO.ok(dictService.getAllDict());
|
||||
}
|
||||
|
||||
// ------------------- 字典 -------------------
|
||||
|
||||
@Operation(summary = "分页查询 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/queryPage")
|
||||
@SaCheckPermission("support:dict:query")
|
||||
public ResponseDTO<PageResult<DictVO>> queryPage(@RequestBody @Valid DictQueryForm queryForm) {
|
||||
return ResponseDTO.ok(dictService.queryPage(queryForm));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/add")
|
||||
@Operation(summary = "数据字典KEY-添加- @author 罗伊")
|
||||
@PostMapping("/dict/key/add")
|
||||
@SaCheckPermission("support:dict:add")
|
||||
public ResponseDTO<String> add(@RequestBody @Valid DictAddForm addForm) {
|
||||
return dictService.add(addForm);
|
||||
public ResponseDTO<String> keyAdd(@Valid @RequestBody DictKeyAddForm keyAddForm) {
|
||||
return dictService.keyAdd(keyAddForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/update")
|
||||
@SaCheckPermission("support:dict:update")
|
||||
public ResponseDTO<String> update(@RequestBody @Valid DictUpdateForm updateForm) {
|
||||
return dictService.update(updateForm);
|
||||
@Operation(summary = "数据字典缓存-刷新- @author 罗伊")
|
||||
@GetMapping("/dict/cache/refresh")
|
||||
@SaCheckPermission("support:dict:refresh")
|
||||
public ResponseDTO<String> cacheRefresh() {
|
||||
return dictCacheService.cacheRefresh();
|
||||
}
|
||||
|
||||
@Operation(summary = "启用/禁用 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/updateDisabled/{dictId}")
|
||||
@SaCheckPermission("support:dict:updateDisabled")
|
||||
public ResponseDTO<String> updateDisabled(@PathVariable Long dictId) {
|
||||
return dictService.updateDisabled(dictId);
|
||||
@Operation(summary = "数据字典Value-添加- @author 罗伊")
|
||||
@PostMapping("/dict/value/add")
|
||||
public ResponseDTO<String> valueAdd(@Valid @RequestBody DictValueAddForm valueAddForm) {
|
||||
return dictService.valueAdd(valueAddForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "批量删除 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/batchDelete")
|
||||
@Operation(summary = "数据字典KEY-更新- @author 罗伊")
|
||||
@PostMapping("/dict/key/edit")
|
||||
@SaCheckPermission("support:dict:edit")
|
||||
public ResponseDTO<String> keyEdit(@Valid @RequestBody DictKeyUpdateForm keyUpdateForm) {
|
||||
return dictService.keyEdit(keyUpdateForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典Value-更新- @author 罗伊")
|
||||
@PostMapping("/dict/value/edit")
|
||||
public ResponseDTO<String> valueEdit(@Valid @RequestBody DictValueUpdateForm valueUpdateForm) {
|
||||
return dictService.valueEdit(valueUpdateForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典KEY-删除- @author 罗伊")
|
||||
@PostMapping("/dict/key/delete")
|
||||
@SaCheckPermission("support:dict:delete")
|
||||
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
|
||||
return dictService.batchDelete(idList);
|
||||
public ResponseDTO<String> keyDelete(@RequestBody List<Long> keyIdList) {
|
||||
return dictService.keyDelete(keyIdList);
|
||||
}
|
||||
|
||||
@Operation(summary = "单个删除 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/delete/{dictId}")
|
||||
@SaCheckPermission("support:dict:delete")
|
||||
public ResponseDTO<String> delete(@PathVariable Long dictId) {
|
||||
return dictService.delete(dictId);
|
||||
}
|
||||
|
||||
// ------------------- 字典数据 -------------------
|
||||
|
||||
@Operation(summary = "字典数据 分页查询 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/dictData/queryDictData/{dictId}")
|
||||
@SaCheckPermission("support:dictData:query")
|
||||
public ResponseDTO<List<DictDataVO>> queryDictData(@PathVariable Long dictId) {
|
||||
return ResponseDTO.ok(dictService.queryDictData(dictId));
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 启用/禁用 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/dictData/updateDisabled/{dictDataId}")
|
||||
@SaCheckPermission("support:dictData:updateDisabled")
|
||||
public ResponseDTO<String> updateDictDataDisabled(@PathVariable Long dictDataId) {
|
||||
return dictService.updateDictDataDisabled(dictDataId);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 添加 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/dictData/add")
|
||||
@SaCheckPermission("support:dictData:add")
|
||||
public ResponseDTO<String> addDictData(@RequestBody @Valid DictDataAddForm addForm) {
|
||||
return dictService.addDictData(addForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 更新 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/dictData/update")
|
||||
@SaCheckPermission("support:dictData:update")
|
||||
public ResponseDTO<String> updateDictData(@RequestBody @Valid DictDataUpdateForm updateForm) {
|
||||
return dictService.updateDictData(updateForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 批量删除 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/dictData/batchDelete")
|
||||
@SaCheckPermission("support:dictData:delete")
|
||||
public ResponseDTO<String> batchDeleteDictData(@RequestBody ValidateList<Long> idList) {
|
||||
return dictService.batchDeleteDictData(idList);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 单个删除 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/dictData/delete/{dictDataId}")
|
||||
@SaCheckPermission("support:dictData:delete")
|
||||
public ResponseDTO<String> deleteDictData(@PathVariable Long dictDataId) {
|
||||
return dictService.deleteDictData(dictDataId);
|
||||
@Operation(summary = "数据字典Value-删除- @author 罗伊")
|
||||
@PostMapping("/dict/value/delete")
|
||||
public ResponseDTO<String> valueDelete(@RequestBody List<Long> valueIdList) {
|
||||
return dictService.valueDelete(valueIdList);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
*
|
||||
* 网络安全
|
||||
*
|
||||
* @Author 1024创新实验室-主任:卓大
|
||||
|
@ -5,13 +5,12 @@
|
||||
-->
|
||||
<Configuration status="INFO" monitorInterval="30">
|
||||
<Properties>
|
||||
<Property name="log-directory" value="${spring:project.log-directory}"/>
|
||||
<Property name="log-directory" value="${sys:project.log-directory}"/>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="[%blue{%d}][%highlight{%-5p}][%t][%cyan{%c{1.}:%L}] %m %n"
|
||||
disableAnsi="false" noConsoleNoAnsi="false"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
</Console>
|
||||
<RollingFile name="debug" fileName="${log-directory}/debug/debug.log"
|
||||
filePattern="${log-directory}/debug/debug-%d{yyyy-MM-dd}-%i.log">
|
||||
@ -19,7 +18,7 @@
|
||||
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -37,7 +36,7 @@
|
||||
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -55,7 +54,7 @@
|
||||
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -73,7 +72,7 @@
|
||||
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||
@ -87,7 +86,7 @@
|
||||
</RollingFile>
|
||||
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
||||
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -102,9 +101,11 @@
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
|
||||
<logger name="com.alibaba.druid.filter.stat.StatFilter" level="ERROR" additivity="false">
|
||||
<AppenderRef ref="druidSlowSqlLog"/>
|
||||
</logger>
|
||||
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="Console"/>
|
||||
<AppenderRef ref="debug"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.sa.admin.module.business.oa.bank.dao.BankDao">
|
||||
<mapper namespace="net.lab1024.sa.admin.module.business.oa.bank.BankDao">
|
||||
<update id="deleteBank">
|
||||
UPDATE t_oa_bank
|
||||
SET deleted_flag = #{deletedFlag}
|
||||
|
@ -70,7 +70,7 @@
|
||||
<select id="queryPageEmployeeList"
|
||||
resultType="net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo.EnterpriseEmployeeVO">
|
||||
select
|
||||
t_oa_enterprise_employee.enterprise_id,
|
||||
t_oa_enterprise_employee.*,
|
||||
t_oa_enterprise.enterprise_name,
|
||||
t_employee.*,
|
||||
t_employee.actual_name as employeeName
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.sa.admin.module.business.oa.invoice.dao.InvoiceDao">
|
||||
<mapper namespace="net.lab1024.sa.admin.module.business.oa.invoice.InvoiceDao">
|
||||
<update id="deleteInvoice">
|
||||
UPDATE t_oa_invoice
|
||||
SET deleted_flag = #{deletedFlag}
|
||||
|
@ -219,7 +219,7 @@
|
||||
<select id="queryNoticeViewRecordList" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeViewRecordVO">
|
||||
select t_notice_view_record.*,
|
||||
t_employee.actual_name as employeeName,
|
||||
t_department.department_name
|
||||
t_department.name as departmentName
|
||||
from t_notice_view_record
|
||||
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
|
||||
|
@ -6,7 +6,7 @@
|
||||
<select id="listAll" 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
|
||||
parent_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
|
||||
@ -19,16 +19,5 @@
|
||||
WHERE parent_id = #{departmentId}
|
||||
</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>
|
@ -5,7 +5,7 @@
|
||||
<select id="queryEmployee" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
|
||||
SELECT
|
||||
t_employee.*,
|
||||
t_department.department_name
|
||||
t_department.name AS departmentName
|
||||
FROM t_employee
|
||||
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
||||
<where>
|
||||
@ -169,7 +169,7 @@
|
||||
|
||||
<select id="getEmployeeById" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
|
||||
SELECT t_employee.*,
|
||||
t_department.department_name
|
||||
t_department.name AS departmentName
|
||||
FROM t_employee
|
||||
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
||||
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
|
||||
t_employee.*,
|
||||
t_department.department_name
|
||||
t_department.name AS departmentName
|
||||
FROM t_employee
|
||||
LEFT JOIN t_department ON t_department.department_id = t_employee.department_id
|
||||
<where>
|
||||
|
@ -5,12 +5,12 @@
|
||||
-->
|
||||
<Configuration status="INFO" monitorInterval="30">
|
||||
<Properties>
|
||||
<Property name="log-directory" value="${spring:project.log-directory}"/>
|
||||
<Property name="log-directory" value="${sys:project.log-directory}"/>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
</Console>
|
||||
<RollingFile name="debug" fileName="${log-directory}/debug/debug.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="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -36,7 +36,7 @@
|
||||
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -54,7 +54,7 @@
|
||||
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -72,7 +72,7 @@
|
||||
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||
@ -86,7 +86,7 @@
|
||||
</RollingFile>
|
||||
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
||||
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
|
@ -5,12 +5,12 @@
|
||||
-->
|
||||
<Configuration status="INFO" monitorInterval="30">
|
||||
<Properties>
|
||||
<Property name="log-directory" value="${spring:project.log-directory}"/>
|
||||
<Property name="log-directory" value="${sys:project.log-directory}"/>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
</Console>
|
||||
<RollingFile name="debug" fileName="${log-directory}/debug/debug.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="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -36,7 +36,7 @@
|
||||
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -54,7 +54,7 @@
|
||||
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -72,7 +72,7 @@
|
||||
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||
@ -86,7 +86,7 @@
|
||||
</RollingFile>
|
||||
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
||||
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
|
@ -5,12 +5,12 @@
|
||||
-->
|
||||
<Configuration status="INFO" monitorInterval="30">
|
||||
<Properties>
|
||||
<Property name="log-directory" value="${spring:project.log-directory}"/>
|
||||
<Property name="log-directory" value="${sys:project.log-directory}"/>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
</Console>
|
||||
<RollingFile name="debug" fileName="${log-directory}/debug/debug.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="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -36,7 +36,7 @@
|
||||
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -54,7 +54,7 @@
|
||||
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="50 MB"/>
|
||||
@ -72,7 +72,7 @@
|
||||
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||
@ -86,7 +86,7 @@
|
||||
</RollingFile>
|
||||
<RollingFile name="druidSlowSqlLog" fileName="${log-directory}/slow-sql/slow-sql.log"
|
||||
filePattern="${log-directory}/slow-sql/slow-sql-%d{yyyy-MM-dd}-%i.log">
|
||||
<PatternLayout pattern="[%d][%-5p][%t][%c{1.}:%L] %m %n"/>
|
||||
<PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>net.lab1024</groupId>
|
||||
<groupId>net.1024lab</groupId>
|
||||
<artifactId>sa-parent</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
@ -64,6 +64,7 @@
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-redis-jackson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- sa-token end -->
|
||||
|
||||
<dependency>
|
||||
@ -117,25 +118,19 @@
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>p6spy</groupId>
|
||||
<artifactId>p6spy</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- knife4j & SpringDoc -->
|
||||
<dependency>
|
||||
<groupId>com.github.xingfudeshi</groupId>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -164,11 +159,10 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3</artifactId>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
@ -193,6 +187,16 @@
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>jwks-rsa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
@ -216,6 +220,12 @@
|
||||
<dependency>
|
||||
<groupId>cn.idev.excel</groupId>
|
||||
<artifactId>fastexcel</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -223,6 +233,11 @@
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
@ -230,7 +245,12 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-full</artifactId>
|
||||
<artifactId>ooxml-schemas</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -3,7 +3,6 @@ package net.lab1024.sa.base.common.controller;
|
||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
|
||||
/**
|
||||
* 支撑类业务路由基类
|
||||
*
|
||||
|
@ -2,7 +2,6 @@ package net.lab1024.sa.base.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -16,7 +15,7 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class UserPermission implements Serializable {
|
||||
public class UserPermission {
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
|
@ -1,15 +1,18 @@
|
||||
package net.lab1024.sa.base.common.json.deserializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.ObjectCodec;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典反序列化
|
||||
@ -18,13 +21,13 @@ import java.util.List;
|
||||
* @Date 2022-08-12 22:17:53
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
public class DictDataDeserializer extends JsonDeserializer<String> {
|
||||
public class DictValueVoDeserializer extends JsonDeserializer<String> {
|
||||
|
||||
@Override
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
|
||||
List<String> list = new ArrayList<>();
|
||||
ObjectCodec objectCodec = jsonParser.getCodec();
|
||||
JsonNode listOrObjectNode = objectCodec.readTree(jsonParser);
|
@ -20,25 +20,17 @@ public class LongJsonSerializer extends JsonSerializer<Long> {
|
||||
|
||||
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
|
||||
public void serialize(Long value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
|
||||
if (null == value) {
|
||||
gen.writeNull();
|
||||
return;
|
||||
}
|
||||
// 如果超出了 JavaScript 安全整数范围,则序列化为字符串
|
||||
if (value < JS_MIN_SAFE_INTEGER || value > JS_MAX_SAFE_INTEGER) {
|
||||
gen.writeString(Long.toString(value));
|
||||
// js中最大安全整数16位 Number.MAX_SAFE_INTEGER
|
||||
String longStr = String.valueOf(value);
|
||||
if (longStr.length() > 16) {
|
||||
gen.writeString(longStr);
|
||||
} else {
|
||||
// 否则,序列化为数字
|
||||
gen.writeNumber(value);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,11 @@ public class SmartPageUtil {
|
||||
log.error("《存在SQL注入:》 : {}", sortItem.getColumn());
|
||||
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);
|
||||
return page;
|
||||
|
@ -18,9 +18,6 @@ public class SmartRequestUtil {
|
||||
private static final ThreadLocal<RequestUser> REQUEST_THREAD_LOCAL = new ThreadLocal<>();
|
||||
|
||||
public static void setRequestUser(RequestUser requestUser) {
|
||||
if(requestUser == null){
|
||||
return;
|
||||
}
|
||||
REQUEST_THREAD_LOCAL.set(requestUser);
|
||||
}
|
||||
|
||||
|
@ -1,70 +0,0 @@
|
||||
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.CaffeineCacheServiceImpl;
|
||||
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.cache.CacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
|
||||
/**
|
||||
* 缓存配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class CacheConfig {
|
||||
|
||||
private static final String REDIS_CACHE = "redis";
|
||||
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
|
||||
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = REDIS_CACHE)
|
||||
public CacheService redisCacheService() {
|
||||
return new RedisCacheServiceImpl();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = CAFFEINE_CACHE)
|
||||
public CacheService caffeineCacheService() {
|
||||
return new CaffeineCacheServiceImpl();
|
||||
}
|
||||
|
||||
}
|
@ -145,7 +145,7 @@ public class DataSourceConfig {
|
||||
if (dataScopePlugin != null) {
|
||||
pluginsList.add(dataScopePlugin);
|
||||
}
|
||||
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[0]));
|
||||
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[pluginsList.size()]));
|
||||
// 添加字段自动填充处理
|
||||
factoryBean.setGlobalConfig(new GlobalConfig().setBanner(false).setMetaObjectHandler(new MybatisPlusFillHandler()));
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
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 net.lab1024.sa.base.module.support.file.service.FileStorageCloudServiceImpl;
|
||||
import net.lab1024.sa.base.module.support.file.service.FileStorageLocalServiceImpl;
|
||||
@ -10,13 +17,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 文件上传 配置
|
||||
@ -25,16 +25,12 @@ import java.net.URI;
|
||||
* @Date 2019-09-02 23:21:10
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
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_LOCAL = "local";
|
||||
@ -72,18 +68,16 @@ public class FileConfig implements WebMvcConfigurer {
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = MODE_CLOUD)
|
||||
public S3Client initAmazonS3() {
|
||||
return S3Client.builder()
|
||||
.region(Region.AWS_GLOBAL)
|
||||
.endpointOverride(URI.create((urlPrefix.startsWith(HTTPS) ? HTTPS : HTTP) + endpoint))
|
||||
.credentialsProvider(
|
||||
StaticCredentialsProvider.create(
|
||||
AwsBasicCredentials.create(accessKey, secretKey)))
|
||||
.serviceConfiguration(S3Configuration.builder()
|
||||
.pathStyleAccessEnabled(true)
|
||||
.chunkedEncodingEnabled(false)
|
||||
.build())
|
||||
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = "cloud")
|
||||
public AmazonS3 initAmazonS3() {
|
||||
ClientConfiguration clientConfig = new ClientConfiguration();
|
||||
clientConfig.setProtocol(Protocol.HTTPS);
|
||||
return AmazonS3ClientBuilder.standard()
|
||||
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)))
|
||||
.withClientConfiguration(clientConfig)
|
||||
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region))
|
||||
.withPathStyleAccessEnabled(false)
|
||||
.withChunkedEncodingDisabled(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package net.lab1024.sa.base.config;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
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.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
@ -14,8 +13,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
@ -40,9 +37,6 @@ public class JsonConfig {
|
||||
builder.serializers(new LocalDateSerializer(DatePattern.NORM_DATE_FORMAT.getDateTimeFormatter()));
|
||||
builder.serializers(new LocalDateTimeSerializer(DatePattern.NORM_DATETIME_FORMAT.getDateTimeFormatter()));
|
||||
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,14 +1,11 @@
|
||||
package net.lab1024.sa.base.config;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.lab1024.sa.base.common.constant.StringConst;
|
||||
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.ticket.RepeatSubmitRedisTicket;
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitCaffeineTicket;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
/**
|
||||
* 重复提交配置
|
||||
@ -17,28 +14,25 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
* @Date 2021/10/9 18:47
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Configuration
|
||||
public class RepeatSubmitConfig {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Bean
|
||||
public RepeatSubmitAspect repeatSubmitAspect() {
|
||||
RepeatSubmitRedisTicket ticket = new RepeatSubmitRedisTicket(redisTemplate, this::ticket);
|
||||
return new RepeatSubmitAspect(ticket);
|
||||
RepeatSubmitCaffeineTicket caffeineTicket = new RepeatSubmitCaffeineTicket(this::ticket);
|
||||
return new RepeatSubmitAspect(caffeineTicket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指明某个用户的凭证
|
||||
*/
|
||||
private String ticket(HttpServletRequest request) {
|
||||
private String ticket(String servletPath) {
|
||||
Long userId = SmartRequestUtil.getRequestUserId();
|
||||
if (null == userId) {
|
||||
return StringConst.EMPTY;
|
||||
}
|
||||
return request.getServletPath() + "_" + userId;
|
||||
return servletPath + "_" + userId;
|
||||
}
|
||||
}
|
||||
|
@ -1,92 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
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,7 +12,6 @@ import net.lab1024.sa.base.common.constant.RequestHeaderConst;
|
||||
import net.lab1024.sa.base.common.swagger.SmartOperationCustomizer;
|
||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
|
||||
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
|
||||
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
@ -25,8 +24,6 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -83,21 +80,6 @@ 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));
|
||||
}
|
||||
|
||||
@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
|
||||
public GroupedOpenApi businessApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
@ -140,11 +122,11 @@ public class SwaggerConfig {
|
||||
Optional<JavadocProvider> javadocProvider) {
|
||||
List<ServerBaseUrlCustomizer> list = Lists.newArrayList(new ServerBaseUrlCustomizer() {
|
||||
@Override
|
||||
public String customize(String serverBaseUrl, HttpRequest request) {
|
||||
public String customize(String baseUrl) {
|
||||
if (StringUtils.isNotBlank(serverBaseUrl)) {
|
||||
return serverBaseUrl;
|
||||
}
|
||||
return serverBaseUrl;
|
||||
return baseUrl;
|
||||
}
|
||||
});
|
||||
return new OpenAPIService(openAPI, securityParser, springDocConfigProperties,
|
||||
|
@ -7,14 +7,8 @@ package net.lab1024.sa.base.constant;
|
||||
* @Date 2022-05-30 21:22:12
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CacheKeyConst {
|
||||
|
||||
public static class Dict {
|
||||
|
||||
public static final String DICT_DATA = "dict_data_cache";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.lab1024.sa.base.module.support.apiencrypt.advice;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
@ -25,7 +25,7 @@ import java.lang.reflect.Type;
|
||||
* @Date 2023/10/21 11:41:46
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@ -37,19 +37,16 @@ public class DecryptRequestAdvice extends RequestBodyAdviceAdapter {
|
||||
@Resource
|
||||
private ApiEncryptService apiEncryptService;
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
return methodParameter.hasMethodAnnotation(ApiDecrypt.class) || methodParameter.hasParameterAnnotation(ApiDecrypt.class) || methodParameter.getContainingClass().isAnnotationPresent(ApiDecrypt.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
try {
|
||||
String bodyStr = IOUtils.toString(inputMessage.getBody(), ENCODING);
|
||||
ApiEncryptForm apiEncryptForm = objectMapper.readValue(bodyStr, ApiEncryptForm.class);
|
||||
ApiEncryptForm apiEncryptForm = JSONObject.parseObject(bodyStr, ApiEncryptForm.class);
|
||||
if (SmartStringUtil.isEmpty(apiEncryptForm.getEncryptData())) {
|
||||
return inputMessage;
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
* @Date 2023/10/24 09:52:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO<Object>> {
|
||||
public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
|
||||
|
||||
@Resource
|
||||
private ApiEncryptService apiEncryptService;
|
||||
@ -44,18 +44,19 @@ public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO<Obj
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseDTO<Object> beforeBodyWrite(ResponseDTO<Object> body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if (body == null || body.getData() == null) {
|
||||
public ResponseDTO beforeBodyWrite(ResponseDTO body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if (body.getData() == null) {
|
||||
return body;
|
||||
}
|
||||
|
||||
String encrypt = null;
|
||||
try {
|
||||
String encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
|
||||
body.setData(encrypt);
|
||||
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
|
||||
encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
body.setData(encrypt);
|
||||
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,74 @@
|
||||
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 java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 缓存服务
|
||||
* 缓存操作
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2021/10/11 20:07
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Service
|
||||
public interface CacheService {
|
||||
public class CacheService {
|
||||
|
||||
@Resource
|
||||
private CaffeineCacheManager caffeineCacheManager;
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*
|
||||
*/
|
||||
List<String> cacheNames();
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(caffeineCacheManager.getCacheNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有 key
|
||||
* 某个缓存下的所有key
|
||||
*
|
||||
*/
|
||||
List<String> cacheKey(String cacheName);
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
Set<Object> cacheKey = cache.getNativeCache().asMap().keySet();
|
||||
return cacheKey.stream().map(e -> e.toString()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除某个 key
|
||||
* 移除某个key
|
||||
*
|
||||
*/
|
||||
void removeCache(String cacheName);
|
||||
|
||||
}
|
||||
public void removeCache(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = caffeineCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
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 java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* caffeine 缓存实现
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2021/10/11 20:07
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CaffeineCacheServiceImpl implements CacheService {
|
||||
|
||||
@Resource
|
||||
private CaffeineCacheManager caffeineCacheManager;
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(caffeineCacheManager.getCacheNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有 key
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
Set<Object> cacheKey = cache.getNativeCache().asMap().keySet();
|
||||
return cacheKey.stream().map(e -> e.toString()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除某个 key
|
||||
*/
|
||||
@Override
|
||||
public void removeCache(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = caffeineCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.cache;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.data.redis.cache.RedisCache;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* redis 缓存实现
|
||||
*
|
||||
* @author zhoumingfa
|
||||
* @date 2025/3/28
|
||||
*/
|
||||
public class RedisCacheServiceImpl implements CacheService {
|
||||
|
||||
@Resource
|
||||
private RedisCacheManager redisCacheManager;
|
||||
|
||||
@Resource
|
||||
private RedisConnectionFactory redisConnectionFactory;
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(redisCacheManager.getCacheNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有 key
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
// 获取 Redis 连接
|
||||
RedisConnection connection = redisConnectionFactory.getConnection();
|
||||
// 根据指定的 key 模式获取所有匹配的键
|
||||
Set<byte[]> keys = connection.keyCommands().keys((cacheName + ":*").getBytes());
|
||||
|
||||
if (keys != null) {
|
||||
return keys.stream().map(key -> {
|
||||
String redisKey = StrUtil.str(key, "utf-8");
|
||||
// 从 Redis 键中提取出最后一个冒号后面的字符串作为真正的键
|
||||
return redisKey.substring(redisKey.lastIndexOf(":") + 1);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
connection.close();
|
||||
return Lists.newArrayList(cacheName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除某个 key
|
||||
*/
|
||||
@Override
|
||||
public void removeCache(String cacheName) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = redisCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,10 +3,10 @@ package net.lab1024.sa.base.module.support.captcha;
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
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.SystemEnvironment;
|
||||
import net.lab1024.sa.base.constant.RedisKeyConst;
|
||||
@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 图形验证码 服务
|
||||
@ -69,7 +70,7 @@ public class CaptchaService {
|
||||
* 图片 base64格式
|
||||
*/
|
||||
// uuid 唯一标识
|
||||
String uuid = IdUtil.fastSimpleUUID();
|
||||
String uuid = UUID.randomUUID().toString().replace("-", StringConst.EMPTY);
|
||||
|
||||
CaptchaVO captchaVO = new CaptchaVO();
|
||||
captchaVO.setCaptchaUuid(uuid);
|
||||
|
@ -20,6 +20,7 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface ChangeLogDao extends BaseMapper<ChangeLogEntity> {
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ public class ChangeLogEntity {
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String updateVersion;
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]
|
||||
|
@ -23,7 +23,7 @@ public class ChangeLogAddForm {
|
||||
|
||||
@Schema(description = "版本", required = true)
|
||||
@NotBlank(message = "版本 不能为空")
|
||||
private String updateVersion;
|
||||
private String version;
|
||||
|
||||
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
||||
@CheckEnum(value = ChangeLogTypeEnum.class, message = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复] 错误", required = true)
|
||||
|
@ -27,7 +27,7 @@ public class ChangeLogUpdateForm {
|
||||
|
||||
@Schema(description = "版本", required = true)
|
||||
@NotBlank(message = "版本 不能为空")
|
||||
private String updateVersion;
|
||||
private String version;
|
||||
|
||||
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
||||
@CheckEnum(value = ChangeLogTypeEnum.class, message = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复] 错误", required = true)
|
||||
|
@ -23,7 +23,7 @@ public class ChangeLogVO {
|
||||
private Long changeLogId;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private String updateVersion;
|
||||
private String version;
|
||||
|
||||
@SchemaEnum(value = ChangeLogTypeEnum.class, desc = "更新类型:[1:特大版本功能更新;2:功能更新;3:bug修复]")
|
||||
private Integer type;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user