fix (encounter): add guard for create, delete and cancel

This commit is contained in:
dpurbosakti
2025-11-13 14:51:45 +07:00
parent ccc341be34
commit 1e54d3bc3f
6 changed files with 73 additions and 10 deletions
@@ -89,9 +89,14 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
if id <= 0 {
return
}
authInfo, err := pa.GetAuthInfo(r)
if err != nil {
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
}
dto := e.DeleteDto{}
dto.Id = uint16(id)
dto.AuthInfo = *authInfo
res, err := u.Delete(dto)
rw.DataResponse(w, res, err)
}
@@ -159,11 +164,17 @@ func (obj myBase) Cancel(w http.ResponseWriter, r *http.Request) {
return
}
authInfo, err := pa.GetAuthInfo(r)
if err != nil {
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
}
dto := e.UpdateStatusDto{
Id: uint16(id),
StatusCode: erc.DSCCancel,
}
dto.AuthInfo = *authInfo
res, err := u.UpdateStatusCode(dto)
rw.DataResponse(w, res, err)
}