10.5 감사 이력/신고 내역/열람 로그 o

This commit is contained in:
koreacomp5
2025-10-09 18:47:42 +09:00
parent 0d18893374
commit a777c0ab73
5 changed files with 80 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
"use client";
import useSWR from "swr";
const fetcher = (url: string) => fetch(url).then((r) => r.json());
export default function AdminLogsPage() {
const { data: audits } = useSWR<{ logs: any[] }>("/api/admin/audit-logs?limit=100", fetcher);
const { data: reports } = useSWR<{ reports: any[] }>("/api/admin/reports", fetcher);
const { data: views } = useSWR<{ views: any[] }>("/api/admin/views", fetcher);
return (
<div>
<h1>// </h1>
<h2> </h2>
<Table rows={(audits?.logs ?? []).map((x) => ({ a: x.createdAt, b: x.action, c: x.targetType, d: x.targetId }))} headers={["시각", "행위", "대상", "ID"]} />
<h2></h2>
<Table rows={(reports?.reports ?? []).map((x) => ({ a: x.createdAt, b: x.targetType, c: x.reason, d: x.status }))} headers={["시각", "대상", "사유", "상태"]} />
<h2> </h2>
<Table rows={(views?.views ?? []).map((x) => ({ a: x.createdAt, b: x.postId, c: x.userId, d: x.ip }))} headers={["시각", "postId", "userId", "ip"]} />
</div>
);
}
function Table({ headers, rows }: { headers: string[]; rows: { a: any; b: any; c: any; d: any }[] }) {
return (
<table style={{ width: "100%", borderCollapse: "collapse", marginBottom: 16 }}>
<thead>
<tr>
{headers.map((h) => (
<th key={h} style={{ textAlign: "left", borderBottom: "1px solid #eee" }}>{h}</th>
))}
</tr>
</thead>
<tbody>
{rows.map((r, i) => (
<tr key={i}>
<td>{String(r.a)}</td>
<td>{String(r.b)}</td>
<td>{String(r.c)}</td>
<td>{String(r.d)}</td>
</tr>
))}
</tbody>
</table>
);
}

View File

@@ -0,0 +1,14 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
const limit = Number(searchParams.get("limit") || 100);
const logs = await prisma.auditLog.findMany({
orderBy: { createdAt: "desc" },
take: Math.min(limit, 200),
});
return NextResponse.json({ logs });
}

View File

@@ -0,0 +1,9 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET() {
const items = await prisma.report.findMany({ orderBy: { createdAt: "desc" }, take: 200 });
return NextResponse.json({ reports: items });
}

View File

@@ -0,0 +1,9 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET() {
const items = await prisma.postViewLog.findMany({ orderBy: { createdAt: "desc" }, take: 200 });
return NextResponse.json({ views: items });
}

View File

@@ -73,7 +73,7 @@
10.2 게시판 스키마/설정 관리 UI o 10.2 게시판 스키마/설정 관리 UI o
10.3 사용자 검색/정지/권한 변경 o 10.3 사용자 검색/정지/권한 변경 o
10.4 공지/배너 등록 및 노출 설정 o 10.4 공지/배너 등록 및 노출 설정 o
10.5 감사 이력/신고 내역/열람 로그 10.5 감사 이력/신고 내역/열람 로그 o
10.6 카테고리 유형/설정 관리(일반/특수/승인/레벨/익명/태그) 10.6 카테고리 유형/설정 관리(일반/특수/승인/레벨/익명/태그)
[테스트/품질] [테스트/품질]