10.3 사용자 검색/정지/권한 변경 o

This commit is contained in:
koreacomp5
2025-10-09 18:31:37 +09:00
parent 4167fcb332
commit 375f4c5681
5 changed files with 148 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
const q = searchParams.get("q") || "";
const users = await prisma.user.findMany({
where: q
? {
OR: [
{ nickname: { contains: q } },
{ phone: { contains: q } },
{ name: { contains: q } },
],
}
: {},
orderBy: { createdAt: "desc" },
select: {
userId: true,
nickname: true,
name: true,
phone: true,
status: true,
authLevel: true,
createdAt: true,
userRoles: { select: { role: { select: { name: true } } } },
},
take: 100,
});
const items = users.map((u) => ({
...u,
roles: u.userRoles.map((r) => r.role.name),
}));
return NextResponse.json({ users: items });
}