upd: api ai

Deskripsi:
- api ai list pengumuman
- api ai detail pengumuman
- api ai list banner : blm selesai

No Issues
This commit is contained in:
2025-09-15 17:38:13 +08:00
parent cacc8c72b3
commit 648f23c760
4 changed files with 189 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
import { prisma } from "@/module/_global";
import { NextResponse } from "next/server";
// GET ALL BANNER
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const judul = searchParams.get('q');
const page = searchParams.get('p');
const get = searchParams.get('get');
const villageId = searchParams.get('desa');
const dataSkip = page == null || page == undefined ? 0 : Number(page) * 10 - 10;
let kondisi: any = {
idVillage: String(villageId),
isActive: true,
title: {
contains: (judul == undefined || judul == null) ? "" : judul,
mode: "insensitive"
}
}
const data = await prisma.bannerImage.findMany({
where: {
isActive: true,
idVillage: String(villageId)
},
orderBy: {
createdAt: 'desc'
}
});
return NextResponse.json({ success: true, message: "Berhasil mendapatkan banner", data }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan data banner, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}