文件
hyb-oa/client/src/api/cutover.ts
T
wangsli 9905c1c79d feat(P25-2/P25-3/P26-2/P28-1/P24-2/P29-3): 落地内部OA够用版前端入口与运营页面
关联 Issue: P25-2, P25-3, P25-4, P26-2, P26-4, P28-1, P28-2, P28-3, P28-4, P24-2, P29-3
2026-03-21 18:03:48 +08:00

73 行
2.0 KiB
TypeScript

import { apiRequestData } from "./http";
export type MigrationRun = {
id: string;
runType: "employees" | "departments" | "budgets" | "masterdata_validation";
status: string;
sourceFilename: string;
summaryJson: Record<string, unknown> | null;
errorJson: Record<string, unknown> | null;
createdAt: string | null;
createdBy: string | null;
};
export type CutoverScope = {
id: string;
scopeType: "department" | "legal_entity" | "domain";
scopeKey: string;
enabled: boolean;
startsAt: string | null;
notes: string | null;
createdAt: string | null;
updatedAt: string | null;
updatedBy: string | null;
};
export async function fetchMigrationRuns() {
return apiRequestData<{ items: MigrationRun[] }>("/api/migration-runs");
}
export async function fetchMigrationRun(id: string) {
return apiRequestData<{ item: MigrationRun }>(`/api/migration-runs/${id}`);
}
export async function dryRunMigration(payload: { runType: MigrationRun["runType"]; file: File }) {
const formData = new FormData();
formData.append("runType", payload.runType);
formData.append("file", payload.file);
return apiRequestData<{ item: MigrationRun }>("/api/migration-runs/dry-run", {
method: "POST",
body: formData,
});
}
export async function fetchCutoverScopes() {
return apiRequestData<{ items: CutoverScope[] }>("/api/cutover/scopes");
}
export async function createCutoverScope(payload: {
scopeType: CutoverScope["scopeType"];
scopeKey: string;
enabled?: boolean;
startsAt?: string | null;
notes?: string | null;
}) {
return apiRequestData<{ item: CutoverScope }>("/api/cutover/scopes", {
method: "POST",
body: JSON.stringify(payload),
});
}
export async function updateCutoverScope(id: string, payload: Partial<{
scopeType: CutoverScope["scopeType"];
scopeKey: string;
enabled: boolean;
startsAt: string | null;
notes: string | null;
}>) {
return apiRequestData<{ item: CutoverScope }>(`/api/cutover/scopes/${id}`, {
method: "PATCH",
body: JSON.stringify(payload),
});
}