forked from wangziqi/gongxue-base
feat: add tenant import console
This commit is contained in:
@@ -122,6 +122,47 @@ export interface ImportTemplateItem {
|
||||
fields?: Record<string, unknown>[];
|
||||
}
|
||||
|
||||
export interface ImportPreviewResult {
|
||||
job?: {
|
||||
id: string;
|
||||
status?: string;
|
||||
totalCount?: number;
|
||||
validCount?: number;
|
||||
errorCount?: number;
|
||||
warningCount?: number;
|
||||
};
|
||||
items?: Array<{
|
||||
rowNo?: number;
|
||||
status?: string;
|
||||
externalId?: string | null;
|
||||
normalized?: Record<string, unknown> | null;
|
||||
issues?: ImportIssueItem[];
|
||||
}>;
|
||||
issues?: ImportIssueItem[];
|
||||
}
|
||||
|
||||
export type ImportType = 'questions' | 'vocabulary' | 'handbook' | 'scoreline' | 'videos';
|
||||
export type ImportSourceFormat = 'json' | 'csv' | 'excel';
|
||||
|
||||
export interface ImportRequestBody {
|
||||
sourceFormat?: ImportSourceFormat;
|
||||
sourceName?: string;
|
||||
payload?: unknown;
|
||||
items?: unknown[];
|
||||
csvText?: string;
|
||||
fileBase64?: string;
|
||||
allowPartial?: boolean;
|
||||
executionMode?: 'sync' | 'async';
|
||||
previewJobId?: string;
|
||||
jobId?: string;
|
||||
regionId?: string;
|
||||
entryId?: string;
|
||||
contentNodeId?: string;
|
||||
collectionId?: string;
|
||||
fieldMappingOverrides?: Record<string, string[]>;
|
||||
fieldMappingPreset?: ImportFieldMapping | null;
|
||||
}
|
||||
|
||||
export interface CouponItem {
|
||||
id: string;
|
||||
code: string;
|
||||
@@ -239,6 +280,20 @@ export async function loadImportTemplate(importType: string, format: 'json' | 'c
|
||||
});
|
||||
}
|
||||
|
||||
export async function previewContentImport(importType: ImportType, body: ImportRequestBody) {
|
||||
return apiRequest<ImportPreviewResult>(`/api/tenant-content/imports/preview/${importType}`, {
|
||||
method: 'POST',
|
||||
body,
|
||||
});
|
||||
}
|
||||
|
||||
export async function executeContentImport(importType: ImportType, body: ImportRequestBody) {
|
||||
return apiRequest<{ item?: Record<string, unknown>; preview?: ImportPreviewResult }>(`/api/tenant-content/imports/${importType}`, {
|
||||
method: 'POST',
|
||||
body,
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadCoupons() {
|
||||
return apiRequest<{ items?: CouponItem[] }>('/api/tenant-admin/coupons');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user