mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
feat:权限调整
This commit is contained in:
parent
1a9690b862
commit
8afa848a81
@ -0,0 +1,23 @@
|
||||
package com.youlai.admin.pojo;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.youlai.common.core.base.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SysPermission extends BaseEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private String name;
|
||||
private String permission;
|
||||
|
||||
// 拥有资源权限角色ID集合
|
||||
@TableField(exist = false)
|
||||
private List<Long> roleIds;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.youlai.admin.pojo;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SysRolePermission {
|
||||
private Long roleId;
|
||||
private Long permissionId;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.youlai.admin.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PermissionVO {
|
||||
List<TreeVO> permissions;
|
||||
List<Long> checkedKeys;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.youlai.admin.pojo.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TreeVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String label;
|
||||
|
||||
private List<TreeVO> children;
|
||||
|
||||
}
|
@ -23,7 +23,7 @@ public interface AuthConstants {
|
||||
/**
|
||||
* Redis缓存权限规则key
|
||||
*/
|
||||
String RESOURCE_ROLES_KEY = "auth:resourceRoles";
|
||||
String PERMISSION_RULES_KEY = "auth:permission:rules";
|
||||
|
||||
/**
|
||||
* 黑名单token前缀
|
||||
|
@ -56,15 +56,15 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
|
||||
}
|
||||
|
||||
// 从缓存取资源权限角色关系列表
|
||||
Map<Object, Object> resourceRolesMap = redisTemplate.opsForHash().entries(AuthConstants.RESOURCE_ROLES_KEY);
|
||||
Iterator<Object> iterator = resourceRolesMap.keySet().iterator();
|
||||
Map<Object, Object> permissionRoles = redisTemplate.opsForHash().entries(AuthConstants.PERMISSION_RULES_KEY);
|
||||
Iterator<Object> iterator = permissionRoles.keySet().iterator();
|
||||
|
||||
// 请求路径匹配到的资源需要的角色权限集合authorities统计
|
||||
Set<String> authorities = new HashSet<>();
|
||||
while (iterator.hasNext()) {
|
||||
String pattern = (String) iterator.next();
|
||||
if (pathMatcher.match(pattern, path)) {
|
||||
authorities.addAll(Convert.toList(String.class, resourceRolesMap.get(pattern)));
|
||||
authorities.addAll(Convert.toList(String.class, permissionRoles.get(pattern)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user