bangumi.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package http
  2. import (
  3. "go-common/app/interface/main/space/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func bangumiList(c *bm.Context) {
  7. var (
  8. mid int64
  9. list []*model.Bangumi
  10. count int
  11. err error
  12. )
  13. v := new(struct {
  14. Vmid int64 `form:"vmid" validate:"min=1"`
  15. Pn int `form:"pn" default:"1" validate:"min=1"`
  16. Ps int `form:"ps" default:"15" validate:"min=1"`
  17. })
  18. if err = c.Bind(v); err != nil {
  19. return
  20. }
  21. if midInter, ok := c.Get("mid"); ok {
  22. mid = midInter.(int64)
  23. }
  24. if list, count, err = spcSvc.BangumiList(c, mid, v.Vmid, v.Pn, v.Ps); err != nil {
  25. c.JSON(nil, err)
  26. return
  27. }
  28. type data struct {
  29. List []*model.Bangumi `json:"list"`
  30. *model.Page
  31. }
  32. c.JSON(&data{List: list, Page: &model.Page{Pn: v.Pn, Ps: v.Ps, Total: count}}, nil)
  33. }
  34. func bangumiConcern(c *bm.Context) {
  35. midStr, _ := c.Get("mid")
  36. mid := midStr.(int64)
  37. v := new(struct {
  38. SeasonID int64 `form:"season_id" validate:"min=1"`
  39. })
  40. if err := c.Bind(v); err != nil {
  41. return
  42. }
  43. c.JSON(nil, spcSvc.BangumiConcern(c, mid, v.SeasonID))
  44. }
  45. func bangumiUnConcern(c *bm.Context) {
  46. midStr, _ := c.Get("mid")
  47. mid := midStr.(int64)
  48. v := new(struct {
  49. SeasonID int64 `form:"season_id" validate:"min=1"`
  50. })
  51. if err := c.Bind(v); err != nil {
  52. return
  53. }
  54. c.JSON(nil, spcSvc.BangumiUnConcern(c, mid, v.SeasonID))
  55. }