summaryrefslogtreecommitdiff
path: root/lib/nonsap/db.ts
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-12-01 16:13:43 +0900
committerjoonhoekim <26rote@gmail.com>2025-12-01 16:13:43 +0900
commit41bb0f9f67a85ac8e17d766492f79a2997d3c6e9 (patch)
treea2d56ea5b4713fe3a762c234622570cb36729628 /lib/nonsap/db.ts
parent13c8b4e48f62c1f437b1a2b10731d092fea2a83f (diff)
(김준회) 권한관리: 페이지 조회 권한 확인 처리
Diffstat (limited to 'lib/nonsap/db.ts')
-rw-r--r--lib/nonsap/db.ts68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/nonsap/db.ts b/lib/nonsap/db.ts
new file mode 100644
index 00000000..2b3cbda3
--- /dev/null
+++ b/lib/nonsap/db.ts
@@ -0,0 +1,68 @@
+import { oracleKnex } from '@/lib/oracle-db/db';
+import { unstable_cache } from 'next/cache';
+
+// Types
+export interface ScreenEvcp {
+ SCR_ID: string;
+ SCR_URL: string;
+ SCRT_CHK_YN: string; // 'Y' | 'N'
+ DEL_YN: string; // 'Y' | 'N'
+}
+
+export interface ScreenAuthEvcp {
+ SCR_ID: string;
+ ACSR_GB_CD: string; // 'U' | 'R' | 'D' | 'E'
+ ACSR_ID: string;
+ AUTH_CD_SEARCH: string; // 'Y' | 'N'
+ AUTH_CD_ADD: string;
+ AUTH_CD_DEL: string;
+ AUTH_CD_SAVE: string;
+ AUTH_CD_PRINT: string;
+ AUTH_CD_DOWN: string;
+ AUTH_CD_UP: string;
+ AUTH_CD_APPROVAL: string;
+ AUTH_CD_PREV: string;
+ AUTH_CD_NEXT: string;
+}
+
+export interface RoleEvcp {
+ ROLE_ID: string;
+ ROLE_NM: string;
+}
+
+export interface RoleRelEvcp {
+ ROLE_ID: string;
+ EMPNO: string;
+}
+
+// Fetch functions with cache
+
+export const getAllScreens = unstable_cache(
+ async () => {
+ const result = await oracleKnex('CMCVW_SCR_EVCP')
+ .select('*');
+ return result as ScreenEvcp[];
+ },
+ ['nonsap-all-screens'],
+ { revalidate: 60 }
+);
+
+export const getAuthsByScreenId = unstable_cache(
+ async (scrId: string) => {
+ const result = await oracleKnex('CMCVW_SCR_AUTH_EVCP')
+ .where('SCR_ID', scrId);
+ return result as ScreenAuthEvcp[];
+ },
+ ['nonsap-auths-by-screen-id'],
+ { revalidate: 60 }
+);
+
+export const getUserRoles = unstable_cache(
+ async (empNo: string) => {
+ const result = await oracleKnex('CMCVW_ROLE_REL_EVCP')
+ .where('EMPNO', empNo);
+ return result as RoleRelEvcp[];
+ },
+ ['nonsap-user-roles'],
+ { revalidate: 60 }
+);