docs: Phase 4 남은 Prisma 호출 전환 계획서 작성

현재 상황 분석 및 문서화:

컨트롤러 레이어:
-  adminController.ts (28개) 완료
-  screenFileController.ts (2개) 완료
- 🔄 남은 파일 (12개 호출):
  * webTypeStandardController.ts (11개)
  * fileController.ts (1개)

Routes & Services:
- ddlRoutes.ts (2개)
- companyManagementRoutes.ts (2개)
- multiConnectionQueryService.ts (4개)

Config:
- database.ts (4개 - 제거 예정)

새로운 계획서:
- PHASE4_REMAINING_PRISMA_CALLS.md (상세 전환 계획)
- 파일별 Prisma 호출 상세 분석
- 전환 패턴 및 우선순위 정리

전체 진행률: 445/444 (100.2%)
남은 작업: 12개 (추가 조사 필요한 파일 제외)
This commit is contained in:
kjs
2025-10-01 14:33:08 +09:00
parent 381d19caee
commit 7919079362
23 changed files with 2304 additions and 1295 deletions

View File

@@ -7,7 +7,7 @@ import {
CreateBatchExecutionLogRequest,
UpdateBatchExecutionLogRequest,
BatchExecutionLogFilter,
BatchExecutionLogWithConfig
BatchExecutionLogWithConfig,
} from "../types/batchExecutionLogTypes";
import { ApiResponse } from "../types/batchTypes";
@@ -25,7 +25,7 @@ export class BatchExecutionLogService {
start_date,
end_date,
page = 1,
limit = 50
limit = 50,
} = filter;
const skip = (page - 1) * limit;
@@ -35,28 +35,31 @@ export class BatchExecutionLogService {
const whereConditions: string[] = [];
const params: any[] = [];
let paramIndex = 1;
if (batch_config_id) {
whereConditions.push(`bel.batch_config_id = $${paramIndex++}`);
params.push(batch_config_id);
}
if (execution_status) {
whereConditions.push(`bel.execution_status = $${paramIndex++}`);
params.push(execution_status);
}
if (start_date) {
whereConditions.push(`bel.start_time >= $${paramIndex++}`);
params.push(start_date);
}
if (end_date) {
whereConditions.push(`bel.start_time <= $${paramIndex++}`);
params.push(end_date);
}
const whereClause = whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : '';
const whereClause =
whereConditions.length > 0
? `WHERE ${whereConditions.join(" AND ")}`
: "";
// 로그 조회 (batch_config 정보 포함)
const sql = `
@@ -75,7 +78,7 @@ export class BatchExecutionLogService {
ORDER BY bel.start_time DESC
LIMIT $${paramIndex} OFFSET $${paramIndex + 1}
`;
const countSql = `
SELECT COUNT(*) as count
FROM batch_execution_logs bel
@@ -86,10 +89,10 @@ export class BatchExecutionLogService {
const [logs, countResult] = await Promise.all([
query<any>(sql, params),
query<{ count: number }>(countSql, params.slice(0, -2))
query<{ count: number }>(countSql, params.slice(0, -2)),
]);
const total = parseInt(countResult[0]?.count?.toString() || '0', 10);
const total = parseInt(countResult[0]?.count?.toString() || "0", 10);
return {
success: true,
@@ -98,15 +101,15 @@ export class BatchExecutionLogService {
page,
limit,
total,
totalPages: Math.ceil(total / limit)
}
totalPages: Math.ceil(total / limit),
},
};
} catch (error) {
console.error("배치 실행 로그 조회 실패:", error);
return {
success: false,
message: "배치 실행 로그 조회 중 오류가 발생했습니다.",
error: error instanceof Error ? error.message : "알 수 없는 오류"
error: error instanceof Error ? error.message : "알 수 없는 오류",
};
}
}
@@ -136,22 +139,22 @@ export class BatchExecutionLogService {
data.failed_records || 0,
data.error_message,
data.error_details,
data.server_name || process.env.HOSTNAME || 'unknown',
data.process_id || process.pid?.toString()
data.server_name || process.env.HOSTNAME || "unknown",
data.process_id || process.pid?.toString(),
]
);
return {
success: true,
data: log as BatchExecutionLog,
message: "배치 실행 로그가 생성되었습니다."
message: "배치 실행 로그가 생성되었습니다.",
};
} catch (error) {
console.error("배치 실행 로그 생성 실패:", error);
return {
success: false,
message: "배치 실행 로그 생성 중 오류가 발생했습니다.",
error: error instanceof Error ? error.message : "알 수 없는 오류"
error: error instanceof Error ? error.message : "알 수 없는 오류",
};
}
}
@@ -206,7 +209,7 @@ export class BatchExecutionLogService {
const log = await queryOne<BatchExecutionLog>(
`UPDATE batch_execution_logs
SET ${updates.join(', ')}
SET ${updates.join(", ")}
WHERE id = $${paramIndex}
RETURNING *`,
params
@@ -215,14 +218,14 @@ export class BatchExecutionLogService {
return {
success: true,
data: log as BatchExecutionLog,
message: "배치 실행 로그가 업데이트되었습니다."
message: "배치 실행 로그가 업데이트되었습니다.",
};
} catch (error) {
console.error("배치 실행 로그 업데이트 실패:", error);
return {
success: false,
message: "배치 실행 로그 업데이트 중 오류가 발생했습니다.",
error: error instanceof Error ? error.message : "알 수 없는 오류"
error: error instanceof Error ? error.message : "알 수 없는 오류",
};
}
}
@@ -236,14 +239,14 @@ export class BatchExecutionLogService {
return {
success: true,
message: "배치 실행 로그가 삭제되었습니다."
message: "배치 실행 로그가 삭제되었습니다.",
};
} catch (error) {
console.error("배치 실행 로그 삭제 실패:", error);
return {
success: false,
message: "배치 실행 로그 삭제 중 오류가 발생했습니다.",
error: error instanceof Error ? error.message : "알 수 없는 오류"
error: error instanceof Error ? error.message : "알 수 없는 오류",
};
}
}
@@ -265,14 +268,14 @@ export class BatchExecutionLogService {
return {
success: true,
data: log || null
data: log || null,
};
} catch (error) {
console.error("최신 배치 실행 로그 조회 실패:", error);
return {
success: false,
message: "최신 배치 실행 로그 조회 중 오류가 발생했습니다.",
error: error instanceof Error ? error.message : "알 수 없는 오류"
error: error instanceof Error ? error.message : "알 수 없는 오류",
};
}
}
@@ -284,35 +287,40 @@ export class BatchExecutionLogService {
batchConfigId?: number,
startDate?: Date,
endDate?: Date
): Promise<ApiResponse<{
total_executions: number;
success_count: number;
failed_count: number;
success_rate: number;
average_duration_ms: number;
total_records_processed: number;
}>> {
): Promise<
ApiResponse<{
total_executions: number;
success_count: number;
failed_count: number;
success_rate: number;
average_duration_ms: number;
total_records_processed: number;
}>
> {
try {
const whereConditions: string[] = [];
const params: any[] = [];
let paramIndex = 1;
if (batchConfigId) {
whereConditions.push(`batch_config_id = $${paramIndex++}`);
params.push(batchConfigId);
}
if (startDate) {
whereConditions.push(`start_time >= $${paramIndex++}`);
params.push(startDate);
}
if (endDate) {
whereConditions.push(`start_time <= $${paramIndex++}`);
params.push(endDate);
}
const whereClause = whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : '';
const whereClause =
whereConditions.length > 0
? `WHERE ${whereConditions.join(" AND ")}`
: "";
const logs = await query<{
execution_status: string;
@@ -326,17 +334,26 @@ export class BatchExecutionLogService {
);
const total_executions = logs.length;
const success_count = logs.filter((log: any) => log.execution_status === 'SUCCESS').length;
const failed_count = logs.filter((log: any) => log.execution_status === 'FAILED').length;
const success_rate = total_executions > 0 ? (success_count / total_executions) * 100 : 0;
const success_count = logs.filter(
(log: any) => log.execution_status === "SUCCESS"
).length;
const failed_count = logs.filter(
(log: any) => log.execution_status === "FAILED"
).length;
const success_rate =
total_executions > 0 ? (success_count / total_executions) * 100 : 0;
const validDurations = logs
.filter((log: any) => log.duration_ms !== null)
.map((log: any) => log.duration_ms!);
const average_duration_ms = validDurations.length > 0
? validDurations.reduce((sum: number, duration: number) => sum + duration, 0) / validDurations.length
: 0;
const average_duration_ms =
validDurations.length > 0
? validDurations.reduce(
(sum: number, duration: number) => sum + duration,
0
) / validDurations.length
: 0;
const total_records_processed = logs
.filter((log: any) => log.total_records !== null)
.reduce((sum: number, log: any) => sum + (log.total_records || 0), 0);
@@ -349,15 +366,15 @@ export class BatchExecutionLogService {
failed_count,
success_rate,
average_duration_ms,
total_records_processed
}
total_records_processed,
},
};
} catch (error) {
console.error("배치 실행 통계 조회 실패:", error);
return {
success: false,
message: "배치 실행 통계 조회 중 오류가 발생했습니다.",
error: error instanceof Error ? error.message : "알 수 없는 오류"
error: error instanceof Error ? error.message : "알 수 없는 오류",
};
}
}