배치관리시스템 (DB, RestAPI)
This commit is contained in:
@@ -31,8 +31,8 @@ export interface BatchApiResponse<T = unknown> {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export const BatchManagementAPI = {
|
||||
BASE_PATH: "/api/batch-management",
|
||||
class BatchManagementAPIClass {
|
||||
private static readonly BASE_PATH = "/batch-management";
|
||||
|
||||
/**
|
||||
* 사용 가능한 커넥션 목록 조회
|
||||
@@ -52,7 +52,7 @@ export const BatchManagementAPI = {
|
||||
console.error("커넥션 목록 조회 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 커넥션의 테이블 목록 조회
|
||||
@@ -68,20 +68,18 @@ export const BatchManagementAPI = {
|
||||
}
|
||||
url += '/tables';
|
||||
|
||||
const response = await apiClient.get<BatchApiResponse<BatchTableInfo[]>>(url);
|
||||
const response = await apiClient.get<BatchApiResponse<string[]>>(url);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "테이블 목록 조회에 실패했습니다.");
|
||||
}
|
||||
|
||||
// BatchTableInfo[]에서 table_name만 추출하여 string[]로 변환
|
||||
const tables = response.data.data || [];
|
||||
return tables.map(table => table.table_name);
|
||||
return response.data.data || [];
|
||||
} catch (error) {
|
||||
console.error("테이블 목록 조회 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 테이블의 컬럼 정보 조회
|
||||
@@ -96,19 +94,85 @@ export const BatchManagementAPI = {
|
||||
if (connectionType === 'external' && connectionId) {
|
||||
url += `/${connectionId}`;
|
||||
}
|
||||
url += `/tables/${tableName}/columns`;
|
||||
url += `/tables/${encodeURIComponent(tableName)}/columns`;
|
||||
|
||||
console.log("🔍 컬럼 조회 API 호출:", { url, connectionType, connectionId, tableName });
|
||||
|
||||
const response = await apiClient.get<BatchApiResponse<BatchColumnInfo[]>>(url);
|
||||
|
||||
console.log("🔍 컬럼 조회 API 응답:", response.data);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "컬럼 정보 조회에 실패했습니다.");
|
||||
}
|
||||
|
||||
return response.data.data || [];
|
||||
} catch (error) {
|
||||
console.error("컬럼 정보 조회 오류:", error);
|
||||
console.error("❌ 컬럼 정보 조회 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* REST API 데이터 미리보기
|
||||
*/
|
||||
static async previewRestApiData(
|
||||
apiUrl: string,
|
||||
apiKey: string,
|
||||
endpoint: string,
|
||||
method: 'GET' = 'GET'
|
||||
): Promise<{
|
||||
fields: string[];
|
||||
samples: any[];
|
||||
totalCount: number;
|
||||
}> {
|
||||
try {
|
||||
const response = await apiClient.post<BatchApiResponse<{
|
||||
fields: string[];
|
||||
samples: any[];
|
||||
totalCount: number;
|
||||
}>>(`${this.BASE_PATH}/rest-api/preview`, {
|
||||
apiUrl,
|
||||
apiKey,
|
||||
endpoint,
|
||||
method
|
||||
});
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "REST API 미리보기에 실패했습니다.");
|
||||
}
|
||||
|
||||
return response.data.data || { fields: [], samples: [], totalCount: 0 };
|
||||
} catch (error) {
|
||||
console.error("REST API 미리보기 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* REST API 배치 저장
|
||||
*/
|
||||
static async saveRestApiBatch(batchData: {
|
||||
batchName: string;
|
||||
batchType: string;
|
||||
cronSchedule: string;
|
||||
description?: string;
|
||||
apiMappings: any[];
|
||||
}): Promise<{ success: boolean; message: string; data?: any; }> {
|
||||
try {
|
||||
const response = await apiClient.post<BatchApiResponse<any>>(
|
||||
`${this.BASE_PATH}/rest-api/save`, batchData
|
||||
);
|
||||
return {
|
||||
success: response.data.success,
|
||||
message: response.data.message || "",
|
||||
data: response.data.data
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("REST API 배치 저장 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const BatchManagementAPI = BatchManagementAPIClass;
|
||||
Reference in New Issue
Block a user