From 610d3bccf1cb640e2a21df28d8d2a954c2bf337e Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 5 Jun 2025 01:53:35 +0000 Subject: (대표님) 변경사항 0604 - OCR 관련 및 drizzle generated sqls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/sync/workflow/action/route.ts | 44 +++++++++++++++++++++++++++++++++++ app/api/sync/workflow/status/route.ts | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 app/api/sync/workflow/action/route.ts create mode 100644 app/api/sync/workflow/status/route.ts (limited to 'app/api/sync/workflow') diff --git a/app/api/sync/workflow/action/route.ts b/app/api/sync/workflow/action/route.ts new file mode 100644 index 00000000..b6b1a94f --- /dev/null +++ b/app/api/sync/workflow/action/route.ts @@ -0,0 +1,44 @@ +// app/api/sync/workflow/action/route.ts +import { NextRequest, NextResponse } from "next/server" +import { workflowService } from "@/lib/vendor-document-list/workflow-service" +import { getServerSession } from "next-auth" +import { authOptions } from "@/app/api/auth/[...nextauth]/route" + +export async function POST(request: NextRequest) { + try { + const session = await getServerSession(authOptions) + if (!session?.user?.id) { + return NextResponse.json({ error: "Unauthorized" }, { status: 401 }) + } + + const body = await request.json() + const { contractId, targetSystem = 'SWP', action, documents } = body + + if (!contractId || !action) { + return NextResponse.json( + { error: 'Contract ID and action are required' }, + { status: 400 } + ) + } + + const result = await workflowService.executeWorkflowAction( + contractId, + targetSystem, + action, + documents || [], + session.user.id, + session.user.name + ) + + return NextResponse.json(result) + } catch (error) { + console.error('Workflow action failed:', error) + return NextResponse.json( + { + error: 'Workflow action failed', + message: error instanceof Error ? error.message : 'Unknown error' + }, + { status: 500 } + ) + } +} \ No newline at end of file diff --git a/app/api/sync/workflow/status/route.ts b/app/api/sync/workflow/status/route.ts new file mode 100644 index 00000000..a4c5d1d0 --- /dev/null +++ b/app/api/sync/workflow/status/route.ts @@ -0,0 +1,41 @@ +// app/api/sync/workflow/status/route.ts +import { NextRequest, NextResponse } from "next/server" +import { workflowService } from "@/lib/vendor-document-list/workflow-service" +import { getServerSession } from "next-auth" +import { authOptions } from "@/app/api/auth/[...nextauth]/route" + +export async function GET(request: NextRequest) { + try { + const session = await getServerSession(authOptions) + if (!session?.user?.id) { + return NextResponse.json({ error: "Unauthorized" }, { status: 401 }) + } + + const { searchParams } = new URL(request.url) + const contractId = searchParams.get('contractId') + const targetSystem = searchParams.get('targetSystem') || 'SWP' + + if (!contractId) { + return NextResponse.json( + { error: 'Contract ID is required' }, + { status: 400 } + ) + } + + const status = await workflowService.getWorkflowStatus( + Number(contractId), + targetSystem + ) + + return NextResponse.json(status) + } catch (error) { + console.error('Failed to get workflow status:', error) + return NextResponse.json( + { + error: 'Failed to get workflow status', + message: error instanceof Error ? error.message : 'Unknown error' + }, + { status: 500 } + ) + } +} \ No newline at end of file -- cgit v1.2.3