【7.3.2】【cache】更新租户编码获取方式

pull/41/head
fengshuonan 2022-11-08 01:11:51 +08:00
parent f4bd3d6d15
commit 245b05e94a
1 changed files with 11 additions and 0 deletions

View File

@ -1,7 +1,9 @@
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.pojo.login.LoginUser;
import cn.stylefeng.roses.kernel.rule.tenant.TenantCodeHolder;
import cn.stylefeng.roses.kernel.rule.tenant.TenantPrefixApi;
import org.springframework.stereotype.Service;
@ -17,6 +19,15 @@ public class TenantPrefixService implements TenantPrefixApi {
@Override
public String getTenantPrefix() {
// 先从ThreadLocal中获取租户缓存编码
String tenantCode = TenantCodeHolder.getTenantCode();
// 如果有则以ThreadLocal中为准
if (ObjectUtil.isNotEmpty(tenantCode)) {
return tenantCode;
}
// 之后从LoginUser中获取租户编码
LoginUser loginUser = LoginContext.me().getLoginUserNullable();
if (loginUser == null) {