diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-04-28 02:13:30 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-04-28 02:13:30 +0000 |
| commit | ef4c533ebacc2cdc97e518f30e9a9350004fcdfb (patch) | |
| tree | 345251a3ed0f4429716fa5edaa31024d8f4cb560 /app/api/upload/basicContract/complete/route.ts | |
| parent | 9ceed79cf32c896f8a998399bf1b296506b2cd4a (diff) | |
~20250428 작업사항
Diffstat (limited to 'app/api/upload/basicContract/complete/route.ts')
| -rw-r--r-- | app/api/upload/basicContract/complete/route.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/api/upload/basicContract/complete/route.ts b/app/api/upload/basicContract/complete/route.ts new file mode 100644 index 00000000..6398c5eb --- /dev/null +++ b/app/api/upload/basicContract/complete/route.ts @@ -0,0 +1,37 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { createBasicContractTemplate } from '@/lib/basic-contract/service'; +import { revalidatePath ,revalidateTag} from 'next/cache'; + +export async function POST(request: NextRequest) { + try { + const { templateName,validityPeriod, status, fileName, filePath } = await request.json(); + + if (!templateName || !fileName || !filePath) { + return NextResponse.json({ success: false, error: '필수 정보가 누락되었습니다' }, { status: 400 }); + } + + // DB에 저장 + const { data, error } = await createBasicContractTemplate({ + templateName, + validityPeriod, + status, + fileName, + filePath + }); + + + revalidatePath('/evcp/basic-contract-templates'); + revalidatePath('/'); // 루트 경로 무효화도 시도 + revalidateTag("basic-contract-templates"); + + if (error) { + throw new Error(error); + } + + return NextResponse.json({ success: true, data }); + + } catch (error) { + console.error('템플릿 저장 오류:', error); + return NextResponse.json({ success: false, error: '서버 오류' }, { status: 500 }); + } +}
\ No newline at end of file |
