feat(api): 관리자 카테고리 CRUD 추가 및 보드에 category 연동\nfeat(api): 공개 보드 목록 category 포함/필터 지원\ndocs(todo): 체크리스트 2.1~2.3 완료 표시

This commit is contained in:
mota
2025-10-13 06:50:05 +09:00
parent 17a071f125
commit 0ecf29bdfe
6 changed files with 67 additions and 5 deletions

View File

@@ -1,8 +1,19 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET() {
export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
const category = searchParams.get("category"); // slug or id
const where: any = {};
if (category) {
if (category.length === 25 || category.length === 24) {
where.categoryId = category;
} else {
where.category = { slug: category };
}
}
const boards = await prisma.board.findMany({
where,
orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
select: {
id: true,
@@ -13,6 +24,7 @@ export async function GET() {
requiresApproval: true,
allowAnonymousPost: true,
isAdultOnly: true,
category: { select: { id: true, name: true, slug: true } },
},
});
return NextResponse.json({ boards });