엑셀 업로드 분할테이블 지원
This commit is contained in:
@@ -556,6 +556,130 @@ export class DynamicFormApi {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ================================
|
||||
// 마스터-디테일 엑셀 API
|
||||
// ================================
|
||||
|
||||
/**
|
||||
* 마스터-디테일 관계 정보 조회
|
||||
* @param screenId 화면 ID
|
||||
* @returns 마스터-디테일 관계 정보 (null이면 마스터-디테일 구조 아님)
|
||||
*/
|
||||
static async getMasterDetailRelation(screenId: number): Promise<ApiResponse<MasterDetailRelation | null>> {
|
||||
try {
|
||||
console.log("🔍 마스터-디테일 관계 조회:", screenId);
|
||||
|
||||
const response = await apiClient.get(`/data/master-detail/relation/${screenId}`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response.data?.data || null,
|
||||
message: response.data?.message || "조회 완료",
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.error("❌ 마스터-디테일 관계 조회 실패:", error);
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
message: error.response?.data?.message || error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 마스터-디테일 엑셀 다운로드 데이터 조회
|
||||
* @param screenId 화면 ID
|
||||
* @param filters 필터 조건
|
||||
* @returns JOIN된 플랫 데이터
|
||||
*/
|
||||
static async getMasterDetailDownloadData(
|
||||
screenId: number,
|
||||
filters?: Record<string, any>
|
||||
): Promise<ApiResponse<MasterDetailDownloadData>> {
|
||||
try {
|
||||
console.log("📥 마스터-디테일 다운로드 데이터 조회:", { screenId, filters });
|
||||
|
||||
const response = await apiClient.post(`/data/master-detail/download`, {
|
||||
screenId,
|
||||
filters,
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response.data?.data,
|
||||
message: "데이터 조회 완료",
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.error("❌ 마스터-디테일 다운로드 실패:", error);
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 마스터-디테일 엑셀 업로드
|
||||
* @param screenId 화면 ID
|
||||
* @param data 엑셀에서 읽은 플랫 데이터
|
||||
* @returns 업로드 결과
|
||||
*/
|
||||
static async uploadMasterDetailData(
|
||||
screenId: number,
|
||||
data: Record<string, any>[]
|
||||
): Promise<ApiResponse<MasterDetailUploadResult>> {
|
||||
try {
|
||||
console.log("📤 마스터-디테일 업로드:", { screenId, rowCount: data.length });
|
||||
|
||||
const response = await apiClient.post(`/data/master-detail/upload`, {
|
||||
screenId,
|
||||
data,
|
||||
});
|
||||
|
||||
return {
|
||||
success: response.data?.success,
|
||||
data: response.data?.data,
|
||||
message: response.data?.message,
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.error("❌ 마스터-디테일 업로드 실패:", error);
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 마스터-디테일 관계 타입
|
||||
export interface MasterDetailRelation {
|
||||
masterTable: string;
|
||||
detailTable: string;
|
||||
masterKeyColumn: string;
|
||||
detailFkColumn: string;
|
||||
masterColumns: Array<{ name: string; label: string; inputType: string; isFromMaster: boolean }>;
|
||||
detailColumns: Array<{ name: string; label: string; inputType: string; isFromMaster: boolean }>;
|
||||
}
|
||||
|
||||
// 마스터-디테일 다운로드 데이터 타입
|
||||
export interface MasterDetailDownloadData {
|
||||
headers: string[];
|
||||
columns: string[];
|
||||
data: Record<string, any>[];
|
||||
masterColumns: string[];
|
||||
detailColumns: string[];
|
||||
joinKey: string;
|
||||
}
|
||||
|
||||
// 마스터-디테일 업로드 결과 타입
|
||||
export interface MasterDetailUploadResult {
|
||||
success: boolean;
|
||||
masterInserted: number;
|
||||
masterUpdated: number;
|
||||
detailInserted: number;
|
||||
detailDeleted: number;
|
||||
errors: string[];
|
||||
}
|
||||
|
||||
// 편의를 위한 기본 export
|
||||
|
||||
Reference in New Issue
Block a user