Raw SQL을 Prisma ORM으로 마이그레이션

This commit is contained in:
hyeonsu
2025-09-01 14:52:00 +09:00
parent bde5f0884a
commit b365969c72
4 changed files with 384 additions and 2367 deletions

View File

@@ -333,23 +333,36 @@ export class AdminService {
try {
logger.info(`AdminService.getMenuInfo 시작 - menuId: ${menuId}`);
// menu_info 모델이 @@ignore로 설정되어 있으므로 $queryRaw 사용
const menuInfo = await prisma.$queryRaw<any[]>`
SELECT
MI.*,
COALESCE(CM.COMPANY_NAME, '미지정') AS COMPANY_NAME
FROM MENU_INFO MI
LEFT JOIN COMPANY_MNG CM ON MI.COMPANY_CODE = CM.COMPANY_CODE
WHERE MI.OBJID = ${parseInt(menuId)}::numeric
LIMIT 1
`;
// Prisma ORM을 사용한 메뉴 정보 조회 (회사 정보 포함)
const menuInfo = await prisma.menu_info.findUnique({
where: {
objid: Number(menuId),
},
include: {
company: {
select: {
company_name: true,
},
},
},
});
if (!menuInfo || menuInfo.length === 0) {
if (!menuInfo) {
return null;
}
logger.info("메뉴 정보 조회 결과:", menuInfo[0]);
return menuInfo[0];
// 응답 형식 조정 (기존 형식과 호환성 유지)
const result = {
...menuInfo,
objid: menuInfo.objid.toString(), // BigInt를 문자열로 변환
menu_type: menuInfo.menu_type?.toString(),
parent_obj_id: menuInfo.parent_obj_id?.toString(),
seq: menuInfo.seq?.toString(),
company_name: menuInfo.company?.company_name || "미지정",
};
logger.info("메뉴 정보 조회 결과:", result);
return result;
} catch (error) {
logger.error("AdminService.getMenuInfo 오류:", error);
throw error;