feat/action-report: done
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package soapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/action-report"
|
||||
u "simrs-vx/internal/use-case/main-use-case/action-report"
|
||||
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = uint16(id)
|
||||
res, err := u.ReadDetail(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.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Id = uint16(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 = uint16(id)
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
/******************** main / transaction ********************/
|
||||
actionreport "simrs-vx/internal/interface/main-handler/action-report"
|
||||
adime "simrs-vx/internal/interface/main-handler/adime"
|
||||
admemployeehist "simrs-vx/internal/interface/main-handler/adm-employee-hist"
|
||||
ambulancetransportrequest "simrs-vx/internal/interface/main-handler/ambulance-transport-req"
|
||||
@@ -171,6 +172,7 @@ func SetRoutes() http.Handler {
|
||||
hc.RegCrud(r, "/v1/sbar", auth.GuardMW, sbar.O)
|
||||
hc.RegCrud(r, "/v1/prescription-item", prescriptionitem.O)
|
||||
hc.RegCrud(r, "/v1/device-order-item", deviceorderitem.O)
|
||||
hc.RegCrud(r, "/v1/action-report", auth.GuardMW, actionreport.O)
|
||||
|
||||
hc.RegCrud(r, "/v1/material-order-item", materialorderitem.O)
|
||||
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
|
||||
Reference in New Issue
Block a user