/** * Front-end API wrapper for this module. * Call guide: import the named API object, then call the matching method from a Vue page or composable. */ import { adminApi } from './admin' import type { IdType } from '@/utils/id' /** * Purpose: PermissionVO supports permission.ts by holding or executing the permission vo page or API role. * Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow. */ export interface PermissionVO { id: IdType permissionCode: string permissionName: string permissionGroup: string description: string createTime: string updateTime: string } /** * Purpose: CreatePermissionRequest supports permission.ts by holding or executing the create permission request page or API role. * Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow. */ export interface CreatePermissionRequest { permissionCode: string permissionName: string permissionGroup: string description: string } /** * Purpose: UpdatePermissionRequest supports permission.ts by holding or executing the update permission request page or API role. * Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow. */ export interface UpdatePermissionRequest { permissionCode?: string permissionName?: string permissionGroup?: string description?: string } /** * permissionApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const permissionApi = { /** * `getUserPermissions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param userId?: IdType caller-supplied value for `userId?: IdType` */ getUserPermissions: (userId?: IdType) => { if (userId) { return adminApi.get(`/permission/user/${userId}`) } return adminApi.get('/permission/user/current') }, /** * `getAssignablePermissionIds` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param userId: IdType caller-supplied value for `userId: IdType` */ getAssignablePermissionIds: (userId: IdType) => { return adminApi.get(`/permission/assignable/${userId}`) }, /** * `listAllPermissions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listAllPermissions: () => { return adminApi.get('/permission/list/all') }, /** * `createPermission` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: CreatePermissionRequest caller-supplied value for `data: CreatePermissionRequest` */ createPermission: (data: CreatePermissionRequest) => { return adminApi.post('/permission/create', data) }, /** * `updatePermission` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: UpdatePermissionRequest caller-supplied value for `data: UpdatePermissionRequest` */ updatePermission: (id: IdType, data: UpdatePermissionRequest) => { return adminApi.put(`/permission/update/${id}`, data) }, /** * `deletePermission` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ deletePermission: (id: IdType) => { return adminApi.delete(`/permission/delete/${id}`) }, /** * `assignUserPermissions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param userId: IdType caller-supplied value for `userId: IdType` * @param permissionIds: IdType[] caller-supplied value for `permissionIds: IdType[]` */ assignUserPermissions: (userId: IdType, permissionIds: IdType[]) => { return adminApi.post(`/permission/assign/${userId}`, { permissionIds }) } }