From 5db610d16f1a7fb58fd29856ab10545e20139592 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 28 Jun 2023 21:31:25 +0800 Subject: [PATCH] optimized code --- .../src/main/resources/application.yml | 47 ++++++++++--------- .../com/ruoyi/common/annotation/Excel.java | 8 ++-- .../common/core/domain/model/LoginUser.java | 44 ++++++++--------- ruoyi-framework/pom.xml | 2 +- .../web/service/PermissionService.java | 2 +- 5 files changed, 52 insertions(+), 51 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index a5992a8b7..be2b4b203 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -53,15 +53,16 @@ spring: messages: # 国际化资源文件路径 basename: i18n/messages - profiles: + profiles: active: druid # 文件上传 servlet: - multipart: - # 单个文件大小 - max-file-size: 10MB - # 设置总上传的文件大小 - max-request-size: 20MB + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 devtools: restart: @@ -76,7 +77,7 @@ spring: # 数据库索引 database: 0 # 密码 - password: + password: # 连接超时时间 timeout: 10s lettuce: @@ -92,27 +93,27 @@ spring: # token配置 token: - # 令牌自定义标识 - header: Authorization - # 令牌密钥 - secret: abcdefghijklmnopqrstuvwxyz - # 令牌有效期(默认30分钟) - expireTime: 30 - + # 令牌自定义标识 + header: Authorization + # 令牌密钥 + secret: abcdefghijklmnopqrstuvwxyz + # 令牌有效期(默认30分钟) + expireTime: 30 + # MyBatis配置 mybatis: - # 搜索指定包别名 - typeAliasesPackage: com.ruoyi.**.domain - # 配置mapper的扫描,找到所有的mapper.xml映射文件 - mapperLocations: classpath*:mapper/**/*Mapper.xml - # 加载全局的配置文件 - configLocation: classpath:mybatis/mybatis-config.xml + # 搜索指定包别名 + typeAliasesPackage: com.ruoyi.**.domain + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/**/*Mapper.xml + # 加载全局的配置文件 + configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 -pagehelper: +pagehelper: helperDialect: mysql supportMethodsArguments: true - params: count=countSql + params: count=countSql # Swagger配置 swagger: @@ -122,7 +123,7 @@ swagger: pathMapping: /dev-api # 防止XSS攻击 -xss: +xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java index c6c8bc594..d534a3ebc 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java @@ -59,12 +59,12 @@ public @interface Excel public int roundingMode() default BigDecimal.ROUND_HALF_EVEN; /** - * 导出时在excel中每个列的高度 单位为字符 + * 导出时在excel中每个列的高度 */ public double height() default 14; /** - * 导出时在excel中每个列的宽 单位为字符 + * 导出时在excel中每个列的宽度 */ public double width() default 16; @@ -114,7 +114,7 @@ public @interface Excel public ColumnType cellType() default ColumnType.STRING; /** - * 导出列头背景色 + * 导出列头背景颜色 */ public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT; @@ -124,7 +124,7 @@ public @interface Excel public IndexedColors headerColor() default IndexedColors.WHITE; /** - * 导出单元格背景色 + * 导出单元格背景颜色 */ public IndexedColors backgroundColor() default IndexedColors.WHITE; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java index 41490e776..95e169cf3 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java @@ -1,11 +1,11 @@ package com.ruoyi.common.core.domain.model; -import java.util.Collection; -import java.util.Set; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; import com.alibaba.fastjson2.annotation.JSONField; import com.ruoyi.common.core.domain.entity.SysUser; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; +import java.util.Collection; +import java.util.Set; /** * 登录用户身份权限 @@ -71,6 +71,24 @@ public class LoginUser implements UserDetails */ private SysUser user; + public LoginUser() + { + } + + public LoginUser(SysUser user, Set permissions) + { + this.user = user; + this.permissions = permissions; + } + + public LoginUser(Long userId, Long deptId, SysUser user, Set permissions) + { + this.userId = userId; + this.deptId = deptId; + this.user = user; + this.permissions = permissions; + } + public Long getUserId() { return userId; @@ -101,24 +119,6 @@ public class LoginUser implements UserDetails this.token = token; } - public LoginUser() - { - } - - public LoginUser(SysUser user, Set permissions) - { - this.user = user; - this.permissions = permissions; - } - - public LoginUser(Long userId, Long deptId, SysUser user, Set permissions) - { - this.userId = userId; - this.deptId = deptId; - this.user = user; - this.permissions = permissions; - } - @JSONField(serialize = false) @Override public String getPassword() diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml index a2ccee297..f02006bf9 100644 --- a/ruoyi-framework/pom.xml +++ b/ruoyi-framework/pom.xml @@ -41,7 +41,7 @@ kaptcha - javax.servlet-api + servlet-api javax.servlet diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java index 8fed7fbd6..5043e3973 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java @@ -62,7 +62,7 @@ public class PermissionService /** * 验证用户是否具有以下任意一个权限 * - * @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表 + * @param permissions 以 PERMISSION_DELIMETER 为分隔符的权限列表 * @return 用户是否具有以下任意一个权限 */ public boolean hasAnyPermi(String permissions)