Files
bio_frontend/types/permissions.ts

435 lines
12 KiB
TypeScript
Raw Normal View History

2025-09-23 14:15:32 +09:00
/**
*
*
2025-09-23 15:21:00 +09:00
* 2 > > .
2025-09-23 14:15:32 +09:00
*
* :
2025-09-23 15:21:00 +09:00
* - 페이지그룹: PG01, PG02, PG03, PG04...
* - 페이지: P0101 (PG01 ), P0201 (PG02 ), P0501 ( )...
2025-09-23 14:15:32 +09:00
* - 컴포넌트: C010101 (P0101 ), C010102 (P0101 )...
*/
2025-09-23 15:21:00 +09:00
// 리소스 타입 정의 (페이지그룹, 페이지, 컴포넌트)
export type ResourceType = "PAGE_GROUP" | "PAGE" | "COMPONENT";
2025-09-23 14:15:32 +09:00
// 개별 리소스 객체 (계층 구조 지원)
export interface Resource {
oid: number; // OID (고유 식별자)
2025-09-23 15:21:00 +09:00
code: string; // 2자리 계층 코드 (PG01, P0101, C010101)
2025-09-23 14:15:32 +09:00
name: string; // 리소스 이름
parentCode?: string; // 부모 리소스 코드 (계층 구조)
type: ResourceType; // 리소스 타입
2025-09-23 15:21:00 +09:00
path?: string; // 페이지 경로 (PAGE 타입만)
2025-09-23 14:15:32 +09:00
sortOrder: number; // 정렬 순서
description?: string; // 리소스 설명
2025-09-23 15:21:00 +09:00
menuYn?: string; // 메뉴 여부 (char(1))
2025-09-23 14:15:32 +09:00
componentType?: string; // 컴포넌트 세부 타입 (버튼, 그리드 등)
}
// 사용자 권한 구조 (계층적 리소스 관리)
export interface UserPermissions {
resources: {
2025-09-23 15:21:00 +09:00
pageGroups: Resource[]; // 페이지그룹 리소스들 (PG01, PG02...)
2025-09-23 14:15:32 +09:00
pages: Resource[]; // 페이지 리소스들 (P0101, P0201...)
components: Resource[]; // 컴포넌트 리소스들 (C010101, C010102...)
};
}
// 권한 체크 결과 타입 (권한 스토어에서 제공하는 함수들)
export interface PermissionCheckResult {
// 기존 호환성 함수들 (경로/코드 기반)
hasPagePermission: (page: string) => boolean; // 페이지 경로로 권한 체크
2025-09-23 15:21:00 +09:00
hasPageGroupPermission: (pageGroup: string) => boolean; // 페이지그룹 코드로 권한 체크
2025-09-23 14:15:32 +09:00
hasComponentPermission: (component: string) => boolean; // 컴포넌트 코드로 권한 체크
// 계층 구조를 고려한 권한 체크 함수들
hasResourcePermission: (resourceCode: string) => boolean; // 리소스 코드로 권한 체크
getResourceByCode: (code: string) => Resource | undefined; // 코드로 리소스 조회
getResourceByPath: (path: string) => Resource | undefined; // 경로로 리소스 조회
getChildResources: (parentCode: string) => Resource[]; // 부모의 자식 리소스들 조회
}
// 권한 종류별 상수 (기존 호환성 유지용)
export const PERMISSION_TYPES = {
PAGE: "pagePermissions",
2025-09-23 15:21:00 +09:00
PAGE_GROUP: "pageGroupPermissions",
2025-09-23 14:15:32 +09:00
COMPONENT: "componentPermissions",
} as const;
/**
* (/)
*
* 2 .
*
* :
2025-09-23 15:21:00 +09:00
* - PG01 ( ) > P0101~P0115 ( ) > C010101~C010106 ()
* - PG02 ( ) > P0201~P0203 ( )
2025-09-23 14:15:32 +09:00
* - P0501~P0504 ( 페이지들: , , , )
* - P0601~P0602 ( )
* - P0701 ( )
*/
export const MOCK_PERMISSIONS: UserPermissions = {
resources: {
2025-09-23 15:21:00 +09:00
// 페이지그룹 리소스들 (최상위 레벨)
pageGroups: [
2025-09-23 14:15:32 +09:00
{
oid: 1,
2025-09-23 15:21:00 +09:00
code: "PG01",
name: "테스트",
type: "PAGE_GROUP",
2025-09-23 14:15:32 +09:00
sortOrder: 1,
2025-09-23 15:21:00 +09:00
description: "테스트 관련 페이지그룹",
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 2,
2025-09-23 15:21:00 +09:00
code: "PG02",
name: "관리자",
type: "PAGE_GROUP",
2025-09-23 14:15:32 +09:00
sortOrder: 2,
2025-09-23 15:21:00 +09:00
description: "관리자 전용 페이지그룹",
menuYn: "Y",
},
{
oid: 3,
code: "PG03",
name: "공통 팝업",
type: "PAGE_GROUP",
sortOrder: 2,
description: "공통 팝업 페이지그룹",
menuYn: "N",
2025-09-23 14:15:32 +09:00
},
],
// 페이지 리소스들 (화면 메뉴 구성에 맞춤)
pages: [
2025-09-23 15:21:00 +09:00
// 테스트 페이지그룹 하위 페이지들 (PG01 > P0101~P0115)
2025-09-23 14:15:32 +09:00
{
oid: 5,
code: "P0101",
name: "테스트",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
sortOrder: 1,
description: "기본 테스트 페이지",
menuYn: "Y",
},
{
oid: 50,
code: "P010101",
name: "테스트 등록 팝업",
type: "PAGE",
path: "/test/registerPopup",
parentCode: "P0101",
2025-09-23 14:15:32 +09:00
sortOrder: 1,
description: "기본 테스트 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 6,
code: "P0102",
name: "ivg",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/igv",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 2,
description: "IGV 테스트 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 7,
code: "P0103",
name: "ivg2",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/igv2",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 3,
description: "IGV2 테스트 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 8,
code: "P0104",
name: "pathway",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/pathway",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 4,
description: "경로 분석 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 9,
code: "P0105",
name: "pathway2",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/pathway2",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 5,
description: "경로 분석 페이지 2",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 10,
code: "P0106",
name: "pathway3",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/pathway3",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 6,
description: "경로 분석 페이지 3",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 11,
code: "P0107",
name: "pathway4",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/pathway4",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 7,
description: "경로 분석 페이지 4",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 12,
code: "P0108",
name: "pathwayjson",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/pathwayJson",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 8,
description: "경로 분석 JSON 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 13,
code: "P0109",
name: "배양그래프",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/culture-graph",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 9,
description: "배양 그래프 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 14,
code: "P0110",
name: "배양그래프 멀티",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/culture-graph-multi",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 10,
description: "배양 그래프 멀티 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 15,
code: "P0111",
name: "배양그래프 탭",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/culture-graph-tab",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 11,
description: "배양 그래프 탭 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 16,
code: "P0112",
name: "tui-grid",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/tui",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 12,
description: "TUI 그리드 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 17,
code: "P0113",
name: "리소스",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/admin/resource",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 13,
description: "리소스 관리 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 18,
code: "P0114",
name: "sample",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/sampleList",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 14,
description: "샘플 목록 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 19,
code: "P0115",
name: "공용 기능 테스트",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/test/common-test",
2025-09-23 15:21:00 +09:00
parentCode: "PG01",
2025-09-23 14:15:32 +09:00
sortOrder: 15,
description: "공용 기능 테스트 페이지",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
},
{
oid: 20,
2025-09-23 15:21:00 +09:00
code: "P0116",
name: "권한 시스템 테스트",
type: "PAGE",
path: "/test/permission-test",
parentCode: "PG01",
sortOrder: 16,
description: "권한 시스템 테스트 페이지",
menuYn: "Y",
},
{
oid: 25,
code: "P0117",
2025-09-23 15:21:00 +09:00
name: "등록",
type: "PAGE",
path: "/test/register",
parentCode: "PG01",
sortOrder: 17,
2025-09-23 15:21:00 +09:00
description: "테스트 등록 페이지",
menuYn: "N",
2025-09-23 14:15:32 +09:00
},
{
oid: 26,
code: "P0118",
name: "molstar",
type: "PAGE",
path: "/test/molstar",
parentCode: "PG01",
sortOrder: 18,
description: "Mol* 뷰어 테스트 페이지",
menuYn: "Y",
},
2025-09-23 14:15:32 +09:00
2025-09-23 15:21:00 +09:00
// 관리자 페이지그룹 하위 페이지들 (PG02 > P0201~P0203)
2025-09-23 14:15:32 +09:00
{
oid: 21,
2025-09-23 14:15:32 +09:00
code: "P0201",
name: "접속기록",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/admin/logs",
2025-09-23 15:21:00 +09:00
parentCode: "PG02",
2025-09-23 14:15:32 +09:00
sortOrder: 1,
description: "사용자 접속 기록 관리",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 22,
2025-09-23 14:15:32 +09:00
code: "P0202",
name: "공통코드",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/admin/codes",
2025-09-23 15:21:00 +09:00
parentCode: "PG02",
2025-09-23 14:15:32 +09:00
sortOrder: 2,
description: "공통 코드 관리",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
2025-09-23 14:15:32 +09:00
},
{
oid: 23,
2025-09-23 14:15:32 +09:00
code: "P0203",
name: "프로그램",
2025-09-23 15:21:00 +09:00
type: "PAGE",
2025-09-23 14:15:32 +09:00
path: "/admin/programs",
2025-09-23 15:21:00 +09:00
parentCode: "PG02",
2025-09-23 14:15:32 +09:00
sortOrder: 3,
description: "프로그램 관리",
2025-09-23 15:21:00 +09:00
menuYn: "Y",
},
{
oid: 24,
2025-09-23 15:21:00 +09:00
code: "P0204",
name: "등록",
type: "PAGE",
path: "/admin/register",
parentCode: "PG02",
sortOrder: 4,
description: "관리자 등록 페이지",
menuYn: "N",
},
{
oid: 25,
2025-09-23 15:21:00 +09:00
code: "P0301",
name: "부서 조회 팝업",
type: "PAGE",
path: "/test/departmentPopup",
parentCode: "PG03",
sortOrder: 1,
description: "부서 조회 팝업",
menuYn: "N",
2025-09-23 14:15:32 +09:00
},
],
// 컴포넌트 리소스들 (페이지 하위)
components: [
// 테스트 페이지 하위 컴포넌트들 (P0101 > C010101~C010106)
{
oid: 19,
code: "C010101",
name: "삭제 버튼",
2025-09-23 15:21:00 +09:00
type: "COMPONENT",
2025-09-23 14:15:32 +09:00
parentCode: "P0101",
sortOrder: 1,
description: "테스트 삭제 버튼",
},
{
oid: 20,
code: "C010102",
name: "수정 버튼",
2025-09-23 15:21:00 +09:00
type: "COMPONENT",
2025-09-23 14:15:32 +09:00
parentCode: "P0101",
sortOrder: 2,
description: "테스트 수정 버튼",
},
{
oid: 21,
code: "C010103",
name: "내보내기 버튼",
2025-09-23 15:21:00 +09:00
type: "COMPONENT",
2025-09-23 14:15:32 +09:00
parentCode: "P0101",
sortOrder: 3,
description: "테스트 내보내기 버튼",
},
{
oid: 22,
code: "C010104",
name: "가져오기 버튼",
2025-09-23 15:21:00 +09:00
type: "COMPONENT",
2025-09-23 14:15:32 +09:00
parentCode: "P0101",
sortOrder: 4,
description: "테스트 가져오기 버튼",
},
{
oid: 23,
code: "C010105",
name: "생성 버튼",
2025-09-23 15:21:00 +09:00
type: "COMPONENT",
2025-09-23 14:15:32 +09:00
parentCode: "P0101",
sortOrder: 5,
description: "테스트 생성 버튼",
},
{
oid: 24,
code: "C010106",
name: "보기 버튼",
2025-09-23 15:21:00 +09:00
type: "COMPONENT",
2025-09-23 14:15:32 +09:00
parentCode: "P0101",
sortOrder: 6,
description: "테스트 상세보기 버튼",
},
],
},
};