From 34295d6afa4f043d0f1349d5438a18c22b15c65b Mon Sep 17 00:00:00 2001 From: kjs Date: Wed, 1 Oct 2025 10:58:11 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20Phase=203.4=20CommonCodeService=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20=EB=AC=B8=EC=84=9C=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EB=B0=8F=20=EC=BD=94=EB=93=9C=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=B7=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 업데이트 - CommonCodeService (10개) 완료 표시 - Phase 3 진행률 반영 - commonCodeService.ts 코드 포맷 정리 Phase 3 진행률: 64/162 (39.5%) 전체 진행률: 315/444 (70.9%) --- PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md | 14 +++++++++++--- .../src/services/commonCodeService.ts | 19 +++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md b/PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md index 3994cd4e..4d616005 100644 --- a/PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md +++ b/PRISMA_TO_RAW_QUERY_MIGRATION_PLAN.md @@ -125,7 +125,7 @@ backend-node/ (루트) - `multilangService.ts` (0개) - ✅ **전환 완료** (Phase 3.1) - `batchService.ts` (0개) - ✅ **전환 완료** (Phase 3.2) - `componentStandardService.ts` (0개) - ✅ **전환 완료** (Phase 3.3) -- `commonCodeService.ts` (15개) - 코드 관리, 계층 구조 +- `commonCodeService.ts` (0개) - ✅ **전환 완료** (Phase 3.4) - `dataflowDiagramService.ts` (12개) - 다이어그램 관리 ⭐ 신규 발견 - `collectionService.ts` (11개) - 컬렉션 관리 - `layoutService.ts` (10개) - 레이아웃 관리 @@ -1156,12 +1156,20 @@ describe("Performance Benchmarks", () => { - [x] SQL 인젝션 방지 (정렬 컬럼 검증) - [x] TypeScript 컴파일 성공 - [x] Prisma import 완전 제거 +- [x] **CommonCodeService 전환 (10개)** ✅ **완료** (Phase 3.4) + - [x] 10개 Prisma 호출 전환 완료 (코드 카테고리 및 코드 CRUD) + - [x] 동적 WHERE 조건 생성 (ILIKE 검색, OR 조건) + - [x] 동적 UPDATE 쿼리 (변경된 필드만 업데이트) + - [x] IN 절 동적 파라미터 바인딩 (reorderCodes) + - [x] 트랜잭션 처리 (순서 변경) + - [x] 동적 SQL 쿼리 생성 (중복 검사) + - [x] TypeScript 컴파일 성공 + - [x] Prisma import 완전 제거 - [ ] 배치 관련 서비스 전환 (26개) ⭐ 대규모 신규 발견 - [ ] BatchExternalDbService (8개) - [ ] BatchExecutionLogService (7개), BatchManagementService (5개) - [ ] BatchSchedulerService (4개) -- [ ] 표준 관리 서비스 전환 (25개) - - [ ] CommonCodeService (15개) +- [ ] 표준 관리 서비스 전환 (10개) - [ ] LayoutService (10개) - [ ] 데이터플로우 관련 서비스 (18개) ⭐ 신규 발견 - [ ] DataflowDiagramService (12개), DataflowControlService (6개) diff --git a/backend-node/src/services/commonCodeService.ts b/backend-node/src/services/commonCodeService.ts index f37310ae..69c8cba1 100644 --- a/backend-node/src/services/commonCodeService.ts +++ b/backend-node/src/services/commonCodeService.ts @@ -220,9 +220,12 @@ export class CommonCodeService { try { // 디버깅: 받은 데이터 로그 logger.info(`카테고리 수정 데이터:`, { categoryCode, data }); - + // 동적 UPDATE 쿼리 생성 - const updateFields: string[] = ["updated_by = $1", "updated_date = NOW()"]; + const updateFields: string[] = [ + "updated_by = $1", + "updated_date = NOW()", + ]; const values: any[] = [updatedBy]; let paramIndex = 2; @@ -335,9 +338,12 @@ export class CommonCodeService { try { // 디버깅: 받은 데이터 로그 logger.info(`코드 수정 데이터:`, { categoryCode, codeValue, data }); - + // 동적 UPDATE 쿼리 생성 - const updateFields: string[] = ["updated_by = $1", "updated_date = NOW()"]; + const updateFields: string[] = [ + "updated_by = $1", + "updated_date = NOW()", + ]; const values: any[] = [updatedBy]; let paramIndex = 2; @@ -445,7 +451,7 @@ export class CommonCodeService { // 먼저 존재하는 코드들을 확인 const codeValues = codes.map((c) => c.codeValue); const placeholders = codeValues.map((_, i) => `$${i + 2}`).join(", "); - + const existingCodes = await query<{ code_value: string }>( `SELECT code_value FROM code_info WHERE code_category = $1 AND code_value IN (${placeholders})`, @@ -613,7 +619,8 @@ export class CommonCodeService { } // SQL 쿼리 생성 - let sql = "SELECT code_value FROM code_info WHERE code_category = $1 AND "; + let sql = + "SELECT code_value FROM code_info WHERE code_category = $1 AND "; const values: any[] = [categoryCode]; let paramIndex = 2;