1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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 });
}
}
|