h5_service_combo_update.go 835 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package h5
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/errors"
  6. "github.com/astaxie/beego/orm"
  7. )
  8. func ManagementH5ServiceUpdateCombo(ctx context.Context, req *apis.ManagementH5ServiceUpdateComboReq, reply *apis.ManagementH5ServiceUpdateComboReply) error {
  9. if req.ComboId == 0 {
  10. return errors.ArgsError
  11. }
  12. o := orm.NewOrm()
  13. var h5Combo apis.TGdH5ServiceCombo
  14. err := o.QueryTable("t_gd_h5_service_combo").Filter("id", req.ComboId).One(&h5Combo)
  15. if err != nil {
  16. if err != orm.ErrNoRows {
  17. return errors.DataBaseError
  18. } else {
  19. return errors.DataComboNotExist
  20. }
  21. }
  22. if req.Price != h5Combo.Price {
  23. h5Combo.Price = req.Price
  24. }
  25. if req.Count != h5Combo.Count {
  26. h5Combo.Count = req.Count
  27. }
  28. if req.TotalDay != h5Combo.TotalDay {
  29. h5Combo.TotalDay = req.TotalDay
  30. }
  31. o.Update(&h5Combo)
  32. return nil
  33. }