add patient
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package patient
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/patient"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/patient"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.Patient{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateLog(w http.ResponseWriter, r *http.Request) {
|
||||
dto := esync.SimxLogDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateSimxLog(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.Patient{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Id = uint(id)
|
||||
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = uint(id)
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"simrs-vx/internal/interface/main-handler/home"
|
||||
division "simrs-vx/internal/interface/simgos-sync-handler/division"
|
||||
installation "simrs-vx/internal/interface/simgos-sync-handler/installation"
|
||||
patient "simrs-vx/internal/interface/simgos-sync-handler/patient"
|
||||
specialist "simrs-vx/internal/interface/simgos-sync-handler/specialist"
|
||||
subspecialist "simrs-vx/internal/interface/simgos-sync-handler/subspecialist"
|
||||
unit "simrs-vx/internal/interface/simgos-sync-handler/unit"
|
||||
@@ -43,6 +44,7 @@ func SetRoutes() http.Handler {
|
||||
hc.SyncCrud(r, prefix+"/v1/division", division.O)
|
||||
hc.SyncCrud(r, prefix+"/v1/specialist", specialist.O)
|
||||
hc.SyncCrud(r, prefix+"/v1/subspecialist", subspecialist.O)
|
||||
hc.SyncCrud(r, prefix+"/v1/patient", patient.O)
|
||||
|
||||
return cmw.SetCors(handlerlogger.SetLog(r))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user