feat/trx-orders: fix doctor_code + id type
This commit is contained in:
@@ -33,39 +33,42 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
intId := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if intId <= 0 {
|
||||
return
|
||||
}
|
||||
id := uint16(intId)
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = uint16(id)
|
||||
dto.Id = &id
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
intId := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if intId <= 0 {
|
||||
return
|
||||
}
|
||||
id := uint16(intId)
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Id = uint16(id)
|
||||
dto.Id = &id
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
intId := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if intId <= 0 {
|
||||
return
|
||||
}
|
||||
id := uint16(intId)
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = uint16(id)
|
||||
dto.Id = &id
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.AntibioticInUse) {
|
||||
// data.ExaminationDate = inputSrc.ExaminationDate
|
||||
}
|
||||
|
||||
func ValidateMcuOrderDoctor(input e.ReadDetailDto, doctorId uint, event *pl.Event, tx *gorm.DB) error {
|
||||
func ValidateMcuOrderDoctor(input e.ReadDetailDto, doctorCode string, event *pl.Event, tx *gorm.DB) error {
|
||||
pl.SetLogInfo(event, input, "started", "ValidateMcuOrderDoctor")
|
||||
|
||||
var mcuOrder emo.McuOrder
|
||||
@@ -47,7 +47,7 @@ func ValidateMcuOrderDoctor(input e.ReadDetailDto, doctorId uint, event *pl.Even
|
||||
return pl.SetLogError(event, input)
|
||||
}
|
||||
|
||||
if mcuOrder.Doctor_Id == nil || *mcuOrder.Doctor_Id != doctorId {
|
||||
if mcuOrder.Doctor_Code == nil || *mcuOrder.Doctor_Code != doctorCode {
|
||||
return errors.New("doctor is not authorized for this mcu-order")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user