fix: 채번규칙 메뉴별 격리 문제 해결

문제: 영업관리 메뉴에서 생성한 채번규칙이 기준정보 메뉴에도 표시됨

원인:
- scope_type='table' 규칙을 조회할 때 menu_objid 필터링 없이 모든 규칙을 포함
- 'OR scope_type = 'table'' 조건이 다른 메뉴의 규칙도 반환

수정:
- scope_type='table' 규칙도 menu_objid로 필터링하도록 변경
- 'OR (scope_type = 'table' AND menu_objid = ANY(cd /Users/kimjuseok/ERP-node && git commit -m "fix: 채번규칙 메뉴별 격리 문제 해결

문제: 영업관리 메뉴에서 생성한 채번규칙이 기준정보 메뉴에도 표시됨

원인:
- scope_type='table' 규칙을 조회할 때 menu_objid 필터링 없이 모든 규칙을 포함
- 'OR scope_type = 'table'' 조건이 다른 메뉴의 규칙도 반환

수정:
- scope_type='table' 규칙도 menu_objid로 필터링하도록 변경
- 'OR (scope_type = 'table' AND menu_objid = ANY($1))' 조건으로 메뉴별 격리
- menu_objid IS NULL인 기존 규칙은 하위 호환성을 위해 유지

영향:
- 각 메뉴에서 생성한 채번규칙은 해당 메뉴(및 형제 메뉴)에서만 표시
- global 규칙은 여전히 모든 메뉴에서 표시
- 기존 데이터는 영향 없음 (menu_objid NULL 조건 유지)"))' 조건으로 메뉴별 격리
- menu_objid IS NULL인 기존 규칙은 하위 호환성을 위해 유지

영향:
- 각 메뉴에서 생성한 채번규칙은 해당 메뉴(및 형제 메뉴)에서만 표시
- global 규칙은 여전히 모든 메뉴에서 표시
- 기존 데이터는 영향 없음 (menu_objid NULL 조건 유지)
This commit is contained in:
kjs
2025-11-20 18:05:49 +09:00
parent 62463e1ca8
commit 3219015a39

View File

@@ -300,10 +300,9 @@ class NumberingRuleService {
FROM numbering_rules
WHERE
scope_type = 'global'
OR scope_type = 'table'
OR (scope_type = 'menu' AND menu_objid = ANY($1))
OR (scope_type = 'table' AND menu_objid = ANY($1)) -- ⚠️ 임시: table 스코프도 menu_objid로 필터링
OR (scope_type = 'table' AND menu_objid IS NULL) -- ⚠️ 임시: 기존 규칙(menu_objid NULL) 포함
OR (scope_type = 'table' AND menu_objid = ANY($1)) -- ✅ 메뉴별로 필터링
OR (scope_type = 'table' AND menu_objid IS NULL) -- 기존 규칙(menu_objid NULL) 포함 (하위 호환성)
ORDER BY
CASE
WHEN scope_type = 'menu' OR (scope_type = 'table' AND menu_objid = ANY($1)) THEN 1
@@ -313,9 +312,9 @@ class NumberingRuleService {
created_at DESC
`;
params = [siblingObjids];
logger.info("최고 관리자: 형제 메뉴 포함 채번 규칙 조회 (기존 규칙 포함)", { siblingObjids });
logger.info("최고 관리자: 형제 메뉴 기반 채번 규칙 조회 (메뉴별 필터링)", { siblingObjids });
} else {
// 일반 회사: 자신의 규칙만 조회 (형제 메뉴 포함)
// 일반 회사: 자신의 규칙만 조회 (형제 메뉴 포함, 메뉴별 필터링)
query = `
SELECT
rule_id AS "ruleId",
@@ -336,10 +335,9 @@ class NumberingRuleService {
WHERE company_code = $1
AND (
scope_type = 'global'
OR scope_type = 'table'
OR (scope_type = 'menu' AND menu_objid = ANY($2))
OR (scope_type = 'table' AND menu_objid = ANY($2)) -- ⚠️ 임시: table 스코프도 menu_objid로 필터링
OR (scope_type = 'table' AND menu_objid IS NULL) -- ⚠️ 임시: 기존 규칙(menu_objid NULL) 포함
OR (scope_type = 'table' AND menu_objid = ANY($2)) -- ✅ 메뉴별로 필터링
OR (scope_type = 'table' AND menu_objid IS NULL) -- 기존 규칙(menu_objid NULL) 포함 (하위 호환성)
)
ORDER BY
CASE
@@ -350,7 +348,7 @@ class NumberingRuleService {
created_at DESC
`;
params = [companyCode, siblingObjids];
logger.info("회사별: 형제 메뉴 포함 채번 규칙 조회 (기존 규칙 포함)", { companyCode, siblingObjids });
logger.info("회사별: 형제 메뉴 기반 채번 규칙 조회 (메뉴별 필터링)", { companyCode, siblingObjids });
}
logger.info("🔍 채번 규칙 쿼리 실행", {