mirror of https://gitee.com/stylefeng/roses
【7.3.2】【cache】更新租户编码获取方式
parent
f4bd3d6d15
commit
245b05e94a
|
@ -1,7 +1,9 @@
|
||||||
package cn.stylefeng.roses.kernel.system.modular.user.service;
|
package cn.stylefeng.roses.kernel.system.modular.user.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.tenant.TenantCodeHolder;
|
||||||
import cn.stylefeng.roses.kernel.rule.tenant.TenantPrefixApi;
|
import cn.stylefeng.roses.kernel.rule.tenant.TenantPrefixApi;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -17,6 +19,15 @@ public class TenantPrefixService implements TenantPrefixApi {
|
||||||
@Override
|
@Override
|
||||||
public String getTenantPrefix() {
|
public String getTenantPrefix() {
|
||||||
|
|
||||||
|
// 先从ThreadLocal中获取租户缓存编码
|
||||||
|
String tenantCode = TenantCodeHolder.getTenantCode();
|
||||||
|
|
||||||
|
// 如果有则以ThreadLocal中为准
|
||||||
|
if (ObjectUtil.isNotEmpty(tenantCode)) {
|
||||||
|
return tenantCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 之后,从LoginUser中获取租户编码
|
||||||
LoginUser loginUser = LoginContext.me().getLoginUserNullable();
|
LoginUser loginUser = LoginContext.me().getLoginUserNullable();
|
||||||
|
|
||||||
if (loginUser == null) {
|
if (loginUser == null) {
|
||||||
|
|
Loading…
Reference in New Issue