From 842c0049ea8498ea4adb3ca119157561b4d7df4f Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Mon, 08 Dec 2025 17:26:37 +0800
Subject: [PATCH] 2025-12-08 zwy 整理设备属性设置无人机不在线时返回前端错误提示代码为自定义代码,设备已离线和机场代码共用一个,无法区分机场和无人机设备。
---
ard-framework/src/main/java/com/ard/framework/web/service/SysLoginService.java | 21 ++++++++++++++++++++-
1 files changed, 20 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 fd63a77..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,12 +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;
@@ -33,7 +36,7 @@
/**
* 登录校验方法
*
- * @author ruoyi
+ * @author ard
*/
@Component
public class SysLoginService
@@ -56,6 +59,12 @@
@Autowired
private ISysConfigService configService;
+
+ @Resource
+ private CustomAuthenticationSuccessHandler successHandler;
+
+ @Autowired
+ private UserDetailsService userDetailsService;
/**
* 登录验证
@@ -80,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)
{
@@ -158,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