import { createApiClient } from "../lib/apiClient"; import type { RoleDto } from "../types/role"; const api = createApiClient({ getToken: () => { try { return localStorage.getItem("access_token") ?? localStorage.getItem("token") ?? null; } catch { return null; } }, }); const PATH = "/rbac-role"; export type RbacRoleUpsertInput = { roleName: string; roleCode: string; remark?: string | null; dataScope?: number | null; state: boolean; orderNum?: number | null; }; export async function createRbacRole(input: RbacRoleUpsertInput): Promise { return api.requestJson({ path: PATH, method: "POST", body: input, }); } export async function updateRbacRole(id: string, input: RbacRoleUpsertInput): Promise { return api.requestJson({ path: `${PATH}/${encodeURIComponent(id)}`, method: "PUT", body: input, }); } /** * Swagger(常见约定):DELETE /api/app/rbac-role,Body 为 ID 数组 */ export async function deleteRbacRoles(ids: string[]): Promise { if (!ids.length) return; await api.requestJson({ path: PATH, method: "DELETE", body: ids, }); } export async function deleteRbacRole(id: string): Promise { await deleteRbacRoles([id]); }