주요기능 Prisma ORM으로 변경

This commit is contained in:
2025-09-01 11:00:38 +09:00
parent 14218bad11
commit cb88faa68e
5 changed files with 1135 additions and 1615 deletions

View File

@@ -2,7 +2,6 @@ import { Request, Response } from "express";
import { logger } from "../utils/logger";
import { AuthenticatedRequest } from "../types/auth";
import { ApiResponse } from "../types/common";
import { Client } from "pg";
import { TableManagementService } from "../services/tableManagementService";
import {
TableInfo,
@@ -23,29 +22,18 @@ export async function getTableList(
try {
logger.info("=== 테이블 목록 조회 시작 ===");
// PostgreSQL 클라이언트 생성
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
const tableManagementService = new TableManagementService();
const tableList = await tableManagementService.getTableList();
await client.connect();
logger.info(`테이블 목록 조회 결과: ${tableList.length}`);
try {
const tableManagementService = new TableManagementService(client);
const tableList = await tableManagementService.getTableList();
const response: ApiResponse<TableInfo[]> = {
success: true,
message: "테이블 목록을 성공적으로 조회했습니다.",
data: tableList,
};
logger.info(`테이블 목록 조회 결과: ${tableList.length}`);
const response: ApiResponse<TableInfo[]> = {
success: true,
message: "테이블 목록을 성공적으로 조회했습니다.",
data: tableList,
};
res.status(200).json(response);
} finally {
await client.end();
}
res.status(200).json(response);
} catch (error) {
logger.error("테이블 목록 조회 중 오류 발생:", error);
@@ -86,29 +74,18 @@ export async function getColumnList(
return;
}
// PostgreSQL 클라이언트 생성
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
const tableManagementService = new TableManagementService();
const columnList = await tableManagementService.getColumnList(tableName);
await client.connect();
logger.info(`컬럼 정보 조회 결과: ${tableName}, ${columnList.length}`);
try {
const tableManagementService = new TableManagementService(client);
const columnList = await tableManagementService.getColumnList(tableName);
const response: ApiResponse<ColumnTypeInfo[]> = {
success: true,
message: "컬럼 목록을 성공적으로 조회했습니다.",
data: columnList,
};
logger.info(`컬럼 정보 조회 결과: ${tableName}, ${columnList.length}`);
const response: ApiResponse<ColumnTypeInfo[]> = {
success: true,
message: "컬럼 목록을 성공적으로 조회했습니다.",
data: columnList,
};
res.status(200).json(response);
} finally {
await client.end();
}
res.status(200).json(response);
} catch (error) {
logger.error("컬럼 정보 조회 중 오류 발생:", error);
@@ -164,32 +141,21 @@ export async function updateColumnSettings(
return;
}
// PostgreSQL 클라이언트 생성
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
const tableManagementService = new TableManagementService();
await tableManagementService.updateColumnSettings(
tableName,
columnName,
settings
);
await client.connect();
logger.info(`컬럼 설정 업데이트 완료: ${tableName}.${columnName}`);
try {
const tableManagementService = new TableManagementService(client);
await tableManagementService.updateColumnSettings(
tableName,
columnName,
settings
);
const response: ApiResponse<null> = {
success: true,
message: "컬럼 설정을 성공적으로 저장했습니다.",
};
logger.info(`컬럼 설정 업데이트 완료: ${tableName}.${columnName}`);
const response: ApiResponse<null> = {
success: true,
message: "컬럼 설정을 성공적으로 저장했습니다.",
};
res.status(200).json(response);
} finally {
await client.end();
}
res.status(200).json(response);
} catch (error) {
logger.error("컬럼 설정 업데이트 중 오류 발생:", error);
@@ -245,33 +211,22 @@ export async function updateAllColumnSettings(
return;
}
// PostgreSQL 클라이언트 생성
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
const tableManagementService = new TableManagementService();
await tableManagementService.updateAllColumnSettings(
tableName,
columnSettings
);
await client.connect();
logger.info(
`전체 컬럼 설정 일괄 업데이트 완료: ${tableName}, ${columnSettings.length}`
);
try {
const tableManagementService = new TableManagementService(client);
await tableManagementService.updateAllColumnSettings(
tableName,
columnSettings
);
const response: ApiResponse<null> = {
success: true,
message: "모든 컬럼 설정을 성공적으로 저장했습니다.",
};
logger.info(
`전체 컬럼 설정 일괄 업데이트 완료: ${tableName}, ${columnSettings.length}`
);
const response: ApiResponse<null> = {
success: true,
message: "모든 컬럼 설정을 성공적으로 저장했습니다.",
};
res.status(200).json(response);
} finally {
await client.end();
}
res.status(200).json(response);
} catch (error) {
logger.error("전체 컬럼 설정 일괄 업데이트 중 오류 발생:", error);
@@ -312,43 +267,31 @@ export async function getTableLabels(
return;
}
// PostgreSQL 클라이언트 생성
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
const tableManagementService = new TableManagementService();
const tableLabels = await tableManagementService.getTableLabels(tableName);
await client.connect();
try {
const tableManagementService = new TableManagementService(client);
const tableLabels =
await tableManagementService.getTableLabels(tableName);
if (!tableLabels) {
const response: ApiResponse<null> = {
success: false,
message: "테이블 라벨 정보를 찾을 수 없습니다.",
error: {
code: "TABLE_LABELS_NOT_FOUND",
details: `테이블 ${tableName}의 라벨 정보가 존재하지 않습니다.`,
},
};
res.status(404).json(response);
return;
}
logger.info(`테이블 라벨 정보 조회 완료: ${tableName}`);
const response: ApiResponse<any> = {
success: true,
message: "테이블 라벨 정보를 성공적으로 조회했습니다.",
data: tableLabels,
if (!tableLabels) {
const response: ApiResponse<null> = {
success: false,
message: "테이블 라벨 정보를 찾을 수 없습니다.",
error: {
code: "TABLE_LABELS_NOT_FOUND",
details: `테이블 ${tableName}의 라벨 정보가 존재하지 않습니다.`,
},
};
res.status(200).json(response);
} finally {
await client.end();
res.status(404).json(response);
return;
}
logger.info(`테이블 라벨 정보 조회 완료: ${tableName}`);
const response: ApiResponse<any> = {
success: true,
message: "테이블 라벨 정보를 성공적으로 조회했습니다.",
data: tableLabels,
};
res.status(200).json(response);
} catch (error) {
logger.error("테이블 라벨 정보 조회 중 오류 발생:", error);
@@ -389,45 +332,34 @@ export async function getColumnLabels(
return;
}
// PostgreSQL 클라이언트 생성
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
const tableManagementService = new TableManagementService();
const columnLabels = await tableManagementService.getColumnLabels(
tableName,
columnName
);
await client.connect();
try {
const tableManagementService = new TableManagementService(client);
const columnLabels = await tableManagementService.getColumnLabels(
tableName,
columnName
);
if (!columnLabels) {
const response: ApiResponse<null> = {
success: false,
message: "컬럼 라벨 정보를 찾을 수 없습니다.",
error: {
code: "COLUMN_LABELS_NOT_FOUND",
details: `컬럼 ${tableName}.${columnName}의 라벨 정보가 존재하지 않습니다.`,
},
};
res.status(404).json(response);
return;
}
logger.info(`컬럼 라벨 정보 조회 완료: ${tableName}.${columnName}`);
const response: ApiResponse<any> = {
success: true,
message: "컬럼 라벨 정보를 성공적으로 조회했습니다.",
data: columnLabels,
if (!columnLabels) {
const response: ApiResponse<null> = {
success: false,
message: "컬럼 라벨 정보를 찾을 수 없습니다.",
error: {
code: "COLUMN_LABELS_NOT_FOUND",
details: `컬럼 ${tableName}.${columnName}의 라벨 정보가 존재하지 않습니다.`,
},
};
res.status(200).json(response);
} finally {
await client.end();
res.status(404).json(response);
return;
}
logger.info(`컬럼 라벨 정보 조회 완료: ${tableName}.${columnName}`);
const response: ApiResponse<any> = {
success: true,
message: "컬럼 라벨 정보를 성공적으로 조회했습니다.",
data: columnLabels,
};
res.status(200).json(response);
} catch (error) {
logger.error("컬럼 라벨 정보 조회 중 오류 발생:", error);