|
@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -46,23 +47,24 @@ public class UserAuthService {
|
|
|
@Autowired
|
|
|
private TblSystemMenuService tblSystemMenuService;
|
|
|
|
|
|
- public void cacheRolesAndPermissions() {
|
|
|
+ public void cacheRolesAndPermissions(String tenantCode) {
|
|
|
|
|
|
List<String> roleCodeList = this.getRoleCodeList(StpUtil.getLoginId(), StpUtil.getLoginType());
|
|
|
if (!CollectionUtils.isEmpty(roleCodeList)) {
|
|
|
|
|
|
- StpUtil.getSession().set(SaSession.ROLE_LIST, roleCodeList);
|
|
|
+ List<String> newRoleCodeList = new ArrayList<>();
|
|
|
for (String roleCode : roleCodeList) {
|
|
|
if (!redisService.hasKey(RedisCacheConstant.ROLE_PERM_KEY_PRE + roleCode)) {
|
|
|
- // 这里从更改角色权限的地方修改最好
|
|
|
- // redisService.deleteObject(RedisCacheConstant.ROLE_PERM_KEY_PRE+roleCode);
|
|
|
+ String newRoleCode = StringUtils.hasText(tenantCode) ? tenantCode + "_" + roleCode : roleCode;
|
|
|
+ newRoleCodeList.add(newRoleCode);
|
|
|
List<String> permCodeList = this.getPermCodeList(roleCode);
|
|
|
if (!CollectionUtils.isEmpty(permCodeList)) {
|
|
|
// 永久期限
|
|
|
- redisService.setForever(RedisCacheConstant.ROLE_PERM_KEY_PRE + roleCode, JSONArray.toJSONString(permCodeList));
|
|
|
+ redisService.setForever(RedisCacheConstant.ROLE_PERM_KEY_PRE + newRoleCode, JSONArray.toJSONString(permCodeList));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ StpUtil.getSession().set(SaSession.ROLE_LIST, newRoleCodeList);
|
|
|
}
|
|
|
}
|
|
|
|