perf: 对获取路由信息接口增加缓存处理

1.优化 Spring Cache 配置
2.暂时移除 Jackson 针对数值类型:Long、BigInteger、BigDecimal 的 toString 处理(TreeUtil 疑似在字符串类型 parentId 时会出现转换异常)
This commit is contained in:
2023-08-31 22:05:35 +08:00
parent d7c0dce608
commit 4639d13ba6
14 changed files with 181 additions and 105 deletions

View File

@@ -45,6 +45,7 @@ import top.charles7c.cnadmin.common.util.RedisUtils;
import top.charles7c.cnadmin.common.util.SecureUtils;
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
import top.charles7c.cnadmin.common.util.validate.ValidationUtils;
import top.charles7c.cnadmin.monitor.annotation.Log;
import top.charles7c.cnadmin.system.model.vo.UserDetailVO;
import top.charles7c.cnadmin.system.service.UserService;
@@ -92,6 +93,7 @@ public class LoginController {
return R.ok();
}
@Log(ignore = true)
@Operation(summary = "获取用户信息", description = "获取登录用户信息")
@GetMapping("/user/info")
public R<UserInfoVO> getUserInfo() {
@@ -103,9 +105,10 @@ public class LoginController {
return R.ok(userInfoVO);
}
@Log(ignore = true)
@Operation(summary = "获取路由信息", description = "获取登录用户的路由信息")
@GetMapping("/route")
public R<List<RouteVO>> listMenu() {
public R<List<RouteVO>> listRoute() {
Long userId = LoginHelper.getUserId();
List<RouteVO> routeTree = loginService.buildRouteTree(userId);
return R.ok(routeTree);

View File

@@ -50,7 +50,7 @@ spring.liquibase:
# 配置文件路径
change-log: classpath:/db/changelog/db.changelog-master.yaml
--- ### Redis 单机配置
--- ### Redis 配置(单机版)
spring:
redis:
# 地址
@@ -65,6 +65,13 @@ spring:
timeout: 10s
# 是否开启 SSL
ssl: false
## Spring Cache 配置
cache:
redis:
# 缓存过期时长(单位:毫秒,默认 -1表示永不过期
time-to-live: 7200000
# 是否允许缓存空值(默认 true表示允许可以解决缓存穿透问题
cache-null-values: true
--- ### 邮件配置
spring.mail:

View File

@@ -50,7 +50,7 @@ spring.liquibase:
# 配置文件路径
change-log: classpath:/db/changelog/db.changelog-master.yaml
--- ### Redis 单机配置
--- ### Redis 配置(单机版)
spring:
redis:
# 地址
@@ -65,6 +65,13 @@ spring:
timeout: 10s
# 是否开启 SSL
ssl: false
## Spring Cache 配置
cache:
redis:
# 缓存过期时长(单位:毫秒,默认 -1表示永不过期
time-to-live: 7200000
# 是否允许缓存空值(默认 true表示允许可以解决缓存穿透问题
cache-null-values: true
--- ### 邮件配置
spring.mail:

View File

@@ -212,14 +212,6 @@ spring:
deserialization:
# 允许反序列化不存在的属性
FAIL_ON_UNKNOWN_PROPERTIES: false
## 缓存配置(@Cacheable
cache:
type: redis
redis:
# 缓存过期时长(单位:毫秒,默认 -1表示永不过期
time-to-live: 7200000
# 是否允许缓存空值(默认 true表示允许可以解决缓存穿透问题
cache-null-values: true
--- ### 健康检查配置
management.health: