API & UI Admin Menu Ekonomi, Submenu PADesa
This commit is contained in:
@@ -6,36 +6,36 @@ import apbDesaDelete from "./del";
|
||||
import apbDesaUpdate from "./updt";
|
||||
|
||||
const APBDesa = new Elysia({
|
||||
prefix: "/apbdesa",
|
||||
tags: ["Ekonomi/Pendapatan Asli Desa/APB Desa"],
|
||||
prefix: "/apbdesa",
|
||||
tags: ["Ekonomi/Pendapatan Asli Desa/APB Desa"],
|
||||
})
|
||||
.get("/find-many", apbDesaFindMany)
|
||||
.get("/:id", async (context) => {
|
||||
.get("/find-many", apbDesaFindMany)
|
||||
.get("/:id", async (context) => {
|
||||
const response = await apbDesaFindUnique(new Request(context.request));
|
||||
return response;
|
||||
})
|
||||
.post("/create", apbDesaCreate, {
|
||||
})
|
||||
.post("/create", apbDesaCreate, {
|
||||
body: t.Object({
|
||||
tahun: t.Number(),
|
||||
pendapatanIds: t.Array(t.String()),
|
||||
belanjaIds: t.Array(t.String()),
|
||||
pembiayaanIds: t.Array(t.String()),
|
||||
}),
|
||||
})
|
||||
.delete("/del/:id", apbDesaDelete)
|
||||
.put(
|
||||
"/:id",
|
||||
async (context) => {
|
||||
const response = await apbDesaUpdate(context);
|
||||
return response;
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
tahun: t.Number(),
|
||||
pendapatanIds: t.Array(t.String()),
|
||||
belanjaIds: t.Array(t.String()),
|
||||
pembiayaanIds: t.Array(t.String()),
|
||||
}),
|
||||
})
|
||||
.delete("/delete/:id", apbDesaDelete)
|
||||
.put(
|
||||
"/:id",
|
||||
async (context) => {
|
||||
const response = await apbDesaUpdate(context);
|
||||
return response;
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
tahun: t.Number(),
|
||||
pendapatanIds: t.Array(t.String()),
|
||||
belanjaIds: t.Array(t.String()),
|
||||
pembiayaanIds: t.Array(t.String()),
|
||||
}),
|
||||
}),
|
||||
}
|
||||
);
|
||||
);
|
||||
export default APBDesa;
|
||||
|
||||
@@ -41,18 +41,19 @@ export default async function apbDesaUpdate(context: Context) {
|
||||
const updated = await prisma.apbDesa.update({
|
||||
where: { id },
|
||||
data: {
|
||||
tahun,
|
||||
pendapatan: {
|
||||
connect: pendapatanIds.map((id) => ({ id })),
|
||||
},
|
||||
belanja: {
|
||||
connect: belanjaIds.map((id) => ({ id })),
|
||||
},
|
||||
pembiayaan: {
|
||||
connect: pembiayaanIds.map((id) => ({ id })),
|
||||
},
|
||||
tahun,
|
||||
pendapatan: {
|
||||
set: pendapatanIds.map((id) => ({ id })),
|
||||
},
|
||||
belanja: {
|
||||
set: belanjaIds.map((id) => ({ id })),
|
||||
},
|
||||
pembiayaan: {
|
||||
set: pembiayaanIds.map((id) => ({ id })),
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success update APB Desa",
|
||||
|
||||
Reference in New Issue
Block a user