fix: 定时任务修复+管理后台Task7支持 (Task4外键修复, Task7管理员邮箱动态查询, Task5限流防护, Task7加入SCRIPT_MAP)

This commit is contained in:
ZhuiGuangAI Dev
2026-05-30 18:03:48 +08:00
parent 4d5e7266b5
commit 10d1acb305
56 changed files with 2779 additions and 135 deletions
+13 -1
View File
@@ -53,9 +53,21 @@ export async function GET(request: Request) {
}
export async function POST(request: Request) {
const authError = await requireAdmin();
if (authError) return authError;
try {
const body = await request.json();
if (!body.name || !body.websiteUrl || !body.categoryId) {
return NextResponse.json({ error: "名称、网址、分类ID不能为空" }, { status: 400 });
}
const existingCategory = await prisma.category.findUnique({ where: { id: body.categoryId } });
if (!existingCategory) {
return NextResponse.json({ error: "分类ID不存在" }, { status: 400 });
}
let slug = body.slug || body.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "tool";
const existing = await prisma.tool.findUnique({ where: { slug } });
if (existing) {
@@ -66,7 +78,7 @@ export async function POST(request: Request) {
data: {
name: body.name,
slug,
categoryId: body.categoryId || 1,
categoryId: body.categoryId,
description: body.description || "",
logoUrl: body.logoUrl || null,
websiteUrl: body.websiteUrl || "",