diff options
Diffstat (limited to 'app/api/vendor-responses/update-comment')
| -rw-r--r-- | app/api/vendor-responses/update-comment/route.ts | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/app/api/vendor-responses/update-comment/route.ts b/app/api/vendor-responses/update-comment/route.ts deleted file mode 100644 index f1e4c487..00000000 --- a/app/api/vendor-responses/update-comment/route.ts +++ /dev/null @@ -1,62 +0,0 @@ -// app/api/vendor-responses/update-comment/route.ts -import { NextRequest, NextResponse } from "next/server"; -import db from "@/db/db"; -import { vendorAttachmentResponses } from "@/db/schema"; - -import { getServerSession } from "next-auth/next" -import { authOptions } from "@/app/api/auth/[...nextauth]/route" -import { eq } from "drizzle-orm"; - -export async function POST(request: NextRequest) { - try { - // 인증 확인 - const session = await getServerSession(authOptions); - if (!session?.user?.id) { - return NextResponse.json( - { message: "인증이 필요합니다." }, - { status: 401 } - ); - } - - const body = await request.json(); - const { responseId, responseComment, vendorComment } = body; - - if (!responseId) { - return NextResponse.json( - { message: "응답 ID가 필요합니다." }, - { status: 400 } - ); - } - - // 코멘트만 업데이트 - const [updatedResponse] = await db - .update(vendorAttachmentResponses) - .set({ - responseComment, - vendorComment, - updatedAt: new Date(), - updatedBy:Number(session?.user.id) - }) - .where(eq(vendorAttachmentResponses.id, parseInt(responseId))) - .returning(); - - if (!updatedResponse) { - return NextResponse.json( - { message: "응답을 찾을 수 없습니다." }, - { status: 404 } - ); - } - - return NextResponse.json({ - message: "코멘트가 성공적으로 업데이트되었습니다.", - response: updatedResponse, - }); - - } catch (error) { - console.error("Comment update error:", error); - return NextResponse.json( - { message: "코멘트 업데이트 중 오류가 발생했습니다." }, - { status: 500 } - ); - } -}
\ No newline at end of file |
