Create & Read Data :
* Menu Desa : Berita & Pengumuman * Kesehatan : Data Kesehatan Warga => Fasilitas Kesehatan
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.DokterdanTenagaMedisGetPayload<{
|
||||
select: {
|
||||
name: true
|
||||
specialist: true
|
||||
jadwal: true
|
||||
}
|
||||
}>
|
||||
|
||||
async function dokterDantenagamedisCreate(context: Context) {
|
||||
const body = context.body as FormCreate
|
||||
|
||||
await prisma.dokterdanTenagaMedis.create({
|
||||
data: {
|
||||
name: body.name,
|
||||
specialist: body.specialist,
|
||||
jadwal: body.jadwal,
|
||||
}
|
||||
})
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create dokter dan tenaga medis",
|
||||
data: {
|
||||
...body
|
||||
}
|
||||
}
|
||||
}
|
||||
export default dokterDantenagamedisCreate
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function dokterDantenagamedisFindMany() {
|
||||
const res = await prisma.dokterdanTenagaMedis.findMany();
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import dokterDantenagamedisFindMany from "./find-many";
|
||||
import dokterDantenagamedisCreate from "./create";
|
||||
|
||||
const DokterDantenagamedis = new Elysia({
|
||||
prefix: "/dokterdantenagamedis",
|
||||
tags: ["Dokter dan Tenaga Medis"],
|
||||
})
|
||||
.get("/find-many", dokterDantenagamedisFindMany)
|
||||
.post("/create", dokterDantenagamedisCreate, {
|
||||
body: t.Object({
|
||||
name: t.String(),
|
||||
specialist: t.String(),
|
||||
jadwal: t.String(),
|
||||
})
|
||||
})
|
||||
|
||||
export default DokterDantenagamedis
|
||||
@@ -0,0 +1,29 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.FasilitasPendukungGetPayload<{
|
||||
select: {
|
||||
content: true
|
||||
}
|
||||
}>
|
||||
|
||||
async function FasilitasPendukungCreate(context: Context){
|
||||
const body = context.body as FormCreate
|
||||
|
||||
await prisma.fasilitasPendukung.create({
|
||||
data: {
|
||||
|
||||
content: body.content
|
||||
}
|
||||
})
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create fasilitas pendukung",
|
||||
data: {
|
||||
...body
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default FasilitasPendukungCreate
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function fasilitasPendukungFindMany() {
|
||||
const res = await prisma.fasilitasPendukung.findMany();
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import fasilitasPendukungFindMany from "./find-many";
|
||||
import FasilitasPendukungCreate from "./create";
|
||||
|
||||
const FasilitasPendukung = new Elysia({
|
||||
prefix: "/fasilitaspendukung",
|
||||
tags: ["Fasilitas Pendukung"],
|
||||
})
|
||||
.get("/find-many", fasilitasPendukungFindMany)
|
||||
.post("/create", FasilitasPendukungCreate, {
|
||||
body: t.Object({
|
||||
content: t.String(),
|
||||
}),
|
||||
});
|
||||
|
||||
export default FasilitasPendukung;
|
||||
@@ -0,0 +1,31 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.InformasiUmumGetPayload<{
|
||||
select: {
|
||||
fasilitas: true
|
||||
alamat: true
|
||||
jamOperasional: true
|
||||
}
|
||||
}>
|
||||
async function informasiUmumCreate(context: Context) {
|
||||
const body = context.body as FormCreate
|
||||
|
||||
await prisma.informasiUmum.create({
|
||||
data: {
|
||||
fasilitas: body.fasilitas,
|
||||
alamat: body.alamat,
|
||||
jamOperasional: body.jamOperasional,
|
||||
}
|
||||
})
|
||||
return{
|
||||
success: true,
|
||||
message: "Success create informasi umum",
|
||||
data: {
|
||||
...body
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default informasiUmumCreate
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function informasiUmumFindMany() {
|
||||
const res = await prisma.informasiUmum.findMany();
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import informasiUmumFindMany from "./find-many";
|
||||
import informasiUmumCreate from "./create";
|
||||
|
||||
const InformasiUmum = new Elysia({
|
||||
prefix: "/informasiumum",
|
||||
tags: ["Informasi Umum"],
|
||||
})
|
||||
.get("/find-many", informasiUmumFindMany)
|
||||
.post("/create", informasiUmumCreate, {
|
||||
body: t.Object({
|
||||
fasilitas: t.String(),
|
||||
alamat: t.String(),
|
||||
jamOperasional: t.String(),
|
||||
}),
|
||||
});
|
||||
|
||||
export default InformasiUmum;
|
||||
@@ -0,0 +1,28 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.LayananUnggulanGetPayload<{
|
||||
select: {
|
||||
content: true
|
||||
}
|
||||
}>
|
||||
|
||||
async function layananUnggulanCreate(context: Context) {
|
||||
const body = context.body as FormCreate
|
||||
|
||||
await prisma.layananUnggulan.create({
|
||||
data: {
|
||||
content: body.content
|
||||
}
|
||||
})
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create layanan unggulan",
|
||||
data: {
|
||||
...body
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default layananUnggulanCreate
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function layananUnggulanFindMany() {
|
||||
const res = await prisma.layananUnggulan.findMany();
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import layananUnggulanCreate from "./create";
|
||||
import layananUnggulanFindMany from "./find-many";
|
||||
|
||||
const LayananUnggulan = new Elysia({
|
||||
prefix: "/layananunggulan",
|
||||
tags: ["Layanan Unggulan"]
|
||||
})
|
||||
|
||||
.get("/find-many", layananUnggulanFindMany)
|
||||
.post("/create", layananUnggulanCreate, {
|
||||
body: t.Object({
|
||||
content: t.String()
|
||||
})
|
||||
})
|
||||
|
||||
export default LayananUnggulan
|
||||
@@ -0,0 +1,28 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.ProsedurPendaftaranGetPayload<{
|
||||
select: {
|
||||
content: true
|
||||
}
|
||||
}>
|
||||
|
||||
async function prosedurPendaftaranCreate(context: Context) {
|
||||
const body = context.body as FormCreate
|
||||
|
||||
await prisma.prosedurPendaftaran.create({
|
||||
data: {
|
||||
content: body.content
|
||||
}
|
||||
})
|
||||
return{
|
||||
success: true,
|
||||
message: "Success create prosedur pendaftaran",
|
||||
data: {
|
||||
...body
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default prosedurPendaftaranCreate
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function prosedurPendaftaranFindMany() {
|
||||
const res = await prisma.prosedurPendaftaran.findMany();
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import prosedurPendaftaranFindMany from "./find-many";
|
||||
import prosedurPendaftaranCreate from "./create";
|
||||
|
||||
const ProsedurPendaftaran = new Elysia({
|
||||
prefix: "/prosedurpendaftaran",
|
||||
tags: ["Prosedur Pendaftaran"],
|
||||
})
|
||||
.get("/find-many", prosedurPendaftaranFindMany)
|
||||
.post("/create", prosedurPendaftaranCreate, {
|
||||
body: t.Object({
|
||||
content: t.String(),
|
||||
}),
|
||||
});
|
||||
export default ProsedurPendaftaran;
|
||||
@@ -0,0 +1,30 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.TarifDanLayananGetPayload<{
|
||||
select: {
|
||||
layanan: true
|
||||
tarif: true
|
||||
}
|
||||
}>
|
||||
|
||||
async function tarifdanlayananCreate(context: Context) {
|
||||
const body = context.body as FormCreate
|
||||
|
||||
await prisma.tarifDanLayanan.create({
|
||||
data: {
|
||||
layanan: body.layanan,
|
||||
tarif: body.tarif,
|
||||
}
|
||||
})
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create tarif dan layanan",
|
||||
data: {
|
||||
...body
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default tarifdanlayananCreate
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function tarifdanlayananFindMany() {
|
||||
const res = await prisma.tarifDanLayanan.findMany();
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import tarifdanlayananFindMany from "./find-many";
|
||||
import tarifdanlayananCreate from "./create";
|
||||
|
||||
|
||||
const TarifDanLayanan = new Elysia({
|
||||
prefix: "/tarifdanlayanan",
|
||||
tags: ["Tarif dan Layanan"]
|
||||
})
|
||||
.get("/find-many", tarifdanlayananFindMany)
|
||||
.post("/create", tarifdanlayananCreate, {
|
||||
body: t.Object({
|
||||
layanan: t.String(),
|
||||
tarif: t.String(),
|
||||
})
|
||||
})
|
||||
|
||||
export default TarifDanLayanan;
|
||||
20
src/app/api/[[...slugs]]/_lib/kesehatan/index.ts
Normal file
20
src/app/api/[[...slugs]]/_lib/kesehatan/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import Elysia from "elysia";
|
||||
import InformasiUmum from "./data_kesehatan_warga/fasilitas_kesehatan/informasi_umum";
|
||||
import LayananUnggulan from "./data_kesehatan_warga/fasilitas_kesehatan/layanan_unggulan";
|
||||
import DokterDantenagamedis from "./data_kesehatan_warga/fasilitas_kesehatan/dokterDantenagamedis";
|
||||
import FasilitasPendukung from "./data_kesehatan_warga/fasilitas_kesehatan/fasilitas_pendukung";
|
||||
import TarifDanLayanan from "./data_kesehatan_warga/fasilitas_kesehatan/tarifDanlayanan";
|
||||
import ProsedurPendaftaran from "./data_kesehatan_warga/fasilitas_kesehatan/prosedur_pendaftaran";
|
||||
|
||||
const Kesehatan = new Elysia({
|
||||
prefix: "/api/kesehatan",
|
||||
tags: ["Kesehatan"],
|
||||
})
|
||||
.use(InformasiUmum)
|
||||
.use(LayananUnggulan)
|
||||
.use(DokterDantenagamedis)
|
||||
.use(FasilitasPendukung)
|
||||
.use(TarifDanLayanan)
|
||||
.use(ProsedurPendaftaran)
|
||||
|
||||
export default Kesehatan;
|
||||
@@ -1,36 +0,0 @@
|
||||
import { MODEL_LANDING_PAGE_LAYANAN } from "@/app/admin/(dashboard)/landing-page/layanan/lib/interface";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function layanan_landingpage({req} : {req: MODEL_LANDING_PAGE_LAYANAN}) {
|
||||
try {
|
||||
const data = await prisma.landingPage_Layanan.create({
|
||||
data: {
|
||||
id: req.id,
|
||||
deksripsi: req.deskripsi
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
deksripsi: true
|
||||
}
|
||||
})
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Success get collaboration",
|
||||
data: data,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error create layanan", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Error create layanan",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { uplCsvSingle } from "./_lib/upl-csv-single";
|
||||
import uplImg from "./_lib/upl-img";
|
||||
import { uplImgSingle } from "./_lib/upl-img-single";
|
||||
import Desa from "./_lib/desa";
|
||||
import Kesehatan from "./_lib/kesehatan";
|
||||
const ROOT = process.cwd();
|
||||
|
||||
if (!process.env.WIBU_UPLOAD_DIR)
|
||||
@@ -47,6 +48,7 @@ async function layanan() {
|
||||
const ApiServer = new Elysia()
|
||||
.use(swagger({ path: "/api/docs" }))
|
||||
.use(cors(corsConfig))
|
||||
.use(Kesehatan)
|
||||
.use(Desa)
|
||||
.onError(({ code }) => {
|
||||
if (code === "NOT_FOUND") {
|
||||
|
||||
Reference in New Issue
Block a user