panel.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package http
  2. import (
  3. "go-common/app/admin/main/tv/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func panelInfo(c *bm.Context) {
  8. arg := new(struct {
  9. ID int64 `form:"id" validate:"required"`
  10. })
  11. if err := c.Bind(arg); err != nil {
  12. return
  13. }
  14. c.JSON(tvSrv.PanelInfo(arg.ID))
  15. }
  16. func panelStatus(c *bm.Context) {
  17. args := new(struct {
  18. ID int64 `form:"id" validate:"required"`
  19. Status int64 `form:"status" default:"-1"`
  20. })
  21. if err := c.Bind(args); err != nil {
  22. return
  23. }
  24. if args.Status == -1 {
  25. renderErrMsg(c, ecode.RequestErr.Code(), "状态不能为空")
  26. return
  27. }
  28. c.JSON(nil, tvSrv.PanelStatus(args.ID, args.Status))
  29. }
  30. func savePanel(c *bm.Context) {
  31. panel := new(model.TvPriceConfig)
  32. if err := c.Bind(panel); err != nil {
  33. return
  34. }
  35. if panel.PID == 0 && panel.Price == 0 {
  36. renderErrMsg(c, ecode.RequestErr.Code(), "价格不能为空")
  37. return
  38. }
  39. if panel.PID == 0 && panel.Month == 0 {
  40. renderErrMsg(c, ecode.RequestErr.Code(), "月份不能为空")
  41. return
  42. }
  43. if panel.PID != 0 && panel.Stime >= panel.Etime {
  44. renderErrMsg(c, ecode.RequestErr.Code(), "活动开始时间不能晚于结束时间")
  45. return
  46. }
  47. c.JSON(nil, tvSrv.SavePanel(c, panel))
  48. }
  49. func panelList(c *bm.Context) {
  50. args := new(struct {
  51. Platform int64 `form:"platform"`
  52. Month int64 `form:"month"`
  53. SubType int64 `form:"sub_type" default:"-1"`
  54. SuitType int64 `form:"suit_type" default:"-1"`
  55. })
  56. if err := c.Bind(args); err != nil {
  57. return
  58. }
  59. c.JSON(tvSrv.PanelList(args.Platform, args.Month, args.SubType, args.SuitType))
  60. }