返回租户编号

This commit is contained in:
xiaogu
2025-09-11 23:30:44 +08:00
parent 92599e3616
commit b64c618a6d
8 changed files with 19 additions and 7 deletions

View File

@@ -27,4 +27,6 @@ public class AuthLoginRespVO {
@Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime expiresTime;
private Long tenantId;
}

View File

@@ -52,7 +52,7 @@ public class AuthPermissionInfoRespVO {
@Schema(description = "用户邮箱", example = "yudao@iocoder.cn")
private String email;
private Long tenantId;
}
@Schema(description = "管理后台 - 登录用户的菜单信息 Response VO")

View File

@@ -68,6 +68,8 @@ public class UserSaveReqVO {
private Integer status;
private Long tenantId;
// ========== 仅【创建】时,需要传递的字段 ==========
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")

View File

@@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.system.dal.dataobject.oauth2;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -26,7 +27,7 @@ import java.util.Map;
@KeySequence("system_oauth2_access_token_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
public class OAuth2AccessTokenDO extends TenantBaseDO {
public class OAuth2AccessTokenDO extends BaseDO {
/**
* 编号,数据库递增
@@ -71,5 +72,8 @@ public class OAuth2AccessTokenDO extends TenantBaseDO {
* 过期时间
*/
private LocalDateTime expiresTime;
/**
* 多租户编号
*/
private Long tenantId;
}

View File

@@ -9,7 +9,7 @@ import java.util.Map;
/**
* 管理后台的认证 Service 接口
*
* <p>
* 提供用户的登录、登出的能力
*
* @author 芋道源码
@@ -36,7 +36,7 @@ public interface AdminAuthService {
/**
* 基于 token 退出登录
*
* @param token token
* @param token token
* @param logType 登出类型
*/
void logout(String token, Integer logType);
@@ -87,7 +87,7 @@ public interface AdminAuthService {
*/
void resetPassword(AuthResetPasswordReqVO reqVO);
WxLoginRespVO getSession( WxLoginReqVO reqVO);
WxLoginRespVO getSession(WxLoginReqVO reqVO);
String getAccessToken();

View File

@@ -230,6 +230,8 @@ public class AdminAuthServiceImpl implements AdminAuthService {
// 创建访问令牌
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.createAccessToken(userId, getUserType().getValue(),
OAuth2ClientConstants.CLIENT_ID_DEFAULT, null);
AdminUserDO user = userService.getUser(userId);
accessTokenDO.setTenantId(user.getTenantId());
// 构建返回结果
return AuthConvert.INSTANCE.convert(accessTokenDO);
}
@@ -377,6 +379,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
adminUserDO.setStatus(CommonStatusEnum.DISABLE.getStatus());
adminUserDO.setPassword("123456");
adminUserDO.setIsSynchronize(1);
adminUserDO.setTenantId(1L);
userService.createUser(adminUserDO);
return true;
} else {

View File

@@ -177,6 +177,7 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
.setUserId(userId).setUserType(userType)
.setClientId(clientDO.getClientId()).setScopes(scopes)
.setExpiresTime(LocalDateTime.now().plusSeconds(clientDO.getRefreshTokenValiditySeconds()));
refreshToken.setTenantId(TenantContextHolder.getTenantId());
oauth2RefreshTokenMapper.insert(refreshToken);
return refreshToken;
}

View File

@@ -281,7 +281,7 @@ yudao:
- /admin-api/system/auth/get-session
- /admin-api/system/auth/get-phone-number
- /admin-api/system/auth/api/user-add
- /admin-api/system/api/user-info
- /admin-api/system/auth/api/user-info
ignore-visit-urls:
- /admin-api/system/user/profile/**
- /admin-api/system/auth/**