"use server" import { oracleKnex } from '@/lib/oracle-db/db' // SSLVW_PUR_INQ_REQ 테이블 데이터 타입 (실제 테이블 구조에 맞게 조정 필요) export interface SSLVWPurInqReq { [key: string]: string | number | Date | null | undefined } // 테스트 환경용 폴백 데이터 const FALLBACK_TEST_DATA: SSLVWPurInqReq[] = [ { id: 1, request_number: 'REQ001', status: 'PENDING', created_date: new Date('2025-01-01'), description: '테스트 요청 1' }, { id: 2, request_number: 'REQ002', status: 'APPROVED', created_date: new Date('2025-01-02'), description: '테스트 요청 2' } ] /** * SSLVW_PUR_INQ_REQ 테이블 전체 조회 * @returns 테이블 데이터 배열 */ export async function getSSLVWPurInqReqData(): Promise<{ success: boolean data: SSLVWPurInqReq[] error?: string isUsingFallback?: boolean }> { try { console.log('📋 [getSSLVWPurInqReqData] SSLVW_PUR_INQ_REQ 테이블 조회 시작...') const result = await oracleKnex.raw(` SELECT * FROM SSLVW_PUR_INQ_REQ WHERE ROWNUM < 100 ORDER BY 1 `) // Oracle raw query의 결과는 rows 배열에 들어있음 const rows = (result.rows || result) as Array> console.log(`✅ [getSSLVWPurInqReqData] 조회 성공 - ${rows.length}건`) // 데이터 타입 변환 (필요에 따라 조정) const cleanedResult = rows.map((item) => { const convertedItem: SSLVWPurInqReq = {} for (const [key, value] of Object.entries(item)) { if (value instanceof Date) { convertedItem[key] = value } else if (value === null) { convertedItem[key] = null } else { convertedItem[key] = String(value) } } return convertedItem }) return { success: true, data: cleanedResult, isUsingFallback: false } } catch (error) { console.error('❌ [getSSLVWPurInqReqData] 오류:', error) console.log('🔄 [getSSLVWPurInqReqData] 폴백 테스트 데이터 사용') return { success: true, data: FALLBACK_TEST_DATA, isUsingFallback: true } } }