From 1791d8d45a0f6de527a1e243b9ba806edc0753aa Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Thu, 06 Nov 2025 14:32:14 +0800
Subject: [PATCH] 1.修改文件业务,屏蔽前台接口开关。 2.文件夹业务修改为,分组管理业务。 3.航线(kmz)对象增加分组ID。 4.分组信息删除同时删除分组下航信信息。 5.新增航线(kmz)时,不选分组,将赋值默认分组信息。 6.增加初始化数据类。 7.生成kmz文件,增加默认值管理。

---
 ard-framework/src/main/java/com/ard/framework/web/service/SysLoginService.java |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/ard-framework/src/main/java/com/ard/framework/web/service/SysLoginService.java b/ard-framework/src/main/java/com/ard/framework/web/service/SysLoginService.java
index d380f42..1c5aced 100644
--- a/ard-framework/src/main/java/com/ard/framework/web/service/SysLoginService.java
+++ b/ard-framework/src/main/java/com/ard/framework/web/service/SysLoginService.java
@@ -1,11 +1,15 @@
 package com.ard.framework.web.service;
 
 import javax.annotation.Resource;
+
+import com.ard.framework.security.handle.CustomAuthenticationSuccessHandler;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
+import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.stereotype.Component;
 import com.ard.common.constant.CacheConstants;
 import com.ard.common.constant.Constants;
@@ -32,11 +36,15 @@
 /**
  * 登录校验方法
  * 
- * @author ruoyi
+ * @author ard
  */
 @Component
 public class SysLoginService
 {
+    // 是否允许账户多终端同时登录(true允许 false不允许)
+    @Value("${token.soloLogin}")
+    private boolean soloLogin;
+
     @Autowired
     private TokenService tokenService;
 
@@ -51,6 +59,12 @@
 
     @Autowired
     private ISysConfigService configService;
+
+    @Resource
+    private CustomAuthenticationSuccessHandler successHandler;
+
+    @Autowired
+    private UserDetailsService userDetailsService;
 
     /**
      * 登录验证
@@ -75,6 +89,15 @@
             AuthenticationContextHolder.setContext(authenticationToken);
             // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
             authentication = authenticationManager.authenticate(authenticationToken);
+
+            // 获取用户ID
+            LoginUser loginUser = (LoginUser) userDetailsService.loadUserByUsername(username);
+            Long userId = loginUser.getUser().getUserId();
+            // 登录成功逻辑
+            if (authentication.isAuthenticated()) {
+                // 检查是否已登录
+                successHandler.onAuthenticationSuccess(userId);
+            }
         }
         catch (Exception e)
         {
@@ -96,6 +119,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);
+            }
+        }
         // 生成token
         return tokenService.createToken(loginUser);
     }
@@ -142,6 +176,7 @@
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null")));
             throw new UserNotExistsException();
         }
+
         // 密码如果不在指定范围内 错误
         if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
                 || password.length() > UserConstants.PASSWORD_MAX_LENGTH)

--
Gitblit v1.9.3