import { http } from '@/api/http' export interface Org { id: string tenantCode: string parentCode: string | null code: string name: string leader: string | null sort: number status: 'enabled' | 'disabled' createdAt: number } /** 组织列表(后端按 sort 升序返回普通数组,前端自行组树)。 */ export function listOrgs(signal?: AbortSignal): Promise { return http.get('/orgs', { signal }) } export function createOrg(data: { code: string name: string parentCode?: string | null leader?: string sort?: number }): Promise { return http.post('/orgs', data) } export function updateOrg( id: string, data: { name?: string; parentCode?: string | null; leader?: string; sort?: number; status?: string }, ): Promise { return http.patch(`/orgs/${id}`, data) } export function deleteOrg(id: string): Promise { return http.delete(`/orgs/${id}`) } /** 批量删除组织。 */ export function batchDeleteOrgs(ids: string[]): Promise<{ total: number; success: number; failed: string[] }> { return http.post('/orgs/batch-delete', { ids }) }