pages.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/tv/dao/thirdp"
  5. "go-common/app/interface/main/tv/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. )
  10. func zonePage(c *bm.Context) {
  11. var (
  12. t int
  13. err error
  14. req = c.Request.Form
  15. )
  16. takeBuild(req) // take build number
  17. seasonType := req.Get("season_type")
  18. if seasonType == "" {
  19. c.JSON(nil, ecode.RequestErr)
  20. return
  21. }
  22. if t, err = strconv.Atoi(seasonType); err != nil || t < 1 {
  23. t = 1
  24. }
  25. zone, ok := tvSvc.RankData[t]
  26. if !ok {
  27. c.JSON(nil, ecode.ServerErr)
  28. return
  29. }
  30. c.JSON(zone, nil)
  31. }
  32. func homepage(c *bm.Context) {
  33. var err error
  34. params := c.Request.Form
  35. accessKey := params.Get("access_key")
  36. homeData := *tvSvc.HomeData
  37. takeBuild(params) // take build number
  38. if accessKey != "" {
  39. _, ok := c.Get("mid")
  40. if !ok { // if not login, we don't call follow data
  41. err = ecode.NoLogin
  42. } else {
  43. homeData.Follow = tvSvc.FollowData(c, accessKey)
  44. }
  45. }
  46. if tvSvc.HomeData == nil {
  47. log.Error("HomeData is Nil")
  48. c.JSON(nil, ecode.ServerErr)
  49. return
  50. }
  51. c.JSON(homeData, err)
  52. }
  53. func modpage(c *bm.Context) {
  54. var (
  55. err error
  56. params = c.Request.Form
  57. )
  58. v := new(model.ReqPageFollow)
  59. if err = c.Bind(v); err != nil {
  60. return
  61. }
  62. takeBuild(params)
  63. // check login
  64. if v.AccessKey != "" {
  65. _, ok := c.Get("mid")
  66. if !ok { // if not logged in, not request follow
  67. err = ecode.NoLogin
  68. v.AccessKey = ""
  69. }
  70. }
  71. c.JSON(tvSvc.PageFollow(c, v))
  72. }
  73. // get dangbei pgc data by page
  74. func dbeiPage(c *bm.Context) {
  75. v := new(struct {
  76. Page int64 `form:"page" validate:"required"`
  77. TypeC string `form:"type_c" validate:"required"`
  78. })
  79. err := c.Bind(v)
  80. if err != nil {
  81. return
  82. }
  83. // check the typeC ( type of the content ) value
  84. if _, err = thirdp.KeyThirdp(v.TypeC); err != nil {
  85. c.JSON(nil, ecode.TvDangbeiWrongType)
  86. return
  87. }
  88. c.JSON(thirdpSvc.PickDBeiPage(v.Page, v.TypeC))
  89. }
  90. func mangoRecom(c *bm.Context) {
  91. c.JSON(thirdpSvc.MangoRecom(), nil)
  92. }
  93. func mangoSnPage(c *bm.Context) {
  94. v := new(struct {
  95. Page int64 `form:"page" validate:"required"`
  96. })
  97. err := c.Bind(v)
  98. if err != nil {
  99. return
  100. }
  101. c.JSON(thirdpSvc.MangoSns(c, v.Page))
  102. }
  103. func mangoEpPage(c *bm.Context) {
  104. v := new(struct {
  105. SID int64 `form:"sid" validate:"required"`
  106. Page int `form:"page" validate:"required"`
  107. })
  108. err := c.Bind(v)
  109. if err != nil {
  110. return
  111. }
  112. c.JSON(thirdpSvc.MangoEps(c, v.SID, v.Page))
  113. }
  114. func mangoArcPage(c *bm.Context) {
  115. v := new(struct {
  116. Page int64 `form:"page" validate:"required"`
  117. })
  118. err := c.Bind(v)
  119. if err != nil {
  120. return
  121. }
  122. c.JSON(thirdpSvc.MangoArcs(c, v.Page))
  123. }
  124. func mangoVideoPage(c *bm.Context) {
  125. v := new(struct {
  126. AVID int64 `form:"avid" validate:"required"`
  127. Page int `form:"page" validate:"required"`
  128. })
  129. err := c.Bind(v)
  130. if err != nil {
  131. return
  132. }
  133. c.JSON(thirdpSvc.MangoVideos(c, v.AVID, v.Page))
  134. }