summaryrefslogtreecommitdiff
path: root/app/api/oracle
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-05-28 00:17:56 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-05-28 00:17:56 +0000
commit9e280704988fdeffa05c1d8cbb731722f666c6af (patch)
treebbf57b3c882502dc7afd2ff770d95aca69fca0d9 /app/api/oracle
parent44356f1b203da5169db42950a42a8146f612c674 (diff)
(대표님) 앱 라우터 api 파트 커밋
Diffstat (limited to 'app/api/oracle')
-rw-r--r--app/api/oracle/[tableName]/route.ts42
-rw-r--r--app/api/oracle/columns/[tableName]/route.ts55
2 files changed, 97 insertions, 0 deletions
diff --git a/app/api/oracle/[tableName]/route.ts b/app/api/oracle/[tableName]/route.ts
new file mode 100644
index 00000000..0898421d
--- /dev/null
+++ b/app/api/oracle/[tableName]/route.ts
@@ -0,0 +1,42 @@
+import { NextRequest, NextResponse } from 'next/server';
+import { getTableData } from '@/lib/oracle/db';
+
+interface Params {
+ tableName: string;
+}
+
+interface ApiError {
+ message: string;
+ error?: string;
+}
+
+/**
+ * GET 핸들러 - 테이블 데이터 가져오기
+ */
+export async function GET(
+ request: NextRequest,
+ { params }: { params: Params }
+): Promise<NextResponse<{ data: any[] } | ApiError>> {
+ const { tableName } = params;
+
+ if (!tableName) {
+ return NextResponse.json(
+ { message: '테이블 이름이 필요합니다.' },
+ { status: 400 }
+ );
+ }
+
+ try {
+ const data = await getTableData(tableName);
+ return NextResponse.json({ data }, { status: 200 });
+ } catch (error: any) {
+ console.error('API 에러:', error);
+ return NextResponse.json(
+ {
+ message: '서버 에러가 발생했습니다.',
+ error: error.message
+ },
+ { status: 500 }
+ );
+ }
+} \ No newline at end of file
diff --git a/app/api/oracle/columns/[tableName]/route.ts b/app/api/oracle/columns/[tableName]/route.ts
new file mode 100644
index 00000000..ba62d7a8
--- /dev/null
+++ b/app/api/oracle/columns/[tableName]/route.ts
@@ -0,0 +1,55 @@
+import { NextRequest, NextResponse } from 'next/server';
+import { getTableColumns } from '@/lib/oracle/db';
+
+interface Params {
+ tableName: string;
+}
+
+interface ApiError {
+ message: string;
+ error?: string;
+}
+
+/**
+ * GET 핸들러 - 테이블의 특정 컬럼 데이터만 가져오기
+ */
+export async function GET(
+ request: NextRequest,
+ { params }: { params: Params }
+): Promise<NextResponse<{ data: any[] } | ApiError>> {
+ const { tableName } = params;
+
+ if (!tableName) {
+ return NextResponse.json(
+ { message: '테이블 이름이 필요합니다.' },
+ { status: 400 }
+ );
+ }
+
+ // 쿼리 파라미터에서 컬럼 목록 가져오기
+ const searchParams = request.nextUrl.searchParams;
+ const columnsParam = searchParams.get('columns');
+
+ if (!columnsParam) {
+ return NextResponse.json(
+ { message: '컬럼 목록이 필요합니다. 예: ?columns=ID,NAME,EMAIL' },
+ { status: 400 }
+ );
+ }
+
+ const columns = columnsParam.split(',').map(col => col.trim());
+
+ try {
+ const data = await getTableColumns(tableName, columns);
+ return NextResponse.json({ data }, { status: 200 });
+ } catch (error: any) {
+ console.error('API 에러:', error);
+ return NextResponse.json(
+ {
+ message: '서버 에러가 발생했습니다.',
+ error: error.message
+ },
+ { status: 500 }
+ );
+ }
+} \ No newline at end of file