10.6 카테고리 유형/설정 관리(일반/특수/승인/레벨/익명/태그) o
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user