diff --git a/admin-web/src/models/menu.js b/admin-web/src/models/menu.js index 347ecdfc9..9e19845fb 100644 --- a/admin-web/src/models/menu.js +++ b/admin-web/src/models/menu.js @@ -3,8 +3,7 @@ import isEqual from 'lodash/isEqual'; import { formatMessage } from 'umi/locale'; import Authorized from '@/utils/Authorized'; import { menu } from '../defaultSettings'; -import { getAdminUrls } from '../services/admin'; -import { authorizationMenuResourceTree } from '../services/system'; +import { authorizationMenuResourceTree, authorizationResourcePermissions } from '../services/system'; const { check } = Authorized; @@ -213,7 +212,7 @@ export default { }); }, *getUrlsData(state, { put, call }) { - const { data } = yield call(getAdminUrls); + const { data } = yield call(authorizationResourcePermissions); // 构建 {'/user': true} 这种 map 结构方便取数据、 const urlsData = {}; diff --git a/admin-web/src/services/admin.js b/admin-web/src/services/admin.js index 4ab8ada42..03e44d30f 100644 --- a/admin-web/src/services/admin.js +++ b/admin-web/src/services/admin.js @@ -1,12 +1,6 @@ import { stringify } from '@/utils/request.qs'; import request from '@/utils/request'; -// auth - -export async function getAdminUrls(params) { - return request(`/admin-api/admins/admin/url_resource_list?${stringify(params)}`); -} - // admin export async function queryAdmin(params) { diff --git a/admin-web/src/services/system.js b/admin-web/src/services/system.js index 9ce73e9bb..e893e4cbb 100644 --- a/admin-web/src/services/system.js +++ b/admin-web/src/services/system.js @@ -1,4 +1,4 @@ -import { stringify } from '@/utils/request.qs'; +import {stringify} from '@/utils/request.qs'; import request from '@/utils/request'; // ========== OAuth2 模块 ========== @@ -14,6 +14,12 @@ export async function oauth2UsernameAuthenticate(params) { export async function authorizationMenuResourceTree() { return request('/system-api/admins/authorization/menu-resource-tree', { - method: 'GET', + method: 'GET', + }); +} + +export async function authorizationResourcePermissions(params) { + return request(`/system-api/admins/authorization/resource-permissions`, { + method: 'GET', }); } diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/controller/authorization/AdminsAuthorizationController.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/controller/authorization/AdminsAuthorizationController.java index 9c13d6254..3ca5f6500 100644 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/controller/authorization/AdminsAuthorizationController.java +++ b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/controller/authorization/AdminsAuthorizationController.java @@ -63,4 +63,12 @@ public class AdminsAuthorizationController { return CommonResult.success(rootNodes); } + @GetMapping("/resource-permissions") + @ApiOperation(value = "获得当前账号的资源权限列表") + public CommonResult> resourcePermissions() { + List resources = authorizationService.getResourcesByAccountId(new AuthorizationGetResourcesByAccountIdDTO() + .setAccountId(AdminSecurityContextHolder.getAccountId())); + return CommonResult.success(resources.stream().map(ResourceBO::getRoute).collect(Collectors.toSet())); + } + } diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/AdminController.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/AdminController.java index 01ce1f5fd..0e6345987 100644 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/AdminController.java +++ b/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/AdminController.java @@ -50,17 +50,6 @@ public class AdminController { @Autowired private DeptmentService deptmentService; - // =========== 当前管理员相关的资源 API =========== - - // TODO 功能:当前管理员 - - @GetMapping("/url_resource_list") - @ApiOperation(value = "获得当前登陆的管理员拥有的 URL 权限列表") - public CommonResult> urlResourceList() { - List resources = resourceService.getResourcesByTypeAndRoleIds(ResourceConstants.TYPE_BUTTON, AdminSecurityContextHolder.getContext().getRoleIds()); - return success(resources.stream().map(ResourceBO::getHandler).collect(Collectors.toSet())); - } - // =========== 管理员管理 API =========== //TODO 目前需要增加搜索所有子部门的用户 @GetMapping("/page")