38 lines
968 B
TypeScript
38 lines
968 B
TypeScript
import { axios } from "./BaseAPI";
|
|
import type { ModuleCode, Page, PageResult, Permission, PermissionPayload } from "../types";
|
|
|
|
const BASE_URI = "/user/permission";
|
|
|
|
async function list(req: Page<Permission>): Promise<PageResult<Permission>> {
|
|
return axios.post(`${BASE_URI}/list`, req);
|
|
}
|
|
|
|
async function create(req: PermissionPayload): Promise<void> {
|
|
return axios.post(`${BASE_URI}/create`, req);
|
|
}
|
|
|
|
async function update(req: PermissionPayload): Promise<void> {
|
|
return axios.post(`${BASE_URI}/update`, req);
|
|
}
|
|
|
|
async function remove(id: string): Promise<void> {
|
|
return axios.post(`${BASE_URI}/delete`, undefined, {
|
|
params: { id }
|
|
});
|
|
}
|
|
|
|
/** 查询当前登录用户在指定模块内可转授的权限。 */
|
|
async function grantableList(moduleCode: ModuleCode): Promise<Permission[]> {
|
|
return await axios.post(`${BASE_URI}/grantable/list`, undefined, {
|
|
params: { moduleCode }
|
|
});
|
|
}
|
|
|
|
export default {
|
|
list,
|
|
create,
|
|
update,
|
|
remove,
|
|
grantableList
|
|
};
|