fix: screen_menu_assignments를 통해 메뉴별 테이블 조회

 문제:
- screen_definitions 테이블에 menu_objid 컬럼이 없음
- SQL 쿼리 실행 실패 (500 에러)

 수정:
- screen_menu_assignments와 screen_definitions를 JOIN하여 조회
- menu_objid → screen_id → table_name 경로로 데이터 조회

🎯 쿼리 구조:
SELECT DISTINCT sd.table_name
FROM screen_menu_assignments sma
INNER JOIN screen_definitions sd ON sma.screen_id = sd.screen_id
WHERE sma.menu_objid = ANY($1)
  AND sma.company_code = $2
  AND sd.table_name IS NOT NULL
This commit is contained in:
kjs 2025-11-11 14:47:25 +09:00
parent 23911d3dd8
commit e7ecd0a863
1 changed files with 6 additions and 5 deletions

View File

@ -1634,11 +1634,12 @@ export async function getCategoryColumnsByMenu(
const pool = getPool();
const tablesQuery = `
SELECT DISTINCT table_name
FROM screen_definitions
WHERE menu_objid = ANY($1)
AND company_code = $2
AND table_name IS NOT NULL
SELECT DISTINCT sd.table_name
FROM screen_menu_assignments sma
INNER JOIN screen_definitions sd ON sma.screen_id = sd.screen_id
WHERE sma.menu_objid = ANY($1)
AND sma.company_code = $2
AND sd.table_name IS NOT NULL
`;
const tablesResult = await pool.query(tablesQuery, [siblingObjids, companyCode]);