46 lines
977 B
TypeScript
46 lines
977 B
TypeScript
|
|
import { apiClient } from "./client";
|
||
|
|
|
||
|
|
export interface TableColumn {
|
||
|
|
name: string;
|
||
|
|
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: [],
|
||
|
|
},
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|