upd: api jenna ai
Deskripsi: - detail post pengaduan - detail post pengajuan surat No Issues
This commit is contained in:
@@ -151,18 +151,10 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
.get("/detail", async ({ query }) => {
|
||||
const { nomerPengajuan } = query
|
||||
console.log(nomerPengajuan, query)
|
||||
const { id } = query
|
||||
const data = await prisma.pelayananAjuan.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
{
|
||||
noPengajuan: nomerPengajuan
|
||||
},
|
||||
{
|
||||
id: nomerPengajuan
|
||||
}
|
||||
]
|
||||
id: id
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -192,6 +184,17 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
if (!data) {
|
||||
const datafix = {
|
||||
pengajuan: {},
|
||||
history: [],
|
||||
warga: {},
|
||||
syaratDokumen: [],
|
||||
dataText: [],
|
||||
}
|
||||
return datafix
|
||||
}
|
||||
|
||||
const dataSurat = await prisma.suratPelayanan.findFirst({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
@@ -303,16 +306,14 @@ const PelayananRoute = new Elysia({
|
||||
dataText: dataTextFix,
|
||||
}
|
||||
|
||||
console.log(datafix)
|
||||
return datafix
|
||||
}, {
|
||||
query: t.Object({
|
||||
nomerPengajuan: t.String({ minLength: 1, error: "nomer pengajuan harus diisi" }),
|
||||
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||
}),
|
||||
detail: {
|
||||
summary: "Detail Ajuan Pelayanan Surat by Nomer Pengajuan",
|
||||
description: `tool untuk mendapatkan detail ajuan pelayanan surat berdasarkan nomer pengajuan`,
|
||||
tags: ["mcp"]
|
||||
summary: "Detail Ajuan Pelayanan Surat by ID",
|
||||
description: `tool untuk mendapatkan detail ajuan pelayanan surat berdasarkan id`,
|
||||
}
|
||||
})
|
||||
.post("/create", async ({ body, headers }) => {
|
||||
@@ -505,6 +506,171 @@ const PelayananRoute = new Elysia({
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
.post("/detail-data", async ({ body }) => {
|
||||
const { nomerPengajuan } = body
|
||||
const data = await prisma.pelayananAjuan.findFirst({
|
||||
where: {
|
||||
noPengajuan: nomerPengajuan
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
noPengajuan: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
CategoryPelayanan: {
|
||||
select: {
|
||||
name: true,
|
||||
dataText: true,
|
||||
syaratDokumen: true,
|
||||
}
|
||||
},
|
||||
Warga: {
|
||||
select: {
|
||||
name: true,
|
||||
phone: true,
|
||||
_count: {
|
||||
select: {
|
||||
Pengaduan: true,
|
||||
PelayananAjuan: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
if (!data) {
|
||||
return { success: false, message: "Data tidak ditemukan" }
|
||||
}
|
||||
|
||||
const dataSurat = await prisma.suratPelayanan.findFirst({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
isActive: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
idCategory: true,
|
||||
}
|
||||
})
|
||||
|
||||
const dataSyarat = await prisma.syaratDokumenPelayanan.findMany({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
isActive: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
jenis: true,
|
||||
value: true,
|
||||
}
|
||||
})
|
||||
|
||||
const dataText = await prisma.dataTextPelayanan.findMany({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
isActive: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
value: true,
|
||||
jenis: true,
|
||||
}
|
||||
})
|
||||
const syaratDokumen = (data?.CategoryPelayanan?.syaratDokumen ?? []) as {
|
||||
name: string;
|
||||
desc: string;
|
||||
}[];
|
||||
|
||||
const dataSyaratFix = dataSyarat.map((item) => {
|
||||
const desc = syaratDokumen.find((v) => v.name == item.jenis)?.desc
|
||||
return {
|
||||
id: item.id,
|
||||
jenis: desc,
|
||||
value: item.value,
|
||||
}
|
||||
})
|
||||
|
||||
const dataTextFix = dataText.map((item) => {
|
||||
const desc = data?.CategoryPelayanan?.dataText.find((v) => v == item.jenis)
|
||||
return {
|
||||
id: item.id,
|
||||
jenis: item.jenis,
|
||||
value: item.value,
|
||||
}
|
||||
})
|
||||
|
||||
const dataHistory = await prisma.historyPelayanan.findMany({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
idUser: true,
|
||||
User: {
|
||||
select: {
|
||||
name: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const dataHistoryFix = dataHistory.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
deskripsi: item.deskripsi,
|
||||
status: item.status,
|
||||
createdAt: item.createdAt,
|
||||
idUser: item.idUser,
|
||||
nameUser: item.User?.name,
|
||||
}
|
||||
})
|
||||
|
||||
const warga = {
|
||||
name: data?.Warga?.name,
|
||||
phone: data?.Warga?.phone,
|
||||
pengaduan: data?.Warga?._count.Pengaduan,
|
||||
pelayanan: data?.Warga?._count.PelayananAjuan,
|
||||
}
|
||||
|
||||
const dataPengajuan = {
|
||||
id: data?.id,
|
||||
noPengajuan: data?.noPengajuan,
|
||||
category: data?.CategoryPelayanan.name,
|
||||
status: data?.status,
|
||||
createdAt: data?.createdAt,
|
||||
updatedAt: data?.updatedAt,
|
||||
idSurat: dataSurat?.id,
|
||||
}
|
||||
|
||||
const datafix = {
|
||||
pengajuan: dataPengajuan,
|
||||
history: dataHistoryFix,
|
||||
warga: warga,
|
||||
syaratDokumen: dataSyaratFix,
|
||||
dataText: dataTextFix,
|
||||
}
|
||||
|
||||
return datafix
|
||||
|
||||
}, {
|
||||
body: t.Object({
|
||||
nomerPengajuan: t.String({
|
||||
description: "Nomor pengajuan pelayanan surat yang ingin diakses.",
|
||||
examples: ["PS-101225-001", "PS-101225-002"],
|
||||
error: "Nomor pengajuan harus diisi"
|
||||
})
|
||||
}),
|
||||
detail: {
|
||||
summary: "Detail Pengajuan Pelayanan Surat By Nomor Pengajuan",
|
||||
description: `tool untuk mendapatkan detail pengajuan pelayanan surat berdasarkan nomor pengajuan`,
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
.post("/update-status", async ({ body }) => {
|
||||
const { id, status, keterangan, idUser, noSurat } = body
|
||||
let deskripsi = ""
|
||||
|
||||
Reference in New Issue
Block a user