From 85287e1f7f0dc402135e8bae317583e158469377 Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 1 Aug 2022 19:03:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PermissionAssignUserRoleReqVO.java | 4 +- .../src/api/system/permission/index.ts | 33 +++++++ .../src/api/system/permission/types.ts | 15 +++ .../src/api/system/role/index.ts | 29 +++--- .../src/components/CountTo/src/CountTo.vue | 2 +- .../src/views/system/role/index.vue | 74 +++++++++++---- .../src/views/system/user/index.vue | 91 ++++++++++++++++++- .../src/views/system/user/user.data.ts | 2 +- 8 files changed, 210 insertions(+), 40 deletions(-) create mode 100644 yudao-ui-admin-vue3/src/api/system/permission/index.ts create mode 100644 yudao-ui-admin-vue3/src/api/system/permission/types.ts diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/permission/PermissionAssignUserRoleReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/permission/PermissionAssignUserRoleReqVO.java index 75671bcd2c..93cc8ffa27 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/permission/PermissionAssignUserRoleReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/permission/PermissionAssignUserRoleReqVO.java @@ -12,8 +12,8 @@ import java.util.Set; @Data public class PermissionAssignUserRoleReqVO { - @ApiModelProperty(value = "角色编号", required = true, example = "1") - @NotNull(message = "角色编号不能为空") + @ApiModelProperty(value = "用户编号", required = true, example = "1") + @NotNull(message = "用户编号不能为空") private Long userId; @ApiModelProperty(value = "角色编号列表", example = "1,3,5") diff --git a/yudao-ui-admin-vue3/src/api/system/permission/index.ts b/yudao-ui-admin-vue3/src/api/system/permission/index.ts new file mode 100644 index 0000000000..f498826eaf --- /dev/null +++ b/yudao-ui-admin-vue3/src/api/system/permission/index.ts @@ -0,0 +1,33 @@ +import { useAxios } from '@/hooks/web/useAxios' +import type { + PermissionAssignRoleDataScopeReqVO, + PermissionAssignRoleMenuReqVO, + PermissionAssignUserRoleReqVO +} from './types' + +const request = useAxios() + +// 查询角色拥有的菜单权限 +export const listRoleMenusApi = async (roleId: number) => { + return await request.get({ url: '/system/permission/list-role-resources?roleId=' + roleId }) +} + +// 赋予角色菜单权限 +export const assignRoleMenuApi = async (data: PermissionAssignRoleMenuReqVO) => { + return await request.post({ url: '/system/permission/assign-role-menu', data }) +} + +// 赋予角色数据权限 +export const assignRoleDataScopeApi = async (data: PermissionAssignRoleDataScopeReqVO) => { + return await request.post({ url: '/system/permission/assign-role-data-scope', data }) +} + +// 查询用户拥有的角色数组 +export const listUserRolesApi = async (userId: number) => { + return await request.get({ url: '/system/permission/list-user-roles?userId=' + userId }) +} + +// 赋予用户角色 +export const aassignUserRoleApi = async (data: PermissionAssignUserRoleReqVO) => { + return await request.post({ url: '/system/permission/assign-user-role', data }) +} diff --git a/yudao-ui-admin-vue3/src/api/system/permission/types.ts b/yudao-ui-admin-vue3/src/api/system/permission/types.ts new file mode 100644 index 0000000000..1050c39e29 --- /dev/null +++ b/yudao-ui-admin-vue3/src/api/system/permission/types.ts @@ -0,0 +1,15 @@ +export type PermissionAssignUserRoleReqVO = { + userId: number + roleIds: number[] +} + +export type PermissionAssignRoleMenuReqVO = { + roleId: number + menuIds: number[] +} + +export type PermissionAssignRoleDataScopeReqVO = { + roleId: number + dataScope: number + dataScopeDeptIds: number[] +} diff --git a/yudao-ui-admin-vue3/src/api/system/role/index.ts b/yudao-ui-admin-vue3/src/api/system/role/index.ts index 99c8a2d93e..c5b3589f0d 100644 --- a/yudao-ui-admin-vue3/src/api/system/role/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/role/index.ts @@ -4,31 +4,36 @@ import type { RoleVO } from './types' const request = useAxios() // 查询角色列表 -export const getRolePageApi = (params) => { - return request.get({ url: '/system/role/page', params }) +export const getRolePageApi = async (params) => { + return await request.get({ url: '/system/role/page', params }) +} + +// 查询角色(精简)列表 +export const listSimpleRolesApi = async () => { + return await request.get({ url: '/system/role/list-all-simple' }) } // 查询角色详情 -export const getRoleApi = (id: number) => { - return request.get({ url: '/system/role/get?id=' + id }) +export const getRoleApi = async (id: number) => { + return await request.get({ url: '/system/role/get?id=' + id }) } // 新增角色 -export const createRoleApi = (data: RoleVO) => { - return request.post({ url: '/system/role/create', data }) +export const createRoleApi = async (data: RoleVO) => { + return await request.post({ url: '/system/role/create', data }) } // 修改角色 -export const updateRoleApi = (data: RoleVO) => { - return request.put({ url: '/system/role/update', data }) +export const updateRoleApi = async (data: RoleVO) => { + return await request.put({ url: '/system/role/update', data }) } // 修改角色状态 -export const updateRoleStatusApi = (data: RoleVO) => { - return request.put({ url: '/system/role/update-status', data }) +export const updateRoleStatusApi = async (data: RoleVO) => { + return await request.put({ url: '/system/role/update-status', data }) } // 删除角色 -export const deleteRoleApi = (id: number) => { - return request.delete({ url: '/system/role/delete?id=' + id }) +export const deleteRoleApi = async (id: number) => { + return await request.delete({ url: '/system/role/delete?id=' + id }) } diff --git a/yudao-ui-admin-vue3/src/components/CountTo/src/CountTo.vue b/yudao-ui-admin-vue3/src/components/CountTo/src/CountTo.vue index 7d8d37b1ed..cab8ea9651 100644 --- a/yudao-ui-admin-vue3/src/components/CountTo/src/CountTo.vue +++ b/yudao-ui-admin-vue3/src/components/CountTo/src/CountTo.vue @@ -157,7 +157,7 @@ const count = (timestamp: number) => { } else { state.printVal = state.printVal > endVal ? endVal : state.printVal } - state.displayValue = formatNumber(state.printVal) + state.displayValue = formatNumber(state.printVal!) if (progress < (state.localDuration as number)) { state.rAF = requestAnimationFrame(count) } else { diff --git a/yudao-ui-admin-vue3/src/views/system/role/index.vue b/yudao-ui-admin-vue3/src/views/system/role/index.vue index 12e3f0eb68..dfae295b1d 100644 --- a/yudao-ui-admin-vue3/src/views/system/role/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/role/index.vue @@ -1,14 +1,6 @@