fix: 공통 카테고리 설정(menu_objid=0) 복사 누락 문제 해결

문제:
- menu_objid = 0인 공통 카테고리 값들이 복사되지 않음
- 원본 34개 중 15개만 복사됨 (19개 누락)
- customer_mng, item_info 등의 공통 카테고리 값들이 프론트엔드에서 안 보임

원인:
- collectCategorySettings: menu_objid로만 WHERE 필터링
- copyCategorySettings: menuIdMap.get()이 0을 찾지 못함

해결:
1. collectCategorySettings 함수:
   - WHERE menu_objid = ANY($1) OR menu_objid = 0
   - 공통 카테고리 설정도 함께 수집

2. copyCategorySettings 함수:
   - menu_objid = 0일 경우 그대로 0으로 유지
   - if (newMenuObjid === undefined) 체크로 안전성 강화

영향:
- 공통 카테고리 값(division, status, currency_code 등) 정상 복사
- 모든 화면에서 카테고리 값 정상 표시

테스트:
- 원본 34개 → 복사본 34개 (100% 복사)
- customer_mng.division, item_info.division 등 정상 동작
This commit is contained in:
kjs 2025-11-21 16:04:04 +09:00
parent 42435193cf
commit be48d30d8f
1 changed files with 35 additions and 21 deletions

View File

@ -410,26 +410,26 @@ export class MenuCopyService {
const columnMappings: any[] = [];
const categoryValues: any[] = [];
for (const menuObjid of menuObjids) {
// 카테고리 컬럼 매핑
const mappingsResult = await client.query(
`SELECT * FROM category_column_mapping
WHERE menu_objid = $1 AND company_code = $2`,
[menuObjid, sourceCompanyCode]
);
columnMappings.push(...mappingsResult.rows);
// 카테고리 컬럼 매핑 (메뉴별 + 공통)
const mappingsResult = await client.query(
`SELECT * FROM category_column_mapping
WHERE (menu_objid = ANY($1) OR menu_objid = 0)
AND company_code = $2`,
[menuObjids, sourceCompanyCode]
);
columnMappings.push(...mappingsResult.rows);
// 테이블 컬럼 카테고리 값
const valuesResult = await client.query(
`SELECT * FROM table_column_category_values
WHERE menu_objid = $1 AND company_code = $2`,
[menuObjid, sourceCompanyCode]
);
categoryValues.push(...valuesResult.rows);
}
// 테이블 컬럼 카테고리 값 (메뉴별 + 공통)
const valuesResult = await client.query(
`SELECT * FROM table_column_category_values
WHERE (menu_objid = ANY($1) OR menu_objid = 0)
AND company_code = $2`,
[menuObjids, sourceCompanyCode]
);
categoryValues.push(...valuesResult.rows);
logger.info(
`✅ 카테고리 설정 수집 완료: 컬럼 매핑 ${columnMappings.length}, 카테고리 값 ${categoryValues.length}`
`✅ 카테고리 설정 수집 완료: 컬럼 매핑 ${columnMappings.length} (공통 포함), 카테고리 값 ${categoryValues.length} (공통 포함)`
);
return { columnMappings, categoryValues };
}
@ -1647,8 +1647,15 @@ export class MenuCopyService {
// 1) 카테고리 컬럼 매핑 복사 (덮어쓰기 모드)
for (const mapping of settings.columnMappings) {
const newMenuObjid = menuIdMap.get(mapping.menu_objid);
if (!newMenuObjid) continue;
// menu_objid = 0인 공통 설정은 그대로 0으로 유지
const newMenuObjid = mapping.menu_objid === 0
? 0
: menuIdMap.get(mapping.menu_objid);
if (newMenuObjid === undefined) {
logger.debug(` ⏭️ 매핑할 메뉴가 없음: menu_objid=${mapping.menu_objid}`);
continue;
}
// 기존 매핑 삭제 (덮어쓰기)
await client.query(
@ -1700,8 +1707,15 @@ export class MenuCopyService {
// 새 값 추가
for (const value of sortedValues) {
const newMenuObjid = menuIdMap.get(value.menu_objid);
if (!newMenuObjid) continue;
// menu_objid = 0인 공통 설정은 그대로 0으로 유지
const newMenuObjid = value.menu_objid === 0
? 0
: menuIdMap.get(value.menu_objid);
if (newMenuObjid === undefined) {
logger.debug(` ⏭️ 매핑할 메뉴가 없음: menu_objid=${value.menu_objid}`);
continue;
}
// 부모 ID 재매핑
let newParentValueId = null;