feat (mcu-order): handle doctor_id on create and update

This commit is contained in:
dpurbosakti
2025-10-03 11:00:07 +07:00
parent 39efdf4d57
commit 06a6ac6424
5 changed files with 73 additions and 1 deletions
@@ -10,6 +10,10 @@ import (
e "simrs-vx/internal/domain/main-entities/mcu-order"
u "simrs-vx/internal/use-case/main-use-case/mcu-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 = uint(id)
res, err := u.Update(dto)
rw.DataResponse(w, res, err)