chejianzheng 3 сар өмнө
parent
commit
18d45583e8

+ 6 - 2
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/AdminGatewayImpl.java

@@ -2,6 +2,7 @@ package com.hfln.portal.infrastructure.gateway.impl;
 
 import cn.dev33.satoken.stp.SaTokenInfo;
 import cn.dev33.satoken.stp.StpUtil;
+import cn.dev33.satoken.stp.parameter.SaLoginParameter;
 import cn.hfln.framework.common.redis.service.RedisService;
 import cn.hfln.framework.extension.BizException;
 import com.alibaba.excel.EasyExcel;
@@ -32,6 +33,7 @@ import com.hfln.portal.infrastructure.service.DevInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
@@ -62,6 +64,9 @@ public class AdminGatewayImpl implements AdminGateway {
     @Autowired
     private UserAuthService userAuthService;
 
+    @Value("${sa-token.admin.timeout}")
+    private long adminTimeout;
+
 
     @Override
     public UploadRes uploadDev(MultipartFile file) throws IOException {
@@ -155,8 +160,7 @@ public class AdminGatewayImpl implements AdminGateway {
         // 1 需要保证 userId 和 adminUserId 不能一样
         // 2 可以在 stputil.login 的 loginId 参数前加前缀 user_ or admin_
         // 3 添加 SptAdminUtil,不过在不同地方,需要注意对 stputil sptadminutil 的不同引用
-        StpUtil.login(adminUser.getUserId(), DeviceType.WEB.getCode());
-
+        StpUtil.login(adminUser.getUserId(), SaLoginParameter.create().setDeviceType(DeviceType.WEB.getCode()).setTimeout(adminTimeout));
 
         // 当前用户登录后,需要将当前用户的权限保存到redis,用于网关校验权限
         userAuthService.cacheRolesAndPermissions();

+ 2 - 0
portal-service-server/src/main/resources/bootstrap-dev.yml

@@ -93,6 +93,8 @@ sa-token:
   token-style: uuid
   # 是否输出操作日志
   is-log: true
+  admin:
+    timeout: 1800
 
 # mqtt相关
 mqtt:

+ 2 - 0
portal-service-server/src/main/resources/bootstrap-local.yml

@@ -93,6 +93,8 @@ sa-token:
   token-style: uuid
   # 是否输出操作日志
   is-log: true
+  admin:
+    timeout: 1800
 
 # mqtt相关
 mqtt:

+ 2 - 0
portal-service-server/src/main/resources/bootstrap-test.yml

@@ -93,6 +93,8 @@ sa-token:
   token-style: uuid
   # 是否输出操作日志
   is-log: true
+  admin:
+    timeout: 1800
 
 # mqtt相关
 mqtt:

+ 0 - 15
portal-service-server/src/main/resources/bootstrap.yml

@@ -26,21 +26,6 @@ mybatis-plus:
       logic-delete-value: 1
       logic-not-delete-value: 0
 
-#sa-token:
-#  config:
-#    ignoreUrls:
-#      - /wap/user/**
-#      - /v2/**
-#      - /doc.html
-#      - /swagger-resources/**
-#      - /webjars/**
-#      - /swagger-ui/**
-#      - /swagger-ui.html
-#      - /v3/**
-#      - /api-docs
-#      - /api/doc.html
-#      - /knife4j/**
-
 # Knife4j 文档配置
 lnxx:
   knife4j: