From ccbb6924c86aa2dd39c5cef219efc3fbdbc3f0b5 Mon Sep 17 00:00:00 2001 From: kjs Date: Mon, 10 Nov 2025 16:32:00 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20writer=20=EC=BB=AC=EB=9F=BC=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=20user=5Fname=20=EB=B3=80=ED=99=98=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 문제: 테이블 리스트에서 writer 컬럼이 user_id로 표시됨 - 해결: 1. 백엔드: entityJoinService에서 writer 컬럼 자동 감지 2. writer 컬럼 발견 시 user_info 테이블과 자동 조인 3. writer_name 별칭으로 user_name 반환 4. 프론트엔드: writer 컬럼일 때 writer_name 우선 표시 - 영향: - writer 컬럼이 있는 모든 테이블에서 자동으로 작성자명 표시 - 기존 entity 조인 설정과 충돌 없이 작동 - column_labels 설정 불필요 --- .../src/services/entityJoinService.ts | 33 +++++++++++++++++++ frontend/components/screen/ScreenDesigner.tsx | 6 ---- .../table-list/TableListComponent.tsx | 5 +++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/backend-node/src/services/entityJoinService.ts b/backend-node/src/services/entityJoinService.ts index df2823c8..d2db8c9e 100644 --- a/backend-node/src/services/entityJoinService.ts +++ b/backend-node/src/services/entityJoinService.ts @@ -49,6 +49,39 @@ export class EntityJoinService { const joinConfigs: EntityJoinConfig[] = []; + // 🎯 writer 컬럼 자동 감지 및 조인 설정 추가 + const tableColumns = await query<{ column_name: string }>( + `SELECT column_name + FROM information_schema.columns + WHERE table_name = $1 + AND table_schema = 'public' + AND column_name = 'writer'`, + [tableName] + ); + + if (tableColumns.length > 0) { + logger.info(`✅ writer 컬럼 발견: ${tableName}.writer -> user_info.user_id`); + + const writerJoinConfig: EntityJoinConfig = { + sourceTable: tableName, + sourceColumn: "writer", + referenceTable: "user_info", + referenceColumn: "user_id", + displayColumns: ["user_name"], + displayColumn: "user_name", + aliasColumn: "writer_name", + separator: " - ", + }; + + // 조인 설정 유효성 검증 + if (await this.validateJoinConfig(writerJoinConfig)) { + joinConfigs.push(writerJoinConfig); + logger.info(`✅ writer 컬럼 조인 설정 추가됨: writer_name`); + } else { + logger.warn(`❌ writer 컬럼 조인 설정 검증 실패`); + } + } + for (const column of entityColumns) { logger.info(`🔍 Entity 컬럼 상세 정보:`, { column_name: column.column_name, diff --git a/frontend/components/screen/ScreenDesigner.tsx b/frontend/components/screen/ScreenDesigner.tsx index 0f3cc9b4..54f26a8d 100644 --- a/frontend/components/screen/ScreenDesigner.tsx +++ b/frontend/components/screen/ScreenDesigner.tsx @@ -634,15 +634,9 @@ export default function ScreenDesigner({ selectedScreen, onBackToList }: ScreenD } } - console.log("🔍 최종 newComp:", { id: newComp.id, size: newComp.size, path }); return newComp; }); - console.log( - "🔍 updatedComponents:", - updatedComponents.map((c) => ({ id: c.id, size: c.size })), - ); - // 🔥 새로운 layout 생성 const newLayout = { ...prevLayout, components: updatedComponents }; diff --git a/frontend/lib/registry/components/table-list/TableListComponent.tsx b/frontend/lib/registry/components/table-list/TableListComponent.tsx index 30756d09..f6a99536 100644 --- a/frontend/lib/registry/components/table-list/TableListComponent.tsx +++ b/frontend/lib/registry/components/table-list/TableListComponent.tsx @@ -1062,6 +1062,11 @@ export const TableListComponent: React.FC = ({ (value: any, column: ColumnConfig, rowData?: Record) => { if (value === null || value === undefined) return "-"; + // 🎯 writer 컬럼 자동 변환: user_id -> user_name + if (column.columnName === "writer" && rowData && rowData.writer_name) { + return rowData.writer_name; + } + // 🎯 엔티티 컬럼 표시 설정이 있는 경우 if (column.entityDisplayConfig && rowData) { // displayColumns 또는 selectedColumns 둘 다 체크