ERP-node/frontend/lib/api/tableSchema.ts

47 lines
1.0 KiB
TypeScript

import { apiClient } from "./client";
export interface TableColumn {
name: string;
label: string; // 컬럼 라벨 (column_labels 테이블에서 가져옴)
type: string;
nullable: boolean;
default: string | null;
maxLength: number | null;
precision: number | null;
scale: number | null;
}
export interface TableSchemaResponse {
success: boolean;
message: string;
data: {
tableName: string;
columns: TableColumn[];
};
}
/**
* 테이블 스키마 조회 (엑셀 업로드 컬럼 매핑용)
*/
export async function getTableSchema(
tableName: string
): Promise<TableSchemaResponse> {
try {
const response = await apiClient.get<TableSchemaResponse>(
`/admin/tables/${tableName}/schema`
);
return response.data;
} catch (error: any) {
console.error("테이블 스키마 조회 실패:", error);
return {
success: false,
message: error.response?.data?.message || "테이블 스키마 조회 실패",
data: {
tableName,
columns: [],
},
};
}
}