material, device-order required doctor_id, infra search and parent,childrens
This commit is contained in:
@@ -6,10 +6,12 @@ import (
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/device-order"
|
||||
u "simrs-vx/internal/use-case/main-use-case/device-order"
|
||||
|
||||
pa "simrs-vx/pkg/auth-helper"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -21,6 +23,12 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -54,6 +62,11 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
dto.Id = uint16(id)
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/consume": medicationitemdist.O.Consume,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/device-order", r, hk.MapHandlerFunc{
|
||||
hk.GroupRoutes("/v1/device-order", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": deviceorder.O.GetList,
|
||||
"GET /{id}": deviceorder.O.GetDetail,
|
||||
"POST /": deviceorder.O.Create,
|
||||
@@ -202,7 +202,7 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/complete": deviceorder.O.Complete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/material-order", r, hk.MapHandlerFunc{
|
||||
hk.GroupRoutes("/v1/material-order", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": materialorder.O.GetList,
|
||||
"GET /{id}": materialorder.O.GetDetail,
|
||||
"POST /": materialorder.O.Create,
|
||||
|
||||
@@ -10,6 +10,10 @@ import (
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/material-order"
|
||||
u "simrs-vx/internal/use-case/main-use-case/material-order"
|
||||
|
||||
pa "simrs-vx/pkg/auth-helper"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -21,6 +25,11 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -53,6 +62,11 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
dto.AuthInfo = *authInfo
|
||||
dto.Id = uint16(id)
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
|
||||
Reference in New Issue
Block a user