import { oracleKnex } from '@/lib/oracle-db/db'; import { unstable_cache } from 'next/cache'; // Types export interface ScreenEvcp { SCR_ID: string; SCR_NM: 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; // '1' | '0' 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 } );