- 新增许可证服务器 (license-server/) - 新增 Agent 部署模块 (flnxi-agent/) - 添加许可证验证和激活页面 - 添加 Harbor 镜像同步脚本 - 更新素材系统支持许可证验证
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { getAdminSession } from '@/lib/auth';
|
|
import { prisma } from '@/lib/db';
|
|
import { AlertStatus, Prisma } from '@prisma/client';
|
|
|
|
export async function GET(request: NextRequest) {
|
|
const session = await getAdminSession();
|
|
if (!session) {
|
|
return NextResponse.json({ error: '未授权' }, { status: 401 });
|
|
}
|
|
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const status = searchParams.get('status') || 'pending';
|
|
|
|
let where: Prisma.AlertWhereInput = {};
|
|
if (status === 'resolved') {
|
|
where = { status: { in: [AlertStatus.resolved, AlertStatus.ignored] } };
|
|
} else if (status !== 'all') {
|
|
where = { status: AlertStatus.pending };
|
|
}
|
|
|
|
const alerts = await prisma.alert.findMany({
|
|
where,
|
|
orderBy: { createdAt: 'desc' },
|
|
include: {
|
|
license: {
|
|
select: {
|
|
licenseKey: true,
|
|
customer: { select: { companyName: true } },
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
return NextResponse.json({ alerts });
|
|
} catch (error) {
|
|
console.error('获取告警列表失败:', error);
|
|
return NextResponse.json({ error: '服务器错误' }, { status: 500 });
|
|
}
|
|
}
|