diff --git a/backend-node/src/controllers/tableManagementController.ts b/backend-node/src/controllers/tableManagementController.ts index e38e2cc5..7f79d998 100644 --- a/backend-node/src/controllers/tableManagementController.ts +++ b/backend-node/src/controllers/tableManagementController.ts @@ -557,7 +557,16 @@ export async function updateColumnInputType( ): Promise { try { const { tableName, columnName } = req.params; - const { inputType, detailSettings } = req.body; + let { inputType, detailSettings } = req.body; + + // πŸ”₯ "direct" λ˜λŠ” "auto"λŠ” ν”„λ‘ νŠΈμ—”λ“œμ˜ μž…λ ₯ 방식 κ΅¬λΆ„κ°’μ΄λ―€λ‘œ + // DB의 input_type(μ›Ήνƒ€μž…)으둜 μ €μž₯ν•˜λ©΄ μ•ˆ 됨 - "text"둜 λ³€ν™˜ + if (inputType === "direct" || inputType === "auto") { + logger.warn( + `잘λͺ»λœ inputType κ°’ 감지: ${inputType} β†’ 'text'둜 λ³€ν™˜ (${tableName}.${columnName})` + ); + inputType = "text"; + } // πŸ”₯ νšŒμ‚¬ μ½”λ“œ μΆ”μΆœ (JWTμ—μ„œ λ˜λŠ” DBμ—μ„œ 쑰회) let companyCode = req.user?.companyCode; @@ -1357,8 +1366,17 @@ export async function updateColumnWebType( `λ ˆκ±°μ‹œ API μ‚¬μš©: updateColumnWebType β†’ updateColumnInputType μ‚¬μš© ꢌμž₯` ); - // webType을 inputType으둜 λ³€ν™˜ - const convertedInputType = inputType || webType || "text"; + // πŸ”₯ inputType이 "direct" λ˜λŠ” "auto"이면 λ¬΄μ‹œν•˜κ³  webType μ‚¬μš© + // "direct"/"auto"λŠ” ν”„λ‘ νŠΈμ—”λ“œμ˜ μž…λ ₯ 방식(μ§μ ‘μž…λ ₯/μžλ™μž…λ ₯) ꡬ뢄값이지 + // DB에 μ €μž₯ν•  μ›Ή νƒ€μž…(text, number, date λ“±)이 μ•„λ‹˜ + let convertedInputType = webType || "text"; + if (inputType && inputType !== "direct" && inputType !== "auto") { + convertedInputType = inputType; + } + + logger.info( + `μ›Ήνƒ€μž… λ³€ν™˜: webType=${webType}, inputType=${inputType} β†’ ${convertedInputType}` + ); // μƒˆλ‘œμš΄ λ©”μ„œλ“œ 호좜 req.body = { inputType: convertedInputType, detailSettings }; diff --git a/backend-node/src/services/tableManagementService.ts b/backend-node/src/services/tableManagementService.ts index c8196235..cbe5e57e 100644 --- a/backend-node/src/services/tableManagementService.ts +++ b/backend-node/src/services/tableManagementService.ts @@ -456,6 +456,15 @@ export class TableManagementService { `컬럼 μ„€μ • μ—…λ°μ΄νŠΈ μ‹œμž‘: ${tableName}.${columnName}, company: ${companyCode}` ); + // πŸ”₯ "direct" λ˜λŠ” "auto"λŠ” ν”„λ‘ νŠΈμ—”λ“œμ˜ μž…λ ₯ 방식 κ΅¬λΆ„κ°’μ΄λ―€λ‘œ + // DB의 input_type(μ›Ήνƒ€μž…)으둜 μ €μž₯ν•˜λ©΄ μ•ˆ 됨 - "text"둜 λ³€ν™˜ + if (settings.inputType === "direct" || settings.inputType === "auto") { + logger.warn( + `잘λͺ»λœ inputType κ°’ 감지: ${settings.inputType} β†’ 'text'둜 λ³€ν™˜ (${tableName}.${columnName})` + ); + settings.inputType = "text"; + } + // ν…Œμ΄λΈ”μ΄ table_labels에 μ—†μœΌλ©΄ μžλ™ μΆ”κ°€ await this.insertTableIfNotExists(tableName); @@ -708,12 +717,22 @@ export class TableManagementService { inputType?: string ): Promise { try { + // πŸ”₯ 'direct'λ‚˜ 'auto'λŠ” ν”„λ‘ νŠΈμ—”λ“œμ˜ μž…λ ₯ 방식 κ΅¬λΆ„κ°’μ΄λ―€λ‘œ + // DB의 input_type(μ›Ήνƒ€μž…)으둜 μ €μž₯ν•˜λ©΄ μ•ˆ 됨 - 'text'둜 λ³€ν™˜ + let finalWebType = webType; + if (webType === "direct" || webType === "auto") { + logger.warn( + `잘λͺ»λœ webType κ°’ 감지: ${webType} β†’ 'text'둜 λ³€ν™˜ (${tableName}.${columnName})` + ); + finalWebType = "text"; + } + logger.info( - `컬럼 μž…λ ₯ νƒ€μž… μ„€μ • μ‹œμž‘: ${tableName}.${columnName} = ${webType}` + `컬럼 μž…λ ₯ νƒ€μž… μ„€μ • μ‹œμž‘: ${tableName}.${columnName} = ${finalWebType}` ); // μ›Ή νƒ€μž…λ³„ κΈ°λ³Έ 상세 μ„€μ • 생성 - const defaultDetailSettings = this.generateDefaultDetailSettings(webType); + const defaultDetailSettings = this.generateDefaultDetailSettings(finalWebType); // μ‚¬μš©μž μ •μ˜ μ„€μ •κ³Ό κΈ°λ³Έ μ„€μ • 병합 const finalDetailSettings = { @@ -732,10 +751,10 @@ export class TableManagementService { input_type = EXCLUDED.input_type, detail_settings = EXCLUDED.detail_settings, updated_date = NOW()`, - [tableName, columnName, webType, JSON.stringify(finalDetailSettings)] + [tableName, columnName, finalWebType, JSON.stringify(finalDetailSettings)] ); logger.info( - `컬럼 μž…λ ₯ νƒ€μž… μ„€μ • μ™„λ£Œ: ${tableName}.${columnName} = ${webType}` + `컬럼 μž…λ ₯ νƒ€μž… μ„€μ • μ™„λ£Œ: ${tableName}.${columnName} = ${finalWebType}` ); } catch (error) { logger.error( @@ -760,13 +779,23 @@ export class TableManagementService { detailSettings?: Record ): Promise { try { + // πŸ”₯ 'direct'λ‚˜ 'auto'λŠ” ν”„λ‘ νŠΈμ—”λ“œμ˜ μž…λ ₯ 방식 κ΅¬λΆ„κ°’μ΄λ―€λ‘œ + // DB의 input_type(μ›Ήνƒ€μž…)으둜 μ €μž₯ν•˜λ©΄ μ•ˆ 됨 - 'text'둜 λ³€ν™˜ + let finalInputType = inputType; + if (inputType === "direct" || inputType === "auto") { + logger.warn( + `잘λͺ»λœ input_type κ°’ 감지: ${inputType} β†’ 'text'둜 λ³€ν™˜ (${tableName}.${columnName})` + ); + finalInputType = "text"; + } + logger.info( - `컬럼 μž…λ ₯ νƒ€μž… μ„€μ • μ‹œμž‘: ${tableName}.${columnName} = ${inputType}, company: ${companyCode}` + `컬럼 μž…λ ₯ νƒ€μž… μ„€μ • μ‹œμž‘: ${tableName}.${columnName} = ${finalInputType}, company: ${companyCode}` ); // μž…λ ₯ νƒ€μž…λ³„ κΈ°λ³Έ 상세 μ„€μ • 생성 const defaultDetailSettings = - this.generateDefaultInputTypeSettings(inputType); + this.generateDefaultInputTypeSettings(finalInputType); // μ‚¬μš©μž μ •μ˜ μ„€μ •κ³Ό κΈ°λ³Έ μ„€μ • 병합 const finalDetailSettings = { @@ -788,7 +817,7 @@ export class TableManagementService { [ tableName, columnName, - inputType, + finalInputType, JSON.stringify(finalDetailSettings), companyCode, ] @@ -798,7 +827,7 @@ export class TableManagementService { await this.syncScreenLayoutsInputType( tableName, columnName, - inputType, + finalInputType, companyCode ); diff --git a/frontend/components/screen/TableTypeSelector.tsx b/frontend/components/screen/TableTypeSelector.tsx index 5da49312..c6757d92 100644 --- a/frontend/components/screen/TableTypeSelector.tsx +++ b/frontend/components/screen/TableTypeSelector.tsx @@ -174,30 +174,10 @@ export default function TableTypeSelector({ } }; - // μž…λ ₯ νƒ€μž… λ³€κ²½ - const handleInputTypeChange = async (columnName: string, inputType: "direct" | "auto") => { - try { - // ν˜„μž¬ 컬럼 정보 κ°€μ Έμ˜€κΈ° - const currentColumn = columns.find((col) => col.columnName === columnName); - if (!currentColumn) return; - - // μ›Ή νƒ€μž…κ³Ό ν•¨κ»˜ μž…λ ₯ νƒ€μž… μ—…λ°μ΄νŠΈ - await tableTypeApi.setColumnWebType( - selectedTable, - columnName, - currentColumn.webType || "text", - undefined, // detailSettings - inputType, - ); - - // 둜컬 μƒνƒœ μ—…λ°μ΄νŠΈ - setColumns((prev) => prev.map((col) => (col.columnName === columnName ? { ...col, inputType } : col))); - - // console.log(`컬럼 ${columnName}의 μž…λ ₯ νƒ€μž…μ„ ${inputType}둜 λ³€κ²½ν–ˆμŠ΅λ‹ˆλ‹€.`); - } catch (error) { - // console.error("μž…λ ₯ νƒ€μž… λ³€κ²½ μ‹€νŒ¨:", error); - alert("μž…λ ₯ νƒ€μž… 섀정에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€. λ‹€μ‹œ μ‹œλ„ν•΄μ£Όμ„Έμš”."); - } + // μž…λ ₯ νƒ€μž… λ³€κ²½ (둜컬 μƒνƒœλ§Œ - DB에 μ €μž₯ν•˜μ§€ μ•ŠμŒ) + const handleInputTypeChange = (columnName: string, inputType: "direct" | "auto") => { + // 둜컬 μƒνƒœλ§Œ μ—…λ°μ΄νŠΈ (DBμ—λŠ” μ €μž₯ν•˜μ§€ μ•ŠμŒ - inputType은 ν™”λ©΄ λ Œλ”λ§μš©) + setColumns((prev) => prev.map((col) => (col.columnName === columnName ? { ...col, inputType } : col))); }; const filteredTables = tables.filter((table) => table.displayName.toLowerCase().includes(searchTerm.toLowerCase())); diff --git a/frontend/lib/api/screen.ts b/frontend/lib/api/screen.ts index 74894dc0..9cdc1bd9 100644 --- a/frontend/lib/api/screen.ts +++ b/frontend/lib/api/screen.ts @@ -347,12 +347,10 @@ export const tableTypeApi = { columnName: string, webType: string, detailSettings?: Record, - inputType?: "direct" | "auto", ): Promise => { await apiClient.put(`/table-management/tables/${tableName}/columns/${columnName}/web-type`, { webType, detailSettings, - inputType, }); },