h5_service_combo_list.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package h5
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/errors"
  6. // "fmt"
  7. "github.com/astaxie/beego/orm"
  8. )
  9. func ManagementH5ServiceGetComboList(ctx context.Context, req *apis.ManagementH5ServiceGetComboListReq, reply *apis.ManagementH5ServiceGetComboListReply) error {
  10. if req.H5ServiceId == 0 {
  11. return errors.ArgsError
  12. }
  13. o := orm.NewOrm()
  14. var err error
  15. err = o.Raw("select is_free from t_gd_h5_service where id=?", req.H5ServiceId).QueryRow(&reply.IsFree)
  16. if err != nil {
  17. if err != orm.ErrNoRows {
  18. return errors.DataBaseError
  19. }
  20. }
  21. _, err = o.QueryTable("t_gd_h5_service_combo").Filter("h5_service_id", req.H5ServiceId).Filter("type", 0).All(&reply.FreeCombos)
  22. if err != nil {
  23. if err != orm.ErrNoRows {
  24. return errors.DataBaseError
  25. }
  26. }
  27. _, err = o.QueryTable("t_gd_h5_service_combo").Filter("h5_service_id", req.H5ServiceId).Filter("type", 1).All(&reply.TotalCountCombos)
  28. if err != nil {
  29. if err != orm.ErrNoRows {
  30. return errors.DataBaseError
  31. }
  32. }
  33. _, err = o.QueryTable("t_gd_h5_service_combo").Filter("h5_service_id", req.H5ServiceId).Filter("type", 2).All(&reply.DayCountCombos)
  34. if err != nil {
  35. if err != orm.ErrNoRows {
  36. return errors.DataBaseError
  37. }
  38. }
  39. return nil
  40. }