upd: api ai
Deskripsi : - update banner api ai No Issues
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
|
||||
@@ -6,15 +7,24 @@ import { NextResponse } from "next/server";
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const judul = searchParams.get('q');
|
||||
const page = searchParams.get('p');
|
||||
const judul = searchParams.get('search');
|
||||
const page = searchParams.get('page');
|
||||
const get = searchParams.get('get');
|
||||
const villageId = searchParams.get('desa');
|
||||
const dataSkip = page == null || page == undefined ? 0 : Number(page) * 10 - 10;
|
||||
const active = searchParams.get('active');
|
||||
|
||||
let getFix = 0;
|
||||
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
|
||||
getFix = 10;
|
||||
} else {
|
||||
getFix = Number(get);
|
||||
}
|
||||
|
||||
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
|
||||
|
||||
let kondisi: any = {
|
||||
idVillage: String(villageId),
|
||||
isActive: true,
|
||||
isActive: (active == "false" || active == undefined) ? false : true,
|
||||
title: {
|
||||
contains: (judul == undefined || judul == null) ? "" : judul,
|
||||
mode: "insensitive"
|
||||
@@ -22,10 +32,9 @@ export async function GET(request: Request) {
|
||||
}
|
||||
|
||||
const data = await prisma.bannerImage.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
idVillage: String(villageId)
|
||||
},
|
||||
skip: dataSkip,
|
||||
take: getFix,
|
||||
where: kondisi,
|
||||
orderBy: {
|
||||
createdAt: 'desc'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user