From c37b74a8bb4cf5ecfbc1bc01b35b73cf9e89f573 Mon Sep 17 00:00:00 2001 From: kjs Date: Wed, 1 Oct 2025 10:45:32 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20Phase=203.2=20BatchService=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20=EB=AC=B8=EC=84=9C=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=8F=20=EC=BD=94=EB=93=9C=20=ED=8F=AC=EB=A7=B7?= =?UTF-8?q?=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md 업데이트 - BatchService (14개) 완료 표시 - Phase 3 진행률 반영 - batchService.ts 코드 포맷 정리 Phase 3 진행률: 39/162 (24.1%) 전체 진행률: 290/444 (65.3%) --- PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md | 15 +++++++++--- backend-node/src/services/batchService.ts | 29 ++++++++--------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md b/PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md index 08b041fc..67dacab9 100644 --- a/PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md +++ b/PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md @@ -123,7 +123,7 @@ backend-node/ (루트) #### 🟠 **복잡 (Raw Query 혼재) - 2순위** - `multilangService.ts` (0개) - ✅ **전환 완료** (Phase 3.1) -- `batchService.ts` (16개) - 배치 작업 관리 +- `batchService.ts` (0개) - ✅ **전환 완료** (Phase 3.2) - `componentStandardService.ts` (16개) - 컴포넌트 표준 관리 - `commonCodeService.ts` (15개) - 코드 관리, 계층 구조 - `dataflowDiagramService.ts` (12개) - 다이어그램 관리 ⭐ 신규 발견 @@ -1137,8 +1137,17 @@ describe("Performance Benchmarks", () => { - [x] IN 절 동적 파라미터 바인딩 - [x] TypeScript 컴파일 성공 - [x] Prisma import 완전 제거 -- [ ] 배치 관련 서비스 전환 (40개) ⭐ 대규모 신규 발견 - - [ ] BatchService (16개), BatchExternalDbService (8개) +- [x] **BatchService 전환 (14개)** ✅ **완료** (Phase 3.2) + - [x] 14개 Prisma 호출 전환 완료 (배치 설정 CRUD) + - [x] 동적 WHERE 조건 생성 (ILIKE 검색, 페이지네이션) + - [x] 동적 UPDATE 쿼리 (변경된 필드만 업데이트) + - [x] 복잡한 트랜잭션 (배치 설정 + 매핑 동시 생성/수정/삭제) + - [x] LEFT JOIN으로 배치 매핑 조회 (json_agg, COALESCE) + - [x] transaction 함수 활용 (client.query().rows 처리) + - [x] TypeScript 컴파일 성공 + - [x] Prisma import 완전 제거 +- [ ] 배치 관련 서비스 전환 (26개) ⭐ 대규모 신규 발견 + - [ ] BatchExternalDbService (8개) - [ ] BatchExecutionLogService (7개), BatchManagementService (5개) - [ ] BatchSchedulerService (4개) - [ ] 표준 관리 서비스 전환 (41개) diff --git a/backend-node/src/services/batchService.ts b/backend-node/src/services/batchService.ts index 19ceea52..00d87d66 100644 --- a/backend-node/src/services/batchService.ts +++ b/backend-node/src/services/batchService.ts @@ -184,13 +184,7 @@ export class BatchService { (batch_name, description, cron_schedule, created_by, updated_by, created_date, updated_date) VALUES ($1, $2, $3, $4, $5, NOW(), NOW()) RETURNING *`, - [ - data.batchName, - data.description, - data.cronSchedule, - userId, - userId, - ] + [data.batchName, data.description, data.cronSchedule, userId, userId] ); const batchConfig = batchConfigResult.rows[0]; @@ -297,7 +291,10 @@ export class BatchService { // 트랜잭션으로 업데이트 const result = await transaction(async (client) => { // 동적 UPDATE 쿼리 생성 - const updateFields: string[] = ["updated_by = $1", "updated_date = NOW()"]; + const updateFields: string[] = [ + "updated_by = $1", + "updated_date = NOW()", + ]; const updateValues: any[] = [userId]; let paramIndex = 2; @@ -740,9 +737,7 @@ export class BatchService { if (connectionType === "internal") { // 내부 DB에서 데이터 조회 (주의: SQL 인젝션 위험 - 실제 프로덕션에서는 테이블명 검증 필요) - const result = await query( - `SELECT * FROM ${tableName} LIMIT 100` - ); + const result = await query(`SELECT * FROM ${tableName} LIMIT 100`); console.log( `[BatchService] 내부 DB 데이터 조회 결과: ${result.length}개 레코드` ); @@ -913,10 +908,9 @@ export class BatchService { const result = await transaction(async (client) => { // 먼저 해당 레코드가 존재하는지 확인 const checkQuery = `SELECT COUNT(*) as count FROM ${tableName} WHERE ${primaryKeyColumn} = $1`; - const existsResult = await client.query( - checkQuery, - [record[primaryKeyColumn]] - ); + const existsResult = await client.query(checkQuery, [ + record[primaryKeyColumn], + ]); const exists = parseInt(existsResult.rows[0]?.count || "0") > 0; let operationResult = "no_change"; @@ -947,10 +941,7 @@ export class BatchService { record[primaryKeyColumn], ...updateColumns.map((col) => record[col]), ]; - const updateResult = await client.query( - query, - updateValues - ); + const updateResult = await client.query(query, updateValues); if (updateResult.rowCount && updateResult.rowCount > 0) { console.log(