first commit

This commit is contained in:
2025-09-07 22:57:43 +00:00
commit 3bd542adbf
122 changed files with 45056 additions and 0 deletions

59
app/api/notice/route.ts Normal file
View File

@@ -0,0 +1,59 @@
import { PrismaClient } from '../../generated/prisma/client';
const prisma = new PrismaClient();
export async function GET() {
const notices = await prisma.noticeBoard.findMany({
where: {
isDeleted: false,
},
select: {
id: true,
title: true,
pubDate: true,
tag: true,
content: true,
// 필요한 다른 필드들도 추가
},
});
return Response.json(notices);
}
export async function POST(request: Request) {
const { title, content, tag } = await request.json();
const newNotice = await prisma.noticeBoard.create({
data: {
title,
content,
tag,
pubDate: new Date(),
},
});
return Response.json(newNotice, { status: 201 });
}
export async function PUT(request: Request) {
const { id, ...updateData } = await request.json();
const updatedNotice = await prisma.noticeBoard.update({
where: { id },
data: updateData,
});
return Response.json(updatedNotice);
}
export async function DELETE(request: Request) {
const url = new URL(request.url);
const id = url.searchParams.get('id');
if (!id) {
return new Response('ID is required', { status: 400 });
}
const deletedNotice = await prisma.noticeBoard.update({
where: { id },
data: { isDeleted: true },
});
return new Response(JSON.stringify(deletedNotice), { status: 200 });
}