登陆信息返回完善

This commit is contained in:
2025-10-25 17:24:40 +08:00
parent d2f62f9eb0
commit d9bab093c4
2 changed files with 8 additions and 6 deletions

View File

@@ -60,11 +60,8 @@ public class SysLoginController
@PostMapping("/login") @PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody) public AjaxResult login(@RequestBody LoginBody loginBody)
{ {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid()); loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
return ajax; return ajax;
} }

View File

@@ -2,6 +2,7 @@ package com.vetti.framework.web.service;
import javax.annotation.Resource; import javax.annotation.Resource;
import com.vetti.common.core.domain.AjaxResult;
import com.vetti.common.utils.SecurityUtils; import com.vetti.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
@@ -63,8 +64,9 @@ public class SysLoginService
* @param uuid 唯一标识 * @param uuid 唯一标识
* @return 结果 * @return 结果
*/ */
public String login(String username, String password, String code, String uuid) public AjaxResult login(String username, String password, String code, String uuid)
{ {
AjaxResult ajax = AjaxResult.success();
// 验证码校验 // 验证码校验
// validateCaptcha(username, code, uuid); // validateCaptcha(username, code, uuid);
// 登录前置校验 // 登录前置校验
@@ -99,7 +101,10 @@ public class SysLoginService
LoginUser loginUser = (LoginUser) authentication.getPrincipal(); LoginUser loginUser = (LoginUser) authentication.getPrincipal();
recordLoginInfo(loginUser.getUserId()); recordLoginInfo(loginUser.getUserId());
// 生成token // 生成token
return tokenService.createToken(loginUser); ajax.put(Constants.TOKEN, tokenService.createToken(loginUser));
ajax.put("userId",loginUser.getUserId());
return ajax;
} }
/** /**