cc
All checks were successful
deploy-on-main / deploy (push) Successful in 28s

This commit is contained in:
koreacomp5
2025-11-09 20:02:18 +09:00
parent cfbb3d50ee
commit 34e831f738
2 changed files with 0 additions and 35 deletions

View File

@@ -1,15 +0,0 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function DELETE(_: Request, context: { params: Promise<{ id: string }> }) {
const { id } = await context.params;
// 파트너가 참조 중이면 삭제 실패(외래키 제약), 클라이언트에서 안내 필요
try {
await prisma.partnerType.delete({ where: { typeId: id } });
return NextResponse.json({ ok: true });
} catch (e) {
return NextResponse.json({ error: "type_in_use" }, { status: 409 });
}
}

View File

@@ -1,20 +0,0 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { z } from "zod";
export async function GET() {
const types = await prisma.partnerType.findMany({ orderBy: { createdAt: "desc" } });
return NextResponse.json({ types });
}
const createSchema = z.object({ name: z.string().min(1).max(50) });
export async function POST(req: Request) {
const body = await req.json().catch(() => ({}));
const parsed = createSchema.safeParse(body);
if (!parsed.success) return NextResponse.json({ error: parsed.error.flatten() }, { status: 400 });
const type = await prisma.partnerType.create({ data: { name: parsed.data.name } });
return NextResponse.json({ type }, { status: 201 });
}