archive.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/service/main/archive/api"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func pageList(c *bm.Context) {
  9. var (
  10. aid int64
  11. err error
  12. pages []*api.Page
  13. )
  14. aidStr := c.Request.Form.Get("aid")
  15. if aid, err = strconv.ParseInt(aidStr, 10, 64); err != nil || aid <= 0 {
  16. c.JSON(nil, ecode.RequestErr)
  17. return
  18. }
  19. if pages, err = playSvr.PageList(c, aid); err != nil {
  20. c.JSON(nil, err)
  21. return
  22. }
  23. if len(pages) == 0 {
  24. c.JSON(nil, ecode.NothingFound)
  25. return
  26. }
  27. c.JSON(pages, nil)
  28. }
  29. func videoShot(c *bm.Context) {
  30. v := new(struct {
  31. Aid int64 `form:"aid" validate:"min=1"`
  32. Cid int64 `form:"cid"`
  33. Index bool `form:"index"`
  34. })
  35. if err := c.Bind(v); err != nil {
  36. return
  37. }
  38. c.JSON(playSvr.VideoShot(c, v.Aid, v.Cid, v.Index))
  39. }
  40. func playURLToken(c *bm.Context) {
  41. var (
  42. aid, cid, mid int64
  43. err error
  44. )
  45. params := c.Request.Form
  46. aidStr := params.Get("aid")
  47. if aid, err = strconv.ParseInt(aidStr, 10, 64); err != nil {
  48. c.JSON(nil, ecode.RequestErr)
  49. return
  50. }
  51. cid, _ = strconv.ParseInt(params.Get("cid"), 10, 64)
  52. midStr, _ := c.Get("mid")
  53. mid = midStr.(int64)
  54. c.JSON(playSvr.PlayURLToken(c, mid, aid, cid))
  55. }