diff options
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 |
