격자에 맞게 컴포넌트 배치
This commit is contained in:
@@ -108,7 +108,7 @@ export const deleteScreen = async (
|
||||
}
|
||||
};
|
||||
|
||||
// 테이블 목록 조회
|
||||
// 테이블 목록 조회 (모든 테이블)
|
||||
export const getTables = async (req: AuthenticatedRequest, res: Response) => {
|
||||
try {
|
||||
const { companyCode } = req.user as any;
|
||||
@@ -122,6 +122,46 @@ export const getTables = async (req: AuthenticatedRequest, res: Response) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 특정 테이블 정보 조회 (최적화된 단일 테이블 조회)
|
||||
export const getTableInfo = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { tableName } = req.params;
|
||||
const { companyCode } = req.user as any;
|
||||
|
||||
if (!tableName) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
message: "테이블명이 필요합니다.",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`=== 테이블 정보 조회 API 호출: ${tableName} ===`);
|
||||
const tableInfo = await screenManagementService.getTableInfo(
|
||||
tableName,
|
||||
companyCode
|
||||
);
|
||||
|
||||
if (!tableInfo) {
|
||||
res.status(404).json({
|
||||
success: false,
|
||||
message: `테이블 '${tableName}'을 찾을 수 없습니다.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
res.json({ success: true, data: tableInfo });
|
||||
} catch (error) {
|
||||
console.error("테이블 정보 조회 실패:", error);
|
||||
res
|
||||
.status(500)
|
||||
.json({ success: false, message: "테이블 정보 조회에 실패했습니다." });
|
||||
}
|
||||
};
|
||||
|
||||
// 테이블 컬럼 정보 조회
|
||||
export const getTableColumns = async (
|
||||
req: AuthenticatedRequest,
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
updateScreen,
|
||||
deleteScreen,
|
||||
getTables,
|
||||
getTableInfo,
|
||||
getTableColumns,
|
||||
saveLayout,
|
||||
getLayout,
|
||||
@@ -33,6 +34,7 @@ router.get("/generate-screen-code/:companyCode", generateScreenCode);
|
||||
|
||||
// 테이블 관리
|
||||
router.get("/tables", getTables);
|
||||
router.get("/tables/:tableName", getTableInfo); // 특정 테이블 정보 조회 (최적화)
|
||||
router.get("/tables/:tableName/columns", getTableColumns);
|
||||
|
||||
// 레이아웃 관리
|
||||
|
||||
@@ -205,7 +205,7 @@ export class ScreenManagementService {
|
||||
// ========================================
|
||||
|
||||
/**
|
||||
* 테이블 목록 조회
|
||||
* 테이블 목록 조회 (모든 테이블)
|
||||
*/
|
||||
async getTables(companyCode: string): Promise<TableInfo[]> {
|
||||
try {
|
||||
@@ -242,6 +242,54 @@ export class ScreenManagementService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 테이블 정보 조회 (최적화된 단일 테이블 조회)
|
||||
*/
|
||||
async getTableInfo(
|
||||
tableName: string,
|
||||
companyCode: string
|
||||
): Promise<TableInfo | null> {
|
||||
try {
|
||||
console.log(`=== 단일 테이블 조회 시작: ${tableName} ===`);
|
||||
|
||||
// 테이블 존재 여부 확인
|
||||
const tableExists = await prisma.$queryRaw<Array<{ table_name: string }>>`
|
||||
SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public'
|
||||
AND table_type = 'BASE TABLE'
|
||||
AND table_name = ${tableName}
|
||||
`;
|
||||
|
||||
if (tableExists.length === 0) {
|
||||
console.log(`테이블 ${tableName}이 존재하지 않습니다.`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 해당 테이블의 컬럼 정보 조회
|
||||
const columns = await this.getTableColumns(tableName, companyCode);
|
||||
|
||||
if (columns.length === 0) {
|
||||
console.log(`테이블 ${tableName}의 컬럼 정보가 없습니다.`);
|
||||
return null;
|
||||
}
|
||||
|
||||
const tableInfo: TableInfo = {
|
||||
tableName: tableName,
|
||||
tableLabel: this.getTableLabel(tableName),
|
||||
columns: columns,
|
||||
};
|
||||
|
||||
console.log(
|
||||
`단일 테이블 조회 완료: ${tableName}, 컬럼 ${columns.length}개`
|
||||
);
|
||||
return tableInfo;
|
||||
} catch (error) {
|
||||
console.error(`테이블 ${tableName} 조회 실패:`, error);
|
||||
throw new Error(`테이블 ${tableName} 정보를 조회할 수 없습니다.`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 테이블 컬럼 정보 조회
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user