upper.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package http
  2. import (
  3. "go-common/app/admin/main/tv/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func upAdd(c *bm.Context) {
  7. var (
  8. err error
  9. )
  10. v := new(struct {
  11. MIDs []int64 `form:"mids,split" validate:"required,min=1,dive,gt=0"`
  12. })
  13. if err = c.Bind(v); err != nil {
  14. return
  15. }
  16. c.JSON(tvSrv.AddMids(v.MIDs))
  17. }
  18. func upImport(c *bm.Context) {
  19. var (
  20. err error
  21. )
  22. v := new(struct {
  23. MIDs []int64 `form:"mids,split" validate:"required,min=1,dive,gt=0"`
  24. })
  25. if err = c.Bind(v); err != nil {
  26. return
  27. }
  28. c.JSON(tvSrv.ImportMids(v.MIDs))
  29. }
  30. func upDel(c *bm.Context) {
  31. var (
  32. err error
  33. )
  34. v := new(struct {
  35. MID int64 `form:"mid" validate:"required,min=1"`
  36. })
  37. if err = c.Bind(v); err != nil {
  38. return
  39. }
  40. c.JSON(nil, tvSrv.DelMid(v.MID))
  41. }
  42. func upList(c *bm.Context) {
  43. v := new(struct {
  44. Order int `form:"order" validate:"required,min=1,max=4"`
  45. Pn int `form:"pn"`
  46. Name string `form:"name"`
  47. ID int `form:"id"`
  48. })
  49. if err := c.Bind(v); err != nil {
  50. return
  51. }
  52. if v.Pn == 0 {
  53. v.Pn = 1
  54. }
  55. c.JSON(tvSrv.UpList(v.Order, v.Pn, v.Name, v.ID))
  56. }
  57. func upcmsList(c *bm.Context) {
  58. v := new(model.ReqUpCms)
  59. if err := c.Bind(v); err != nil {
  60. return
  61. }
  62. c.JSON(tvSrv.CmsList(c, v))
  63. }
  64. func upcmsAudit(c *bm.Context) {
  65. v := new(struct {
  66. Action string `form:"action"`
  67. MIDs []int64 `form:"mids,split" validate:"required,min=1,dive,gt=0"`
  68. })
  69. if err := c.Bind(v); err != nil {
  70. return
  71. }
  72. c.JSON(tvSrv.CmsAudit(c, v.MIDs, v.Action))
  73. }
  74. func upcmsEdit(c *bm.Context) {
  75. v := new(model.ReqUpEdit)
  76. if err := c.Bind(v); err != nil {
  77. return
  78. }
  79. c.JSON(nil, tvSrv.CmsEdit(c, v))
  80. }