mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-08 12:57:13 +08:00
feat(tenant): 增加查询租户开启状态和租户根据域名查询租户的接口
This commit is contained in:
@@ -39,6 +39,7 @@ import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.core.util.ExceptionUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.tenant.context.TenantContextHolder;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@@ -71,7 +72,7 @@ public class AccountLoginHandler extends AbstractLoginHandler<AccountLoginReq> {
|
||||
super.checkUserStatus(user);
|
||||
// 执行认证
|
||||
String token = this.authenticate(user, client);
|
||||
return LoginResp.builder().token(token).build();
|
||||
return LoginResp.builder().token(token).tenantId(TenantContextHolder.isTenantEnabled()? TenantContextHolder.getTenantId():null).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -27,6 +27,7 @@ import top.continew.admin.system.model.entity.user.UserDO;
|
||||
import top.continew.admin.system.model.resp.ClientResp;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.tenant.context.TenantContextHolder;
|
||||
|
||||
/**
|
||||
* 邮箱登录处理器
|
||||
@@ -47,8 +48,7 @@ public class EmailLoginHandler extends AbstractLoginHandler<EmailLoginReq> {
|
||||
super.checkUserStatus(user);
|
||||
// 执行认证
|
||||
String token = super.authenticate(user, client);
|
||||
return LoginResp.builder().token(token).build();
|
||||
}
|
||||
return LoginResp.builder().token(token).tenantId(TenantContextHolder.isTenantEnabled()? TenantContextHolder.getTenantId():null).build(); }
|
||||
|
||||
@Override
|
||||
public void preLogin(EmailLoginReq req, ClientResp client, HttpServletRequest request) {
|
||||
|
@@ -27,6 +27,7 @@ import top.continew.admin.system.model.entity.user.UserDO;
|
||||
import top.continew.admin.system.model.resp.ClientResp;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.tenant.context.TenantContextHolder;
|
||||
|
||||
/**
|
||||
* 手机号登录处理器
|
||||
@@ -47,8 +48,7 @@ public class PhoneLoginHandler extends AbstractLoginHandler<PhoneLoginReq> {
|
||||
super.checkUserStatus(user);
|
||||
// 执行认证
|
||||
String token = super.authenticate(user, client);
|
||||
return LoginResp.builder().token(token).build();
|
||||
}
|
||||
return LoginResp.builder().token(token).tenantId(TenantContextHolder.isTenantEnabled()? TenantContextHolder.getTenantId():null).build(); }
|
||||
|
||||
@Override
|
||||
public void preLogin(PhoneLoginReq req, ClientResp client, HttpServletRequest request) {
|
||||
|
@@ -53,6 +53,7 @@ import top.continew.admin.system.service.UserSocialService;
|
||||
import top.continew.starter.core.autoconfigure.application.ApplicationProperties;
|
||||
import top.continew.starter.core.exception.BadRequestException;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.tenant.context.TenantContextHolder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
@@ -127,7 +128,7 @@ public class SocialLoginHandler extends AbstractLoginHandler<SocialLoginReq> {
|
||||
userSocialService.saveOrUpdate(userSocial);
|
||||
// 执行认证
|
||||
String token = super.authenticate(user, client);
|
||||
return LoginResp.builder().token(token).build();
|
||||
return LoginResp.builder().token(token).tenantId(TenantContextHolder.isTenantEnabled()? TenantContextHolder.getTenantId():null).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -42,4 +42,7 @@ public class LoginResp implements Serializable {
|
||||
*/
|
||||
@Schema(description = "令牌", example = "eyJ0eXAiOiJlV1QiLCJhbGciqiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb29pbiIsImxvZ2luSWQiOjEsInJuU3RyIjoiSjd4SUljYnU5cmNwU09vQ3Uyc1ND1BYYTYycFRjcjAifQ.KUPOYm-2wfuLUSfEEAbpGE527fzmkAJG7sMNcQ0pUZ8")
|
||||
private String token;
|
||||
|
||||
@Schema(description = "租户ID", example = "0")
|
||||
private Long tenantId;
|
||||
}
|
||||
|
@@ -39,6 +39,7 @@ import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
import top.continew.starter.extension.tenant.annotation.TenantIgnore;
|
||||
import top.continew.starter.extension.tenant.context.TenantContextHolder;
|
||||
import top.continew.starter.log.annotation.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -126,4 +127,13 @@ public class CommonController {
|
||||
.getDefaultValue())))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@TenantIgnore
|
||||
@SaIgnore
|
||||
@Operation(summary = "查询租户开启状态",description = "查询租户开启状态")
|
||||
@GetMapping("/dict/option/tenant")
|
||||
@Cached(key = "'TENANT'", name = CacheConstants.OPTION_KEY_PREFIX)
|
||||
public Boolean tenantEnabled(){
|
||||
return TenantContextHolder.isTenantEnabled();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user