diff --git a/backend-node/src/controllers/adminController.ts b/backend-node/src/controllers/adminController.ts index 02a11996..b3ecbffb 100644 --- a/backend-node/src/controllers/adminController.ts +++ b/backend-node/src/controllers/adminController.ts @@ -1127,12 +1127,16 @@ export async function saveMenu( const objid = Date.now(); // 고유 ID 생성 const companyCode = requestCompanyCode || userCompanyCode; + // menu_url이 비어있으면 screen_code도 null로 설정 + const menuUrl = menuData.menuUrl || null; + const screenCode = menuUrl ? menuData.screenCode || null : null; + const [savedMenu] = await query( `INSERT INTO menu_info ( objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng, seq, menu_url, menu_desc, writer, regdate, status, - system_name, company_code, lang_key, lang_key_desc - ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) + system_name, company_code, lang_key, lang_key_desc, screen_code + ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING *`, [ objid, @@ -1141,7 +1145,7 @@ export async function saveMenu( menuData.menuNameKor, menuData.menuNameEng || null, menuData.seq ? Number(menuData.seq) : null, - menuData.menuUrl || null, + menuUrl, menuData.menuDesc || null, req.user?.userId || "admin", new Date(), @@ -1150,6 +1154,7 @@ export async function saveMenu( companyCode, menuData.langKey || null, menuData.langKeyDesc || null, + screenCode, ] ); @@ -1314,6 +1319,17 @@ export async function updateMenu( ] ); + // menu_url이 비어있으면 화면 할당도 해제 (screen_menu_assignments의 is_active를 'N'으로) + if (!menuUrl) { + await query( + `UPDATE screen_menu_assignments + SET is_active = 'N', updated_date = NOW() + WHERE menu_objid = $1 AND company_code = $2`, + [Number(menuId), companyCode] + ); + logger.info("화면 할당 비활성화", { menuId, companyCode }); + } + logger.info("메뉴 수정 성공", { updatedMenu }); const response: ApiResponse = {