修改权限

This commit is contained in:
wanggeng888 2021-06-22 17:19:25 +08:00
parent d6d6d612f5
commit 1a3155f8d5
5 changed files with 128 additions and 347 deletions

View File

@ -130,25 +130,15 @@ public class ClientRbacServiceImpl implements IClientRbacService {
}
List<String> savePaths = accessControl.getSavePaths();
// 匹配接口
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getApiSaveMenu()) {
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getSaveMenu()) {
for (String savePath : savePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + savePath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getApiPrefix()) && antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + savePath, uri)) {
return true;
}
}
}
// 匹配资源
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getResourceSaveMenu()) {
for (String savePath : savePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + savePath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getResourcePrefix()) && antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + savePath, uri)) {
return true;
}
}
}
// 匹配路由
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getRouteSaveMenu()) {
for (String savePath : savePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getRoutePrefix() + savePath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getRoutePrefix()) && antPathMatcher.match(contextPath + roleMenuBO.getRoutePrefix() + savePath, uri)) {
return true;
}
}
@ -173,17 +163,12 @@ public class ClientRbacServiceImpl implements IClientRbacService {
}
List<String> deletePaths = accessControl.getDeletePaths();
// 匹配接口
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getApiDeleteMenu()) {
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getDeleteMenu()) {
for (String deletePath : deletePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + deletePath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getApiPrefix()) && antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + deletePath, uri)) {
return true;
}
}
}
// 匹配资源
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getResourceDeleteMenu()) {
for (String deletePath : deletePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + deletePath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getResourcePrefix()) && antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + deletePath, uri)) {
return true;
}
}
@ -208,25 +193,15 @@ public class ClientRbacServiceImpl implements IClientRbacService {
}
List<String> updatePaths = accessControl.getUpdatePaths();
// 匹配接口
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getApiUpdateMenu()) {
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getUpdateMenu()) {
for (String updatePath : updatePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + updatePath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getApiPrefix()) && antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + updatePath, uri)) {
return true;
}
}
}
// 匹配资源
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getResourceUpdateMenu()) {
for (String updatePath : updatePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + updatePath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getResourcePrefix()) && antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + updatePath, uri)) {
return true;
}
}
}
// 匹配路由
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getRouteUpdateMenu()) {
for (String updatePath : updatePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getRoutePrefix() + updatePath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getRoutePrefix()) && antPathMatcher.match(contextPath + roleMenuBO.getRoutePrefix() + updatePath, uri)) {
return true;
}
}
@ -251,26 +226,23 @@ public class ClientRbacServiceImpl implements IClientRbacService {
}
List<String> queryPaths = accessControl.getQueryPaths();
// 匹配接口
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getApiQueryMenu()) {
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getQueryMenu()) {
if (StringUtils.isBlank(roleMenuBO.getApiPrefix())
&& StringUtils.isBlank(roleMenuBO.getResourcePrefix())
&& StringUtils.isBlank(roleMenuBO.getRoutePrefix())) {
continue;
}
for (String queryPath : queryPaths) {
String queryAntPath = contextPath + roleMenuBO.getApiPrefix() + queryPath;
if (antPathMatcher.match(queryAntPath, uri)) {
if (!StringUtils.isBlank(roleMenuBO.getApiPrefix()) && antPathMatcher.match(queryAntPath, uri)) {
return true;
}
}
}
// 匹配资源
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getResourceQueryMenu()) {
for (String queryPath : queryPaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + queryPath, uri)) {
queryAntPath = contextPath + roleMenuBO.getResourcePrefix() + queryPath;
if (!StringUtils.isBlank(roleMenuBO.getResourcePrefix()) && antPathMatcher.match(queryAntPath, uri)) {
return true;
}
}
}
// 匹配路由
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getRouteQueryMenu()) {
for (String queryPath : queryPaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getRoutePrefix() + queryPath, uri)) {
queryAntPath = contextPath + roleMenuBO.getRoutePrefix() + queryPath;
if (!StringUtils.isBlank(roleMenuBO.getRoutePrefix()) && antPathMatcher.match(queryAntPath, uri)) {
return true;
}
}

View File

@ -18,17 +18,10 @@ public class RoleBO implements Serializable {
private String roleName;
private String roleSummary;
private String roleDataAuthority;
private List<RoleMenuBO> apiSaveMenu = new ArrayList<>();
private List<RoleMenuBO> apiDeleteMenu = new ArrayList<>();
private List<RoleMenuBO> apiUpdateMenu = new ArrayList<>();
private List<RoleMenuBO> apiQueryMenu = new ArrayList<>();
private List<RoleMenuBO> resourceSaveMenu = new ArrayList<>();
private List<RoleMenuBO> resourceDeleteMenu = new ArrayList<>();
private List<RoleMenuBO> resourceUpdateMenu = new ArrayList<>();
private List<RoleMenuBO> resourceQueryMenu = new ArrayList<>();
private List<RoleMenuBO> routeSaveMenu = new ArrayList<>();
private List<RoleMenuBO> routeUpdateMenu = new ArrayList<>();
private List<RoleMenuBO> routeQueryMenu = new ArrayList<>();
private List<RoleMenuBO> saveMenu = new ArrayList<>();
private List<RoleMenuBO> deleteMenu = new ArrayList<>();
private List<RoleMenuBO> updateMenu = new ArrayList<>();
private List<RoleMenuBO> queryMenu = new ArrayList<>();
private List<PermissionBO> permissionInsert = new ArrayList<>();
private List<PermissionBO> permissionDelete = new ArrayList<>();
private List<PermissionBO> permissionUpdate = new ArrayList<>();
@ -66,92 +59,36 @@ public class RoleBO implements Serializable {
this.roleDataAuthority = roleDataAuthority;
}
public List<RoleMenuBO> getApiSaveMenu() {
return apiSaveMenu;
public List<RoleMenuBO> getSaveMenu() {
return saveMenu == null ? new ArrayList() : saveMenu;
}
public void setApiSaveMenu(List<RoleMenuBO> apiSaveMenu) {
this.apiSaveMenu = apiSaveMenu;
public void setSaveMenu(List<RoleMenuBO> saveMenu) {
this.saveMenu = saveMenu;
}
public List<RoleMenuBO> getApiDeleteMenu() {
return apiDeleteMenu;
public List<RoleMenuBO> getDeleteMenu() {
return deleteMenu == null ? new ArrayList() : deleteMenu;
}
public void setApiDeleteMenu(List<RoleMenuBO> apiDeleteMenu) {
this.apiDeleteMenu = apiDeleteMenu;
public void setDeleteMenu(List<RoleMenuBO> deleteMenu) {
this.deleteMenu = deleteMenu;
}
public List<RoleMenuBO> getApiUpdateMenu() {
return apiUpdateMenu;
public List<RoleMenuBO> getUpdateMenu() {
return updateMenu == null ? new ArrayList() : updateMenu;
}
public void setApiUpdateMenu(List<RoleMenuBO> apiUpdateMenu) {
this.apiUpdateMenu = apiUpdateMenu;
public void setUpdateMenu(List<RoleMenuBO> updateMenu) {
this.updateMenu = updateMenu;
}
public List<RoleMenuBO> getApiQueryMenu() {
return apiQueryMenu;
public List<RoleMenuBO> getQueryMenu() {
return queryMenu == null ? new ArrayList() : queryMenu;
}
public void setApiQueryMenu(List<RoleMenuBO> apiQueryMenu) {
this.apiQueryMenu = apiQueryMenu;
}
public List<RoleMenuBO> getResourceSaveMenu() {
return resourceSaveMenu;
}
public void setResourceSaveMenu(List<RoleMenuBO> resourceSaveMenu) {
this.resourceSaveMenu = resourceSaveMenu;
}
public List<RoleMenuBO> getResourceDeleteMenu() {
return resourceDeleteMenu;
}
public void setResourceDeleteMenu(List<RoleMenuBO> resourceDeleteMenu) {
this.resourceDeleteMenu = resourceDeleteMenu;
}
public List<RoleMenuBO> getResourceUpdateMenu() {
return resourceUpdateMenu;
}
public void setResourceUpdateMenu(List<RoleMenuBO> resourceUpdateMenu) {
this.resourceUpdateMenu = resourceUpdateMenu;
}
public List<RoleMenuBO> getResourceQueryMenu() {
return resourceQueryMenu;
}
public void setResourceQueryMenu(List<RoleMenuBO> resourceQueryMenu) {
this.resourceQueryMenu = resourceQueryMenu;
}
public List<RoleMenuBO> getRouteSaveMenu() {
return routeSaveMenu;
}
public void setRouteSaveMenu(List<RoleMenuBO> routeSaveMenu) {
this.routeSaveMenu = routeSaveMenu;
}
public List<RoleMenuBO> getRouteUpdateMenu() {
return routeUpdateMenu;
}
public void setRouteUpdateMenu(List<RoleMenuBO> routeUpdateMenu) {
this.routeUpdateMenu = routeUpdateMenu;
}
public List<RoleMenuBO> getRouteQueryMenu() {
return routeQueryMenu;
}
public void setRouteQueryMenu(List<RoleMenuBO> routeQueryMenu) {
this.routeQueryMenu = routeQueryMenu;
public void setQueryMenu(List<RoleMenuBO> queryMenu) {
this.queryMenu = queryMenu;
}
public List<PermissionBO> getPermissionInsert() {
@ -189,36 +126,22 @@ public class RoleBO implements Serializable {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"roleId\":")
.append("\"").append(roleId).append("\"");
sb.append(",\"roleName\":")
.append("\"").append(roleName).append("\"");
sb.append(",\"roleSummary\":")
.append("\"").append(roleSummary).append("\"");
sb.append(",\"roleDataAuthority\":")
.append("\"").append(roleDataAuthority).append("\"");
sb.append(",\"apiSaveMenu\":")
.append(apiSaveMenu);
sb.append(",\"apiDeleteMenu\":")
.append(apiDeleteMenu);
sb.append(",\"apiUpdateMenu\":")
.append(apiUpdateMenu);
sb.append(",\"apiQueryMenu\":")
.append(apiQueryMenu);
sb.append(",\"resourceSaveMenu\":")
.append(resourceSaveMenu);
sb.append(",\"resourceDeleteMenu\":")
.append(resourceDeleteMenu);
sb.append(",\"resourceUpdateMenu\":")
.append(resourceUpdateMenu);
sb.append(",\"resourceQueryMenu\":")
.append(resourceQueryMenu);
sb.append(",\"routeSaveMenu\":")
.append(routeSaveMenu);
sb.append(",\"routeUpdateMenu\":")
.append(routeUpdateMenu);
sb.append(",\"routeQueryMenu\":")
.append(routeQueryMenu);
sb.append("\"roleId\":\"")
.append(roleId).append('\"');
sb.append(",\"roleName\":\"")
.append(roleName).append('\"');
sb.append(",\"roleSummary\":\"")
.append(roleSummary).append('\"');
sb.append(",\"roleDataAuthority\":\"")
.append(roleDataAuthority).append('\"');
sb.append(",\"saveMenu\":")
.append(saveMenu);
sb.append(",\"deleteMenu\":")
.append(deleteMenu);
sb.append(",\"updateMenu\":")
.append(updateMenu);
sb.append(",\"queryMenu\":")
.append(queryMenu);
sb.append(",\"permissionInsert\":")
.append(permissionInsert);
sb.append(",\"permissionDelete\":")

View File

@ -2,6 +2,7 @@ package com.cm.common.pojo.bos;
import org.springframework.security.core.GrantedAuthority;
import java.util.ArrayList;
import java.util.List;
/**
@ -17,17 +18,10 @@ public class RoleGrantedAuthority implements GrantedAuthority {
private String role;
private String roleId;
private String roleName;
private List<RoleMenuBO> apiSaveMenu;
private List<RoleMenuBO> apiDeleteMenu;
private List<RoleMenuBO> apiUpdateMenu;
private List<RoleMenuBO> apiQueryMenu;
private List<RoleMenuBO> resourceSaveMenu;
private List<RoleMenuBO> resourceDeleteMenu;
private List<RoleMenuBO> resourceUpdateMenu;
private List<RoleMenuBO> resourceQueryMenu;
private List<RoleMenuBO> routeSaveMenu;
private List<RoleMenuBO> routeUpdateMenu;
private List<RoleMenuBO> routeQueryMenu;
private List<RoleMenuBO> saveMenu;
private List<RoleMenuBO> deleteMenu;
private List<RoleMenuBO> updateMenu;
private List<RoleMenuBO> queryMenu;
private List<PermissionBO> permissionInsert;
private List<PermissionBO> permissionDelete;
private List<PermissionBO> permissionUpdate;
@ -41,17 +35,10 @@ public class RoleGrantedAuthority implements GrantedAuthority {
this.role = role;
this.roleId = roleBO.getRoleId();
this.roleName = roleBO.getRoleName();
this.apiSaveMenu = roleBO.getApiSaveMenu();
this.apiDeleteMenu = roleBO.getApiDeleteMenu();
this.apiUpdateMenu = roleBO.getApiUpdateMenu();
this.apiQueryMenu = roleBO.getApiQueryMenu();
this.resourceSaveMenu = roleBO.getResourceSaveMenu();
this.resourceDeleteMenu = roleBO.getResourceDeleteMenu();
this.resourceUpdateMenu = roleBO.getResourceUpdateMenu();
this.resourceQueryMenu = roleBO.getResourceQueryMenu();
this.routeSaveMenu = roleBO.getRouteSaveMenu();
this.routeUpdateMenu = roleBO.getRouteUpdateMenu();
this.routeQueryMenu = roleBO.getRouteQueryMenu();
this.saveMenu = roleBO.getSaveMenu();
this.deleteMenu = roleBO.getDeleteMenu();
this.updateMenu = roleBO.getUpdateMenu();
this.queryMenu = roleBO.getQueryMenu();
this.permissionInsert = roleBO.getPermissionInsert();
this.permissionDelete = roleBO.getPermissionDelete();
this.permissionUpdate = roleBO.getPermissionUpdate();
@ -93,92 +80,36 @@ public class RoleGrantedAuthority implements GrantedAuthority {
this.roleName = roleName;
}
public List<RoleMenuBO> getApiSaveMenu() {
return apiSaveMenu;
public List<RoleMenuBO> getSaveMenu() {
return saveMenu == null ? new ArrayList() : saveMenu;
}
public void setApiSaveMenu(List<RoleMenuBO> apiSaveMenu) {
this.apiSaveMenu = apiSaveMenu;
public void setSaveMenu(List<RoleMenuBO> saveMenu) {
this.saveMenu = saveMenu;
}
public List<RoleMenuBO> getApiDeleteMenu() {
return apiDeleteMenu;
public List<RoleMenuBO> getDeleteMenu() {
return deleteMenu == null ? new ArrayList() : deleteMenu;
}
public void setApiDeleteMenu(List<RoleMenuBO> apiDeleteMenu) {
this.apiDeleteMenu = apiDeleteMenu;
public void setDeleteMenu(List<RoleMenuBO> deleteMenu) {
this.deleteMenu = deleteMenu;
}
public List<RoleMenuBO> getApiUpdateMenu() {
return apiUpdateMenu;
public List<RoleMenuBO> getUpdateMenu() {
return updateMenu == null ? new ArrayList() : updateMenu;
}
public void setApiUpdateMenu(List<RoleMenuBO> apiUpdateMenu) {
this.apiUpdateMenu = apiUpdateMenu;
public void setUpdateMenu(List<RoleMenuBO> updateMenu) {
this.updateMenu = updateMenu;
}
public List<RoleMenuBO> getApiQueryMenu() {
return apiQueryMenu;
public List<RoleMenuBO> getQueryMenu() {
return queryMenu == null ? new ArrayList() : queryMenu;
}
public void setApiQueryMenu(List<RoleMenuBO> apiQueryMenu) {
this.apiQueryMenu = apiQueryMenu;
}
public List<RoleMenuBO> getResourceSaveMenu() {
return resourceSaveMenu;
}
public void setResourceSaveMenu(List<RoleMenuBO> resourceSaveMenu) {
this.resourceSaveMenu = resourceSaveMenu;
}
public List<RoleMenuBO> getResourceDeleteMenu() {
return resourceDeleteMenu;
}
public void setResourceDeleteMenu(List<RoleMenuBO> resourceDeleteMenu) {
this.resourceDeleteMenu = resourceDeleteMenu;
}
public List<RoleMenuBO> getResourceUpdateMenu() {
return resourceUpdateMenu;
}
public void setResourceUpdateMenu(List<RoleMenuBO> resourceUpdateMenu) {
this.resourceUpdateMenu = resourceUpdateMenu;
}
public List<RoleMenuBO> getResourceQueryMenu() {
return resourceQueryMenu;
}
public void setResourceQueryMenu(List<RoleMenuBO> resourceQueryMenu) {
this.resourceQueryMenu = resourceQueryMenu;
}
public List<RoleMenuBO> getRouteSaveMenu() {
return routeSaveMenu;
}
public void setRouteSaveMenu(List<RoleMenuBO> routeSaveMenu) {
this.routeSaveMenu = routeSaveMenu;
}
public List<RoleMenuBO> getRouteUpdateMenu() {
return routeUpdateMenu;
}
public void setRouteUpdateMenu(List<RoleMenuBO> routeUpdateMenu) {
this.routeUpdateMenu = routeUpdateMenu;
}
public List<RoleMenuBO> getRouteQueryMenu() {
return routeQueryMenu;
}
public void setRouteQueryMenu(List<RoleMenuBO> routeQueryMenu) {
this.routeQueryMenu = routeQueryMenu;
public void setQueryMenu(List<RoleMenuBO> queryMenu) {
this.queryMenu = queryMenu;
}
public List<PermissionBO> getPermissionInsert() {
@ -216,34 +147,20 @@ public class RoleGrantedAuthority implements GrantedAuthority {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"role\":")
.append("\"").append(role).append("\"");
sb.append(",\"roleId\":")
.append("\"").append(roleId).append("\"");
sb.append(",\"roleName\":")
.append("\"").append(roleName).append("\"");
sb.append(",\"apiSaveMenu\":")
.append(apiSaveMenu);
sb.append(",\"apiDeleteMenu\":")
.append(apiDeleteMenu);
sb.append(",\"apiUpdateMenu\":")
.append(apiUpdateMenu);
sb.append(",\"apiQueryMenu\":")
.append(apiQueryMenu);
sb.append(",\"resourceSaveMenu\":")
.append(resourceSaveMenu);
sb.append(",\"resourceDeleteMenu\":")
.append(resourceDeleteMenu);
sb.append(",\"resourceUpdateMenu\":")
.append(resourceUpdateMenu);
sb.append(",\"resourceQueryMenu\":")
.append(resourceQueryMenu);
sb.append(",\"routeSaveMenu\":")
.append(routeSaveMenu);
sb.append(",\"routeUpdateMenu\":")
.append(routeUpdateMenu);
sb.append(",\"routeQueryMenu\":")
.append(routeQueryMenu);
sb.append("\"role\":\"")
.append(role).append('\"');
sb.append(",\"roleId\":\"")
.append(roleId).append('\"');
sb.append(",\"roleName\":\"")
.append(roleName).append('\"');
sb.append(",\"saveMenu\":")
.append(saveMenu);
sb.append(",\"deleteMenu\":")
.append(deleteMenu);
sb.append(",\"updateMenu\":")
.append(updateMenu);
sb.append(",\"queryMenu\":")
.append(queryMenu);
sb.append(",\"permissionInsert\":")
.append(permissionInsert);
sb.append(",\"permissionDelete\":")

View File

@ -18,6 +18,7 @@ public class RoleMenuBO implements Serializable {
private String apiPrefix;
private String resourcePrefix;
private String routePrefix;
private String menuUrl;
public String getRoleId() {
return roleId == null ? "" : roleId.trim();
@ -67,21 +68,31 @@ public class RoleMenuBO implements Serializable {
this.routePrefix = routePrefix;
}
public String getMenuUrl() {
return menuUrl == null ? "" : menuUrl;
}
public void setMenuUrl(String menuUrl) {
this.menuUrl = menuUrl;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"roleId\":")
.append("\"").append(roleId).append("\"");
sb.append(",\"roleType\":")
.append("\"").append(roleType).append("\"");
sb.append(",\"menuId\":")
.append("\"").append(menuId).append("\"");
sb.append(",\"apiPrefix\":")
.append("\"").append(apiPrefix).append("\"");
sb.append(",\"resourcePrefix\":")
.append("\"").append(resourcePrefix).append("\"");
sb.append(",\"routePrefix\":")
.append("\"").append(routePrefix).append("\"");
sb.append("\"roleId\":\"")
.append(roleId).append('\"');
sb.append(",\"roleType\":\"")
.append(roleType).append('\"');
sb.append(",\"menuId\":\"")
.append(menuId).append('\"');
sb.append(",\"apiPrefix\":\"")
.append(apiPrefix).append('\"');
sb.append(",\"resourcePrefix\":\"")
.append(resourcePrefix).append('\"');
sb.append(",\"routePrefix\":\"")
.append(routePrefix).append('\"');
sb.append(",\"menuUrl\":\"")
.append(menuUrl).append('\"');
sb.append('}');
return sb.toString();
}

View File

@ -66,17 +66,10 @@ public class RbacServiceImpl implements IRbacService {
RoleBO roleBO = new RoleBO();
roleBO.setRoleId(authorityObject.getString("roleId"));
roleBO.setRoleName(authorityObject.getString("roleName"));
roleBO.setApiSaveMenu(JSON.parseArray(authorityObject.getString("apiSaveMenu"), RoleMenuBO.class));
roleBO.setApiDeleteMenu(JSON.parseArray(authorityObject.getString("apiDeleteMenu"), RoleMenuBO.class));
roleBO.setApiUpdateMenu(JSON.parseArray(authorityObject.getString("apiSaveMenu"), RoleMenuBO.class));
roleBO.setApiQueryMenu(JSON.parseArray(authorityObject.getString("apiQueryMenu"), RoleMenuBO.class));
roleBO.setResourceSaveMenu(JSON.parseArray(authorityObject.getString("resourceSaveMenu"), RoleMenuBO.class));
roleBO.setResourceDeleteMenu(JSON.parseArray(authorityObject.getString("resourceDeleteMenu"), RoleMenuBO.class));
roleBO.setResourceUpdateMenu(JSON.parseArray(authorityObject.getString("resourceUpdateMenu"), RoleMenuBO.class));
roleBO.setResourceQueryMenu(JSON.parseArray(authorityObject.getString("resourceQueryMenu"), RoleMenuBO.class));
roleBO.setRouteSaveMenu(JSON.parseArray(authorityObject.getString("routeSaveMenu"), RoleMenuBO.class));
roleBO.setRouteUpdateMenu(JSON.parseArray(authorityObject.getString("routeUpdateMenu"), RoleMenuBO.class));
roleBO.setRouteQueryMenu(JSON.parseArray(authorityObject.getString("routeQueryMenu"), RoleMenuBO.class));
roleBO.setSaveMenu(JSON.parseArray(authorityObject.getString("saveMenu"), RoleMenuBO.class));
roleBO.setDeleteMenu(JSON.parseArray(authorityObject.getString("deleteMenu"), RoleMenuBO.class));
roleBO.setUpdateMenu(JSON.parseArray(authorityObject.getString("updateMenu"), RoleMenuBO.class));
roleBO.setQueryMenu(JSON.parseArray(authorityObject.getString("queryMenu"), RoleMenuBO.class));
roleGrantedAuthority = new RoleGrantedAuthority(authorityObject.getString("authority"), roleBO);
}
}
@ -151,24 +144,14 @@ public class RbacServiceImpl implements IRbacService {
private boolean hasSavePermission(String contextPath, String uri, RoleGrantedAuthority roleGrantedAuthority, AntPathMatcher antPathMatcher) {
List<String> savePaths = accessControl.getSavePaths();
// 匹配接口
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getApiSaveMenu()) {
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getSaveMenu()) {
for (String savePath : savePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + savePath, uri)) {
return true;
}
}
}
// 匹配资源
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getResourceSaveMenu()) {
for (String savePath : savePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + savePath, uri)) {
return true;
}
}
}
// 匹配路由
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getRouteSaveMenu()) {
for (String savePath : savePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getRoutePrefix() + savePath, uri)) {
return true;
}
@ -188,16 +171,11 @@ public class RbacServiceImpl implements IRbacService {
private boolean hasDeletePermission(String contextPath, String uri, RoleGrantedAuthority roleGrantedAuthority, AntPathMatcher antPathMatcher) {
List<String> deletePaths = accessControl.getDeletePaths();
// 匹配接口
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getApiDeleteMenu()) {
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getDeleteMenu()) {
for (String deletePath : deletePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + deletePath, uri)) {
return true;
}
}
}
// 匹配资源
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getResourceDeleteMenu()) {
for (String deletePath : deletePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + deletePath, uri)) {
return true;
}
@ -217,24 +195,14 @@ public class RbacServiceImpl implements IRbacService {
private boolean hasUpdatePermission(String contextPath, String uri, RoleGrantedAuthority roleGrantedAuthority, AntPathMatcher antPathMatcher) {
List<String> updatePaths = accessControl.getUpdatePaths();
// 匹配接口
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getApiUpdateMenu()) {
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getUpdateMenu()) {
for (String updatePath : updatePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getApiPrefix() + updatePath, uri)) {
return true;
}
}
}
// 匹配资源
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getResourceUpdateMenu()) {
for (String updatePath : updatePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + updatePath, uri)) {
return true;
}
}
}
// 匹配路由
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getRouteUpdateMenu()) {
for (String updatePath : updatePaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getRoutePrefix() + updatePath, uri)) {
return true;
}
@ -254,25 +222,15 @@ public class RbacServiceImpl implements IRbacService {
private boolean hasQueryPermission(String contextPath, String uri, RoleGrantedAuthority roleGrantedAuthority, AntPathMatcher antPathMatcher) {
List<String> queryPaths = accessControl.getQueryPaths();
// 匹配接口
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getApiQueryMenu()) {
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getQueryMenu()) {
for (String queryPath : queryPaths) {
String queryAntPath = contextPath + roleMenuBO.getApiPrefix() + queryPath;
if (antPathMatcher.match(queryAntPath, uri)) {
return true;
}
}
}
// 匹配资源
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getResourceQueryMenu()) {
for (String queryPath : queryPaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getResourcePrefix() + queryPath, uri)) {
return true;
}
}
}
// 匹配路由
for (RoleMenuBO roleMenuBO : roleGrantedAuthority.getRouteQueryMenu()) {
for (String queryPath : queryPaths) {
if (antPathMatcher.match(contextPath + roleMenuBO.getRoutePrefix() + queryPath, uri)) {
return true;
}