blob: 2b3cbda3d8d6ce7ef47181c6a29c9f91ea893b10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 }
);
|