10.2 게시판 스키마/설정 관리 UI o

This commit is contained in:
koreacomp5
2025-10-09 18:25:06 +09:00
parent fee16e68f2
commit 4167fcb332
4 changed files with 116 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function PATCH(req: Request, context: { params: Promise<{ id: string }> }) {
const { id } = await context.params;
const body = await req.json().catch(() => ({}));
const data: any = {};
for (const k of ["name", "slug", "description", "sortOrder", "readLevel", "writeLevel", "allowAnonymousPost", "allowSecretComment", "requiresApproval", "status"]) {
if (k in body) data[k] = body[k];
}
const updated = await prisma.board.update({ where: { id }, data });
return NextResponse.json({ board: updated });
}

View File

@@ -0,0 +1,25 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET() {
const boards = await prisma.board.findMany({
orderBy: { sortOrder: "asc" },
select: {
id: true,
name: true,
slug: true,
description: true,
sortOrder: true,
readLevel: true,
writeLevel: true,
allowAnonymousPost: true,
allowSecretComment: true,
requiresApproval: true,
type: true,
status: true,
},
});
return NextResponse.json({ boards });
}