Merge pull request 'Fix QC Kak Inno Mobile Done' (#47) from nico/1-jan-26 into staggingweb
Reviewed-on: http://wibugit.wibudev.com/wibu/desa-darmasaba/pulls/47
This commit is contained in:
@@ -4,7 +4,11 @@ import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function apbdesFindMany(context: Context) {
|
||||
const { page = "1", limit = "10", tahun } = context.query as {
|
||||
const {
|
||||
page = "1",
|
||||
limit = "10",
|
||||
tahun,
|
||||
} = context.query as {
|
||||
page?: string;
|
||||
limit?: string;
|
||||
tahun?: string;
|
||||
@@ -12,11 +16,24 @@ export default async function apbdesFindMany(context: Context) {
|
||||
|
||||
const pageNumber = Math.max(1, parseInt(page, 10) || 1);
|
||||
const limitNumber = Math.min(100, Math.max(1, parseInt(limit, 10) || 10));
|
||||
|
||||
const search = (context.query.search as string) || "";
|
||||
const skip = (pageNumber - 1) * limitNumber;
|
||||
|
||||
try {
|
||||
const where: any = { isActive: true };
|
||||
|
||||
if (search) {
|
||||
where.OR = [
|
||||
{ name: { contains: search, mode: "insensitive" } },
|
||||
{ deskripsi: { contains: search, mode: "insensitive" } },
|
||||
];
|
||||
|
||||
// Kalau search berupa angka, anggap itu tahun
|
||||
if (!isNaN(Number(search))) {
|
||||
where.OR.push({ tahun: Number(search) });
|
||||
}
|
||||
}
|
||||
|
||||
if (tahun) {
|
||||
where.tahun = parseInt(tahun, 10);
|
||||
}
|
||||
@@ -54,4 +71,4 @@ export default async function apbdesFindMany(context: Context) {
|
||||
message: "Gagal mengambil daftar APBDes",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,9 +72,6 @@ async function pengajarFindMany(context: Context) {
|
||||
})
|
||||
]);
|
||||
|
||||
console.log('Fetched pengajar data count:', data.length);
|
||||
console.log('Total pengajar count:', total);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success fetch pengajar with pagination",
|
||||
|
||||
Reference in New Issue
Block a user