feat (encounter): add flow to insert adm employee
This commit is contained in:
@@ -10,6 +10,10 @@ import (
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/encounter"
|
||||
u "simrs-vx/internal/use-case/main-use-case/encounter"
|
||||
|
||||
pa "simrs-vx/pkg/auth-helper"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -17,10 +21,15 @@ 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)
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": mcuordersubitem.O.Delete,
|
||||
"PATCH /{id}/complete": mcuordersubitem.O.Complete,
|
||||
})
|
||||
hk.GroupRoutes("/v1/encounter", r, hk.MapHandlerFunc{
|
||||
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": encounter.O.GetList,
|
||||
"GET /{id}": encounter.O.GetDetail,
|
||||
"POST /": encounter.O.Create,
|
||||
|
||||
Reference in New Issue
Block a user