upd: api jenna ai
Deskripsi: - detail post pengaduan - detail post pengajuan surat No Issues
This commit is contained in:
@@ -372,18 +372,11 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
.get("/detail", async ({ query }) => {
|
||||
const { nomerPengaduan } = query
|
||||
console.log(nomerPengaduan, query)
|
||||
const { id } = query
|
||||
|
||||
const data = await prisma.pengaduan.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
{
|
||||
noPengaduan: nomerPengaduan
|
||||
}, {
|
||||
id: nomerPengaduan
|
||||
}
|
||||
]
|
||||
id: id
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -418,6 +411,16 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
if (!data) {
|
||||
const datafix = {
|
||||
pengaduan: {},
|
||||
history: [],
|
||||
warga: {},
|
||||
}
|
||||
|
||||
return datafix
|
||||
}
|
||||
|
||||
const dataHistory = await prisma.historyPengaduan.findMany({
|
||||
where: {
|
||||
idPengaduan: data?.id,
|
||||
@@ -470,15 +473,13 @@ const PengaduanRoute = new Elysia({
|
||||
history: dataHistoryFix,
|
||||
warga: warga,
|
||||
}
|
||||
console.log(datafix)
|
||||
|
||||
return datafix
|
||||
|
||||
}, {
|
||||
detail: {
|
||||
summary: "Detail Pengaduan Warga by Nomer Pengaduan",
|
||||
description: `tool untuk mendapatkan detail pengaduan warga / history pengaduan / mengecek status pengaduan berdasarkan nomer Pengaduan`,
|
||||
tags: ["mcp"]
|
||||
summary: "Detail Pengaduan Warga By ID",
|
||||
description: `tool untuk mendapatkan detail pengaduan warga / history pengaduan / mengecek status pengaduan berdasarkan id pengaduan`,
|
||||
}
|
||||
})
|
||||
.get("/", async ({ query, headers }) => {
|
||||
@@ -887,6 +888,118 @@ const PengaduanRoute = new Elysia({
|
||||
description: "Tool untuk delete file Seafile",
|
||||
},
|
||||
})
|
||||
.post("/detail-data", async ({ body }) => {
|
||||
const { nomerPengaduan } = body
|
||||
|
||||
const data = await prisma.pengaduan.findFirst({
|
||||
where: {
|
||||
noPengaduan: nomerPengaduan
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
noPengaduan: true,
|
||||
title: true,
|
||||
detail: true,
|
||||
location: true,
|
||||
image: true,
|
||||
idCategory: true,
|
||||
idWarga: true,
|
||||
status: true,
|
||||
keterangan: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
CategoryPengaduan: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
},
|
||||
Warga: {
|
||||
select: {
|
||||
name: true,
|
||||
phone: true,
|
||||
_count: {
|
||||
select: {
|
||||
Pengaduan: true,
|
||||
PelayananAjuan: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (!data) {
|
||||
return { success: false, message: "Data tidak ditemukan" };
|
||||
}
|
||||
|
||||
const dataHistory = await prisma.historyPengaduan.findMany({
|
||||
where: {
|
||||
idPengaduan: data?.id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
idUser: true,
|
||||
User: {
|
||||
select: {
|
||||
name: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const dataHistoryFix = dataHistory.map((item: any) => ({
|
||||
..._.omit(item, ["User", "createdAt"]),
|
||||
nameUser: item.User?.name,
|
||||
createdAt: item.createdAt
|
||||
}))
|
||||
|
||||
|
||||
const warga = {
|
||||
name: data?.Warga?.name,
|
||||
phone: data?.Warga?.phone,
|
||||
pengaduan: data?.Warga?._count.Pengaduan,
|
||||
pelayanan: data?.Warga?._count.PelayananAjuan,
|
||||
}
|
||||
|
||||
const dataPengaduan = {
|
||||
id: data?.id,
|
||||
noPengaduan: data?.noPengaduan,
|
||||
title: data?.title,
|
||||
detail: data?.detail,
|
||||
location: data?.location,
|
||||
image: data?.image,
|
||||
category: data?.CategoryPengaduan.name,
|
||||
status: data?.status,
|
||||
keterangan: data?.keterangan,
|
||||
createdAt: data?.createdAt,
|
||||
updatedAt: data?.updatedAt,
|
||||
}
|
||||
|
||||
const datafix = {
|
||||
pengaduan: dataPengaduan,
|
||||
history: dataHistoryFix,
|
||||
warga: warga,
|
||||
}
|
||||
|
||||
return datafix
|
||||
}, {
|
||||
body: t.Object({
|
||||
nomerPengaduan: t.String({
|
||||
description: "Nomer pengaduan yg ingin diakses",
|
||||
examples: ["PGD-101225-001", "PGD-101225-002"],
|
||||
error: "Nomer pengaduan harus diisi",
|
||||
}),
|
||||
}),
|
||||
detail: {
|
||||
summary: "Detail Pengaduan Warga By Nomor Pengaduan",
|
||||
description: `tool untuk mendapatkan detail data pengaduan berdasarkan nomor pengaduan`,
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
export default PengaduanRoute
|
||||
|
||||
Reference in New Issue
Block a user