material, device-order required doctor_id, infra search and parent,childrens

This commit is contained in:
dpurbosakti
2025-10-03 10:53:06 +07:00
parent c23df03d0e
commit 39efdf4d57
15 changed files with 166 additions and 6 deletions
@@ -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)