49 lines
996 B
Go
49 lines
996 B
Go
package patient
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
p "simrs-vx/internal/domain/simgos-entities/m-pasien"
|
|
uo "simrs-vx/internal/use-case/simgos-sync-use-case/old/patient"
|
|
|
|
rw "github.com/karincake/risoles"
|
|
)
|
|
|
|
type myBase struct{}
|
|
|
|
var O myBase
|
|
|
|
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
|
dto := p.MPasienDto{}
|
|
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
|
|
return
|
|
}
|
|
|
|
// mapping m_patient to patient
|
|
patient := dto.ToPatient()
|
|
res, err := uo.Create(patient)
|
|
rw.DataResponse(w, res, err)
|
|
|
|
}
|
|
|
|
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
|
|
|
dto := p.MPasienDto{}
|
|
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
|
|
return
|
|
}
|
|
patient := dto.ToPatient()
|
|
res, err := uo.Update(patient)
|
|
rw.DataResponse(w, res, err)
|
|
}
|
|
|
|
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
|
dto := p.MPasienDto{}
|
|
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
|
|
return
|
|
}
|
|
patient := dto.ToPatient()
|
|
res, err := uo.Delete(patient)
|
|
rw.DataResponse(w, res, err)
|
|
}
|