feat (encounter): add flow to insert adm employee

This commit is contained in:
dpurbosakti
2025-10-16 12:16:51 +07:00
parent 2fb47d0d48
commit d4806d90fb
4 changed files with 23 additions and 2 deletions
@@ -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,