bangumi.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func bangumiContent(c *bm.Context) {
  7. v := new(struct {
  8. Pn int `form:"pn" default:"1"`
  9. Ps int `form:"ps" validate:"min=1,max=1000" default:"20"`
  10. Type int8 `form:"type" validate:"required"`
  11. Appkey string `form:"appkey" validate:"required"`
  12. })
  13. if err := c.Bind(v); err != nil {
  14. c.JSON(nil, ecode.RequestErr)
  15. return
  16. }
  17. data, err := svc.BangumiContent(c, v.Pn, v.Ps, v.Type, v.Appkey)
  18. Render(c, data.Code, data.Message, data.Result, data.Total, err)
  19. }
  20. func bangumiOff(c *bm.Context) {
  21. v := new(struct {
  22. Pn int `form:"pn" default:"1"`
  23. Ps int `form:"ps" validate:"min=1,max=1000" default:"20"`
  24. Type int8 `form:"type" validate:"required"`
  25. Timestamp int64 `form:"timestamp"`
  26. Appkey string `form:"appkey" validate:"required"`
  27. })
  28. if err := c.Bind(v); err != nil {
  29. c.JSON(nil, ecode.RequestErr)
  30. return
  31. }
  32. if v.Pn == 0 {
  33. v.Pn = 1
  34. }
  35. data, err := svc.BangumiOff(c, v.Pn, v.Ps, v.Type, v.Timestamp, v.Appkey)
  36. Render(c, data.Code, data.Message, data.Result, data.Total, err)
  37. }