From c3cb1a0033037668a31af5596a7eba5a5d63fd8a Mon Sep 17 00:00:00 2001 From: hyeonsu Date: Sun, 21 Sep 2025 11:39:34 +0900 Subject: [PATCH] =?UTF-8?q?entity=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataflow/condition/WebTypeInput.tsx | 38 +++++++++++++++++-- .../connection/ColumnTableSection.tsx | 1 + 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/frontend/components/dataflow/condition/WebTypeInput.tsx b/frontend/components/dataflow/condition/WebTypeInput.tsx index a8a9ede7..7b96b6af 100644 --- a/frontend/components/dataflow/condition/WebTypeInput.tsx +++ b/frontend/components/dataflow/condition/WebTypeInput.tsx @@ -79,7 +79,23 @@ export const WebTypeInput: React.FC = ({ const loadEntityData = useCallback(async () => { try { setLoading(true); - const data = await EntityReferenceAPI.getEntityReferenceData(tableName!, column.columnName, { limit: 100 }); + // tableName이 없으면 referenceTable에서 추론 (dept_code -> dept_info) + const effectiveTableName = + tableName || + (() => { + if (column.columnName?.endsWith("_code")) { + return column.columnName.replace("_code", "_info"); + } + if (column.columnName?.endsWith("_id")) { + return column.columnName.replace("_id", "_info"); + } + return "unknown_table"; + })(); + + console.log(`🔍 Entity API 호출: ${effectiveTableName}.${column.columnName}`); + const data = await EntityReferenceAPI.getEntityReferenceData(effectiveTableName, column.columnName, { + limit: 100, + }); setEntityOptions(data.options); } catch { setEntityOptions([]); @@ -105,9 +121,25 @@ export const WebTypeInput: React.FC = ({ // Entity 타입일 때 참조 데이터 로드 useEffect(() => { + // 디버깅: dept_code 필드의 정보 확인 + if (column.columnName === "dept_code") { + console.log("🔍 dept_code 필드 디버깅:", { + columnName: column.columnName, + webType: webType, + referenceTable: column.referenceTable, + tableName: tableName, + shouldLoadEntity: (webType === "entity" || column.referenceTable) && tableName && column.columnName, + fullColumn: column, + }); + } + // webType이 entity이거나, referenceTable이 있으면 entity로 처리 - if ((webType === "entity" || column.referenceTable) && tableName && column.columnName) { - loadEntityData(); + if ((webType === "entity" || column.referenceTable) && column.columnName) { + // tableName이 없으면 referenceTable에서 추론 + const effectiveTableName = tableName || (column.referenceTable ? "unknown" : null); + if (effectiveTableName) { + loadEntityData(); + } } else if (webType === "code" && (column.codeCategory || detailSettings.codeCategory || fallbackCodeCategory)) { loadCodeData(); } diff --git a/frontend/components/dataflow/connection/ColumnTableSection.tsx b/frontend/components/dataflow/connection/ColumnTableSection.tsx index 3247f4cf..c394c098 100644 --- a/frontend/components/dataflow/connection/ColumnTableSection.tsx +++ b/frontend/components/dataflow/connection/ColumnTableSection.tsx @@ -310,6 +310,7 @@ export const ColumnTableSection: React.FC = ({ onChange={(value) => onDefaultValueChange(column.columnName, value)} className="h-6 border-gray-200 text-xs focus:border-green-400 focus:ring-0" placeholder="기본값 입력..." + tableName={tableName} /> )}