update permission
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { axios } from "./BaseAPI";
|
import { axios } from "./BaseAPI";
|
||||||
import type { Page, PageResult, Permission, PermissionPayload } from "../types";
|
import type { ModuleCode, Page, PageResult, Permission, PermissionPayload } from "../types";
|
||||||
|
|
||||||
const BASE_URI = "/user/permission";
|
const BASE_URI = "/user/permission";
|
||||||
|
|
||||||
@@ -21,9 +21,17 @@ async function remove(id: string): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 查询当前登录用户在指定模块内可转授的权限。 */
|
||||||
|
async function grantableList(moduleCode: ModuleCode): Promise<Permission[]> {
|
||||||
|
return await axios.post(`${BASE_URI}/grantable/list`, undefined, {
|
||||||
|
params: { moduleCode }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
list,
|
list,
|
||||||
create,
|
create,
|
||||||
update,
|
update,
|
||||||
remove
|
remove,
|
||||||
|
grantableList
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,6 +27,65 @@ async function remove(id: string): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 查询当前登录用户在模块内可管理的角色。 */
|
||||||
|
async function manageableList(moduleCode: ModuleCode): Promise<Role[]> {
|
||||||
|
return await axios.post(`${BASE_URI}/manageable/list`, undefined, {
|
||||||
|
params: { moduleCode }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询当前登录用户在模块内可授权给账号的角色。 */
|
||||||
|
async function grantableList(moduleCode: ModuleCode): Promise<Role[]> {
|
||||||
|
return await axios.post(`${BASE_URI}/grantable/list`, undefined, {
|
||||||
|
params: { moduleCode }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询当前登录用户直属角色详情,不按可管理范围过滤。 */
|
||||||
|
async function currentDetailList(moduleCode?: ModuleCode): Promise<Role[]> {
|
||||||
|
return await axios.post(`${BASE_URI}/current/detail/list`, undefined, {
|
||||||
|
params: { moduleCode }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询当前登录用户可以给目标角色配置的直接权限 P 候选项。 */
|
||||||
|
async function grantablePermissionList(roleId: string): Promise<Permission[]> {
|
||||||
|
return await axios.post(`${BASE_URI}/permission/grantable/list`, undefined, {
|
||||||
|
params: { roleId }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询目标角色当前可继续转授的权限 D。 */
|
||||||
|
async function delegationList(roleId: string): Promise<Permission[]> {
|
||||||
|
return await axios.post(`${BASE_URI}/delegation/list`, undefined, {
|
||||||
|
params: { roleId }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询当前登录用户可以给目标角色配置的 D 候选项。 */
|
||||||
|
async function grantableDelegationList(roleId: string): Promise<Permission[]> {
|
||||||
|
return await axios.post(`${BASE_URI}/delegation/grantable/list`, undefined, {
|
||||||
|
params: { roleId }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 覆盖保存目标角色可继续转授的权限 D。 */
|
||||||
|
async function updateDelegation(req: Pick<RolePayload, "id" | "delegationPermissionIdList">): Promise<void> {
|
||||||
|
await axios.post(`${BASE_URI}/delegation/update`, req);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询目标角色可选管理父级。 */
|
||||||
|
async function parentGrantableList(roleId: string): Promise<Role[]> {
|
||||||
|
return await axios.post(`${BASE_URI}/parent/grantable/list`, undefined, {
|
||||||
|
params: { roleId }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 保存目标角色管理父级。 */
|
||||||
|
async function updateParent(req: Pick<RolePayload, "id" | "parentRoleId">): Promise<void> {
|
||||||
|
await axios.post(`${BASE_URI}/parent/update`, req);
|
||||||
|
}
|
||||||
|
|
||||||
async function authorizedList(userId: string, moduleCode?: ModuleCode): Promise<Role[]> {
|
async function authorizedList(userId: string, moduleCode?: ModuleCode): Promise<Role[]> {
|
||||||
return axios.post(`${BASE_URI}/authorized/list`, undefined, {
|
return axios.post(`${BASE_URI}/authorized/list`, undefined, {
|
||||||
params: {
|
params: {
|
||||||
@@ -52,6 +111,15 @@ export default {
|
|||||||
create,
|
create,
|
||||||
update,
|
update,
|
||||||
remove,
|
remove,
|
||||||
|
manageableList,
|
||||||
|
grantableList,
|
||||||
|
currentDetailList,
|
||||||
|
grantablePermissionList,
|
||||||
|
delegationList,
|
||||||
|
grantableDelegationList,
|
||||||
|
updateDelegation,
|
||||||
|
parentGrantableList,
|
||||||
|
updateParent,
|
||||||
authorizedList,
|
authorizedList,
|
||||||
authorize,
|
authorize,
|
||||||
authorizedPermission
|
authorizedPermission
|
||||||
|
|||||||
@@ -7,11 +7,18 @@ export interface Permission {
|
|||||||
nameLangId?: string;
|
nameLangId?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
builtin?: boolean;
|
||||||
|
protectedPermission?: boolean;
|
||||||
|
ownerType?: AuthOwnerType;
|
||||||
|
ownerId?: string;
|
||||||
|
createdBy?: string;
|
||||||
createdAt?: number;
|
createdAt?: number;
|
||||||
updatedAt?: number;
|
updatedAt?: number;
|
||||||
deletedAt?: number;
|
deletedAt?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type AuthOwnerType = "SYSTEM" | "MODULE" | "TENANT" | "STORE" | "USER";
|
||||||
|
|
||||||
export type PermissionPayload = Pick<Permission, "moduleCode" | "code" | "nameLangId" | "name" | "description"> & {
|
export type PermissionPayload = Pick<Permission, "moduleCode" | "code" | "nameLangId" | "name" | "description"> & {
|
||||||
id?: string;
|
id?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
+15
-2
@@ -1,4 +1,4 @@
|
|||||||
import type { ModuleCode, Permission } from "./Permission";
|
import type { AuthOwnerType, ModuleCode, Permission } from "./Permission";
|
||||||
import { Model } from "./Model";
|
import { Model } from "./Model";
|
||||||
|
|
||||||
export type Role = {
|
export type Role = {
|
||||||
@@ -7,18 +7,31 @@ export type Role = {
|
|||||||
nameLangId?: string;
|
nameLangId?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
builtin?: boolean;
|
||||||
|
protectedRole?: boolean;
|
||||||
|
parentRoleId?: string;
|
||||||
|
ownerType?: AuthOwnerType;
|
||||||
|
ownerId?: string;
|
||||||
|
createdBy?: string;
|
||||||
|
|
||||||
permissionList?: Permission[];
|
permissionList?: Permission[];
|
||||||
allPermissionList?: Permission[];
|
allPermissionList?: Permission[];
|
||||||
childRoleList?: Role[];
|
childRoleList?: Role[];
|
||||||
|
parentRole?: Role;
|
||||||
|
delegationPermissionList?: Permission[];
|
||||||
permissionIdList?: string[];
|
permissionIdList?: string[];
|
||||||
childRoleIdList?: string[];
|
childRoleIdList?: string[];
|
||||||
|
delegationPermissionIdList?: string[];
|
||||||
} & Model;
|
} & Model;
|
||||||
|
|
||||||
export type RolePayload = Pick<Role, "moduleCode" | "code" | "nameLangId" | "name" | "description"> & {
|
export type RolePayload = Partial<Pick<Role, "moduleCode" | "code" | "nameLangId" | "name" | "description">> & {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
parentRoleId?: string;
|
||||||
|
ownerType?: AuthOwnerType;
|
||||||
|
ownerId?: string;
|
||||||
permissionIdList?: string[];
|
permissionIdList?: string[];
|
||||||
childRoleIdList?: string[];
|
childRoleIdList?: string[];
|
||||||
|
delegationPermissionIdList?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface AuthorizeUserRole {
|
export interface AuthorizeUserRole {
|
||||||
|
|||||||
Reference in New Issue
Block a user