根据tokne获取用户信息
This commit is contained in:
@@ -97,6 +97,11 @@
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java-sms</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
<version>1.4.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lideeyunji</groupId>
|
||||
<artifactId>lidee-module-api</artifactId>
|
||||
|
||||
@@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.lideeyunji.service.system.config.convert.auth.AuthConvert;
|
||||
import com.lideeyunji.service.system.constant.ErrorCodeConstants;
|
||||
import com.lideeyunji.service.system.controller.vo.auth.*;
|
||||
import com.lideeyunji.service.system.controller.vo.auth.*;
|
||||
import com.lideeyunji.service.system.controller.vo.user.user.UserRespVO;
|
||||
import com.lideeyunji.service.system.entity.AdminUserDO;
|
||||
import com.lideeyunji.service.system.entity.MenuDO;
|
||||
@@ -23,7 +22,6 @@ import com.lideeyunji.tool.framework.operatelog.core.annotations.OperateLog;
|
||||
import com.lideeyunji.tool.framework.security.config.SecurityProperties;
|
||||
import com.lideeyunji.tool.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.lideeyunji.tool.framework.tenant.core.context.TenantContextHolder;
|
||||
import com.lideeyunji.service.system.service.*;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
@@ -165,8 +163,7 @@ public class AuthController {
|
||||
@Operation(tags = "根据token获取用户信息",summary = "根据token获取用户信息")
|
||||
@Parameter(name = "refreshToken", description = "根据token获取用户信息", required = true)
|
||||
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
|
||||
public CommonResult<AuthLoginRespVO> getUerInfo(@RequestParam("refreshToken") String refreshToken) {
|
||||
//跟
|
||||
public CommonResult<AdminUserDO> getUerInfo(@RequestParam("refreshToken") String refreshToken) {
|
||||
return success(authService.getTokenTouserInfo(refreshToken));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,6 @@ public interface IAdminAuthService {
|
||||
*/
|
||||
AuthLoginRespVO refreshToken(String refreshToken);
|
||||
|
||||
AuthLoginRespVO getTokenTouserInfo(String refreshToken);
|
||||
AdminUserDO getTokenTouserInfo(String refreshToken);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.lideeyunji.service.system.service;
|
||||
|
||||
import com.lideeyunji.service.system.entity.AdminUserDO;
|
||||
import com.lideeyunji.tool.framework.common.pojo.PageResult;
|
||||
import com.lideeyunji.service.system.controller.vo.oauth2.token.OAuth2AccessTokenPageReqVO;
|
||||
import com.lideeyunji.service.system.entity.OAuth2AccessTokenDO;
|
||||
@@ -41,6 +42,9 @@ public interface IOAuth2TokenService {
|
||||
*/
|
||||
OAuth2AccessTokenDO refreshAccessToken(String refreshToken, String clientId);
|
||||
|
||||
AdminUserDO getTokenTouserInfo(String refreshToken);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获得访问令牌
|
||||
|
||||
@@ -364,9 +364,9 @@ public class AdminAuthServiceImpl implements IAdminAuthService {
|
||||
|
||||
|
||||
@Override
|
||||
public AuthLoginRespVO getTokenTouserInfo(String refreshToken) {
|
||||
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.refreshAccessToken(refreshToken, OAuth2ClientConstants.CLIENT_ID_DEFAULT);
|
||||
return AuthConvert.INSTANCE.convert(accessTokenDO);
|
||||
public AdminUserDO getTokenTouserInfo(String refreshToken) {
|
||||
AdminUserDO user= oauth2TokenService.getTokenTouserInfo(refreshToken);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public class OAuth2TokenServiceImpl implements IOAuth2TokenService {
|
||||
@Lazy // 懒加载,避免循环依赖
|
||||
private IAdminUserService adminUserService;
|
||||
|
||||
|
||||
@Override
|
||||
public OAuth2AccessTokenDO createAccessToken(Long userId, Long lastLoginDeptId, Long lastLoginRoleId, Integer userType, String clientId, List<String> scopes) {
|
||||
return createAccessToken(userId, lastLoginDeptId, lastLoginRoleId, userType, clientId, scopes,false);
|
||||
@@ -77,6 +78,16 @@ public class OAuth2TokenServiceImpl implements IOAuth2TokenService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AdminUserDO getTokenTouserInfo(String refreshToken ) {
|
||||
// 获得用户基本信息
|
||||
OAuth2AccessTokenDO accessTokenDO= oauth2AccessTokenMapper.selectByAccessToken(refreshToken);
|
||||
AdminUserDO user = adminUserService.getUser(accessTokenDO.getUserId());
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuth2AccessTokenDO refreshAccessToken(String refreshToken, String clientId) {
|
||||
boolean supAdmin = SecurityFrameworkUtils.isSupAdmin();
|
||||
@@ -110,6 +121,12 @@ public class OAuth2TokenServiceImpl implements IOAuth2TokenService {
|
||||
return createOAuth2AccessToken(refreshTokenDO, clientDO, supAdmin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public OAuth2AccessTokenDO getAccessToken(String accessToken) {
|
||||
// 优先从 Redis 中获取
|
||||
|
||||
Reference in New Issue
Block a user