refactor: 优化刷新角色权限缓存,如果权限为空则不缓存

This commit is contained in:
Ray.Hao
2024-07-19 12:48:26 +08:00
parent e9e2fee085
commit c7750b8853

View File

@@ -52,7 +52,9 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
list.forEach(item -> {
String roleCode = item.getRoleCode();
Set<String> perms = item.getPerms();
redisTemplate.opsForHash().put(SecurityConstants.ROLE_PERMS_PREFIX, roleCode, perms);
if (CollectionUtil.isNotEmpty(perms)) {
redisTemplate.opsForHash().put(SecurityConstants.ROLE_PERMS_PREFIX, roleCode, perms);
}
});
}
}
@@ -73,7 +75,9 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
}
Set<String> perms = rolePerms.getPerms();
redisTemplate.opsForHash().put(SecurityConstants.ROLE_PERMS_PREFIX, roleCode, perms);
if (CollectionUtil.isNotEmpty(perms)) {
redisTemplate.opsForHash().put(SecurityConstants.ROLE_PERMS_PREFIX, roleCode, perms);
}
}
}