fix: source_menu_objid 저장 문제 해결 - BigInt 타입 비교 수정
문제: - PostgreSQL BIGINT 타입이 JavaScript에서 문자열로 반환됨 - menu.objid === rootMenuObjid 비교가 항상 false (타입 불일치) - 결과: source_menu_objid가 NULL로 저장되어 덮어쓰기 기능 작동 안 함 해결: - String() 변환 후 비교: String(menu.objid) === String(rootMenuObjid) - 타입에 관계없이 값 비교 가능 - source_menu_objid 정상 저장되어 덮어쓰기 기능 작동 검증: - 로그: '📌 source_menu_objid 저장: 1762407678882 (원본 최상위 메뉴)' - DB: menu_info.source_menu_objid = 1762407678882 ✅ 관련 파일: - backend-node/src/services/menuCopyService.ts
This commit is contained in:
parent
c70998fa4f
commit
9b7416b6f8
|
|
@ -713,6 +713,7 @@ export class MenuCopyService {
|
|||
logger.info("\n📂 [4단계] 메뉴 복사");
|
||||
const menuIdMap = await this.copyMenus(
|
||||
menus,
|
||||
sourceMenuObjid, // 원본 최상위 메뉴 ID 전달
|
||||
targetCompanyCode,
|
||||
screenIdMap,
|
||||
userId,
|
||||
|
|
@ -1138,6 +1139,7 @@ export class MenuCopyService {
|
|||
*/
|
||||
private async copyMenus(
|
||||
menus: Menu[],
|
||||
rootMenuObjid: number,
|
||||
targetCompanyCode: string,
|
||||
screenIdMap: Map<number, number>,
|
||||
userId: string,
|
||||
|
|
@ -1170,15 +1172,14 @@ export class MenuCopyService {
|
|||
menuIdMap.get(menu.parent_obj_id) || menu.parent_obj_id;
|
||||
}
|
||||
|
||||
// source_menu_objid 저장: 최상위 메뉴는 원본 ID, 하위 메뉴는 최상위의 원본 ID
|
||||
const sourceMenuObjid =
|
||||
!menu.parent_obj_id || menu.parent_obj_id === 0
|
||||
? menu.objid // 최상위 메뉴: 자신의 ID가 원본
|
||||
: null; // 하위 메뉴: NULL (최상위만 추적)
|
||||
// source_menu_objid 저장: 원본 최상위 메뉴만 저장 (덮어쓰기 식별용)
|
||||
// BigInt 타입이 문자열로 반환될 수 있으므로 문자열로 변환 후 비교
|
||||
const isRootMenu = String(menu.objid) === String(rootMenuObjid);
|
||||
const sourceMenuObjid = isRootMenu ? menu.objid : null;
|
||||
|
||||
if (sourceMenuObjid) {
|
||||
logger.info(
|
||||
` 📌 source_menu_objid 저장: ${sourceMenuObjid} (최상위 메뉴)`
|
||||
` 📌 source_menu_objid 저장: ${sourceMenuObjid} (원본 최상위 메뉴)`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue