Files
model-platform/frontend/app/services/api/employees.ts
T
2026-09-02 10:10:41 +08:00

56 lines
1.5 KiB
TypeScript

import { apiRequest, type Employee } from "./_shared";
export async function listEmployees(workspaceId: string): Promise<Employee[]> {
return apiRequest<Employee[]>("/api/v1/admin/employees", {}, workspaceId);
}
/** @deprecated 使用 createPlatformEmployee 代替 */
export async function createEmployee(
workspaceId: string,
input: {
username: string;
display_name: string;
email?: string | null;
role_code: "admin" | "developer";
password: string;
},
): Promise<Employee> {
return apiRequest<Employee>(
"/api/v1/admin/employees",
{ method: "POST", body: JSON.stringify(input) },
workspaceId,
);
}
/** @deprecated 使用 updatePlatformEmployee 代替 */
export async function updateEmployee(
workspaceId: string,
userId: string,
input: {
display_name?: string;
email?: string | null;
role_code?: "admin" | "developer";
status?: "active" | "disabled" | "locked";
},
): Promise<Employee> {
return apiRequest<Employee>(
`/api/v1/admin/employees/${userId}`,
{ method: "PATCH", body: JSON.stringify(input) },
workspaceId,
);
}
/** @deprecated 使用 deletePlatformEmployee 代替 */
export async function deleteEmployee(
workspaceId: string,
userId: string,
): Promise<{ user_id: string; deleted: boolean }> {
return apiRequest(
`/api/v1/admin/employees/${userId}`,
{ method: "DELETE" },
workspaceId,
);
}
// ----------------------------------------------------------------------------