修复已知问题

This commit is contained in:
2024-11-01 05:09:04 +08:00
parent 277026ed20
commit 80b0ff32ae
4 changed files with 22 additions and 8 deletions

View File

@@ -53,6 +53,7 @@ public class MybatisPlusConfig {
// 从请求头拿ID
final String tenantId = request.getHeader("tenantId");
if(tenantId != null){
System.out.println("从请求头拿ID = " + tenantId);
return new LongValue(tenantId);
}
return getLoginUserTenantId();

View File

@@ -73,12 +73,7 @@ public class BaseController {
* @return tenantId
*/
public Integer getTenantId() {
// 1 从登录用户拿tenantId
User loginUser = getLoginUser();
if (loginUser != null) {
return loginUser.getTenantId();
}
// 2 从域名拿ID
// 1 从域名拿ID
String Domain = request.getHeader("Domain");
if (StrUtil.isNotBlank(Domain)) {
String key = "Domain:" + Domain;
@@ -88,11 +83,16 @@ public class BaseController {
return Integer.valueOf(tenantId);
}
}
// 3 从请求头拿ID
// 2 从请求头拿ID
String tenantId = request.getHeader("tenantId");
if(StrUtil.isNotBlank(tenantId)){
return Integer.valueOf(tenantId);
}
// 1 从登录用户拿tenantId
User loginUser = getLoginUser();
if (loginUser != null) {
return loginUser.getTenantId();
}
return null;
}

View File

@@ -85,6 +85,8 @@ public class MainController extends BaseController {
@Resource
private CompanyMapper companyMapper;
@Resource
private UserRoleService userRoleService;
@Resource
private CompanyService companyService;
@@ -194,7 +196,7 @@ public class MainController extends BaseController {
String key = "TenantInfo:" + tenantId;
final String tenantInfo = redisUtil.get(key);
if(StrUtil.isNotBlank(tenantInfo)){
return success(JSONObject.parseObject(tenantInfo,Company.class));
// return success(JSONObject.parseObject(tenantInfo,Company.class));
}
final Company company = companyMapper.getByTenantId(tenantId);
// 是否过期
@@ -210,6 +212,9 @@ public class MainController extends BaseController {
config.put("LICENSE_CODE", "dk9mcwJyetRWQlxWRiojIzJCLi8mcQ5Wa4ojI0NWZqJWd6ICZpJCL0kjNwl1NnhENahnIvl2cyVmdiwiIiATMuEjI6IibQf0NW==");
config.put("MAP_KEY", "8191620da39a742c6f18f010c084c772");
company.setConfig(config);
//应用菜单
company.setRoles(userRoleService.listByUserId(company.getUserId()));
company.setAuthorities(roleMenuService.listMenuByUserId(company.getUserId(), null));
redisUtil.set(key,company,1L, TimeUnit.DAYS);
return success(company);

View File

@@ -313,6 +313,14 @@ public class Company implements Serializable {
@TableField(exist = false)
private Integer num;
@ApiModelProperty("角色列表")
@TableField(exist = false)
private List<Role> roles;
@ApiModelProperty("权限列表")
@TableField(exist = false)
private List<Menu> authorities;
public String getMobile() {
return DesensitizedUtil.mobilePhone(this.phone);
}