10.6 카테고리 유형/설정 관리(일반/특수/승인/레벨/익명/태그) o

This commit is contained in:
koreacomp5
2025-10-09 18:50:02 +09:00
parent a777c0ab73
commit c28698cd5c
3 changed files with 17 additions and 2 deletions

View File

@@ -5,9 +5,15 @@ export async function PATCH(req: Request, context: { params: Promise<{ id: strin
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"]) {
for (const k of ["name", "slug", "description", "sortOrder", "readLevel", "writeLevel", "allowAnonymousPost", "allowSecretComment", "requiresApproval", "status", "type", "isAdultOnly"]) {
if (k in body) data[k] = body[k];
}
if ("requiredTags" in body) {
try { data.requiredTags = typeof body.requiredTags === "string" ? JSON.parse(body.requiredTags) : body.requiredTags; } catch { /* ignore invalid */ }
}
if ("requiredFields" in body) {
try { data.requiredFields = typeof body.requiredFields === "string" ? JSON.parse(body.requiredFields) : body.requiredFields; } catch { /* ignore invalid */ }
}
const updated = await prisma.board.update({ where: { id }, data });
return NextResponse.json({ board: updated });
}