Merge pull request 'amalia/10-des-25' (#70) from amalia/10-des-25 into main

Reviewed-on: http://wibugit.wibudev.com/wibu/jenna-mcp/pulls/70
This commit is contained in:
2025-12-10 11:45:12 +08:00

View File

@@ -1,6 +1,6 @@
import Elysia, { t } from "elysia" import Elysia, { t } from "elysia"
import type { StatusPengaduan } from "generated/prisma" import type { StatusPengaduan } from "generated/prisma"
import _ from "lodash" import _, { head } from "lodash"
import { v4 as uuidv4 } from "uuid" import { v4 as uuidv4 } from "uuid"
import { getLastUpdated } from "../lib/get-last-updated" import { getLastUpdated } from "../lib/get-last-updated"
import { mimeToExtension } from "../lib/mimetypeToExtension" import { mimeToExtension } from "../lib/mimetypeToExtension"
@@ -131,14 +131,12 @@ const PengaduanRoute = new Elysia({
}) })
if (!cariCategory) { if (!cariCategory) {
idCategoryFix = "lainnya" idCategoryFix = "lainnya"
} else { } else {
idCategoryFix = cariCategory.id idCategoryFix = cariCategory.id
} }
console.log(cariCategory, kategoriId)
} }
} else { } else {
@@ -480,43 +478,44 @@ const PengaduanRoute = new Elysia({
tags: ["mcp"] tags: ["mcp"]
} }
}) })
.get("/", async ({ query }) => { .get("/", async ({ query, headers }) => {
const { take, page, search, phone } = query // const { take, page, search } = query
const skip = !page ? 0 : (Number(page) - 1) * (!take ? 10 : Number(take)) const phone = headers['x-phone'] || ""
// const skip = !page ? 0 : (Number(page) - 1) * (!take ? 10 : Number(take))
const data = await prisma.pengaduan.findMany({ const data = await prisma.pengaduan.findMany({
skip, // skip,
take: !take ? 10 : Number(take), // take: !take ? 10 : Number(take),
orderBy: { orderBy: {
createdAt: "asc" createdAt: "asc"
}, },
where: { where: {
isActive: true, isActive: true,
OR: [ // OR: [
{ // {
title: { // title: {
contains: search ?? "", // contains: search ?? "",
mode: "insensitive" // mode: "insensitive"
}, // },
}, // },
{ // {
noPengaduan: { // noPengaduan: {
contains: search ?? "", // contains: search ?? "",
mode: "insensitive" // mode: "insensitive"
}, // },
}, // },
{ // {
detail: { // detail: {
contains: search ?? "", // contains: search ?? "",
mode: "insensitive" // mode: "insensitive"
}, // },
} // }
], // ],
AND: { // AND: {
Warga: { // Warga: {
phone: phone // phone: phone
} // }
} // }
}, },
select: { select: {
id: true, id: true,
@@ -551,12 +550,11 @@ const PengaduanRoute = new Elysia({
return dataFix return dataFix
}, { }, {
query: t.Object({ // query: t.Object({
take: t.String({ optional: true }), // take: t.String({ optional: true }),
page: t.String({ optional: true }), // page: t.String({ optional: true }),
search: t.String({ optional: true }), // search: t.String({ optional: true }),
phone: t.String({ minLength: 11, error: "phone harus diisi" }), // }),
}),
detail: { detail: {
summary: "List Pengaduan Warga By Phone", summary: "List Pengaduan Warga By Phone",
description: `tool untuk mendapatkan list pengaduan warga by phone`, description: `tool untuk mendapatkan list pengaduan warga by phone`,