From a3d274cc185968709ff240cd77a11a31df045183 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期一, 27 五月 2024 14:25:29 +0800
Subject: [PATCH] 设备健康获取某油井一段时间的测量趋势修改提交

---
 ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
index f3fa8aa..aa97e37 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -1,9 +1,10 @@
 package com.ruoyi.framework.web.service;
 
 import javax.annotation.Resource;
-
 import com.ruoyi.rongcloud.service.RongCloudService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -36,6 +37,11 @@
  */
 @Component
 public class SysLoginService {
+
+    // 鏄惁鍏佽璐︽埛澶氱粓绔悓鏃剁櫥褰曪紙true鍏佽 false涓嶅厑璁革級
+    @Value("${token.soloLogin}")
+    private boolean soloLogin;
+
     @Autowired
     private TokenService tokenService;
 
@@ -65,7 +71,6 @@
      */
     public String login(String username, String password, String code, String uuid) {
 
-
         boolean captchaEnabled = configService.selectCaptchaEnabled();
         // 楠岃瘉鐮佸紑鍏�
         if (captchaEnabled) {
@@ -92,7 +97,17 @@
         AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
         LoginUser loginUser = (LoginUser) authentication.getPrincipal();
         recordLoginInfo(loginUser.getUserId());
-
+        if (!soloLogin)
+        {
+            // 濡傛灉鐢ㄦ埛涓嶅厑璁稿缁堢鍚屾椂鐧诲綍锛屾竻闄ょ紦瀛樹俊鎭�
+            String userIdKey = Constants.LOGIN_USERID_KEY + loginUser.getUser().getUserId();
+            String userKey = redisCache.getCacheObject(userIdKey);
+            if (StringUtils.isNotEmpty(userKey))
+            {
+                redisCache.deleteObject(userIdKey);
+                redisCache.deleteObject(userKey);
+            }
+        }
         getRongCloudToken(loginUser);
         // 鐢熸垚token
         String token = tokenService.createToken(loginUser);
@@ -137,6 +152,7 @@
      *
      * @param loginUser 鐧诲綍鐢ㄦ埛
      */
+    @Async
     public String getRongCloudToken(LoginUser loginUser) {
         try {
             String userId = loginUser.getUserId();

--
Gitblit v1.9.3