video.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/xstr"
  8. )
  9. // arcView archive with page info.
  10. func arcView(c *bm.Context) {
  11. params := c.Request.Form
  12. // check params
  13. aidStr := params.Get("aid")
  14. aid, err := strconv.ParseInt(aidStr, 10, 64)
  15. if err != nil {
  16. c.JSON(nil, ecode.RequestErr)
  17. return
  18. }
  19. c.JSON(arcSvc.View3(c, aid))
  20. }
  21. // arcViews archives with page info by aids
  22. func arcViews(c *bm.Context) {
  23. params := c.Request.Form
  24. aidsStr := params.Get("aids")
  25. // check params
  26. aids, err := xstr.SplitInts(aidsStr)
  27. if err != nil {
  28. log.Error("query aids(%s) split error(%v)", aidsStr, err)
  29. c.JSON(nil, ecode.RequestErr)
  30. return
  31. }
  32. if len(aids) > 20 {
  33. log.Error("query aids(%s) too long, appkey(%s)", aidsStr, params.Get("appkey"))
  34. c.JSON(nil, ecode.RequestErr)
  35. return
  36. }
  37. c.JSON(arcSvc.Views3(c, aids))
  38. }
  39. // arcPage get pages by aid
  40. func arcPage(c *bm.Context) {
  41. params := c.Request.Form
  42. // check params
  43. aidStr := params.Get("aid")
  44. aid, err := strconv.ParseInt(aidStr, 10, 64)
  45. if err != nil {
  46. c.JSON(nil, ecode.RequestErr)
  47. return
  48. }
  49. c.JSON(arcSvc.Page3(c, aid))
  50. }
  51. // video get video by aid & cid.
  52. func video(c *bm.Context) {
  53. params := c.Request.Form
  54. // check params
  55. aidStr := params.Get("aid")
  56. aid, err := strconv.ParseInt(aidStr, 10, 64)
  57. if err != nil {
  58. c.JSON(nil, ecode.RequestErr)
  59. return
  60. }
  61. cidStr := params.Get("cid")
  62. cid, err := strconv.ParseInt(cidStr, 10, 64)
  63. if err != nil {
  64. c.JSON(nil, ecode.RequestErr)
  65. return
  66. }
  67. c.JSON(arcSvc.Video3(c, aid, cid))
  68. }
  69. // description get description by aid & cid.
  70. func description(c *bm.Context) {
  71. params := c.Request.Form
  72. // check params
  73. aidStr := params.Get("aid")
  74. aid, err := strconv.ParseInt(aidStr, 10, 64)
  75. if err != nil {
  76. c.JSON(nil, ecode.RequestErr)
  77. return
  78. }
  79. c.JSON(arcSvc.Description(c, aid))
  80. }