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

47 lines
1.0 KiB
TypeScript
Raw Normal View History

import { apiClient } from "./client";
export interface TableColumn {
name: string;
2025-12-17 12:01:16 +09:00
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: [],
},
};
}
}