up.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/dm/model"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/xstr"
  9. )
  10. // uptPaSwitch 申请保护弹幕开关
  11. func uptPaSwitch(c *bm.Context) {
  12. var (
  13. err error
  14. uid int64
  15. status int
  16. params = c.Request.Form
  17. )
  18. // uid
  19. uid, err = strconv.ParseInt(params.Get("uid"), 10, 64)
  20. if err != nil {
  21. c.JSON(nil, ecode.RequestErr)
  22. return
  23. }
  24. // uid
  25. status, err = strconv.Atoi(params.Get("status"))
  26. if err != nil {
  27. c.JSON(nil, ecode.RequestErr)
  28. return
  29. }
  30. err = dmSvc.UptPaSwitch(c, uid, status)
  31. c.JSON(nil, err)
  32. }
  33. // UptPaStatus 处理保护弹幕申请
  34. func UptPaStatus(c *bm.Context) {
  35. var (
  36. err error
  37. uid int64
  38. status int
  39. ids []int64
  40. params = c.Request.Form
  41. )
  42. // uid
  43. uid, err = strconv.ParseInt(params.Get("uid"), 10, 64)
  44. if err != nil {
  45. c.JSON(nil, ecode.RequestErr)
  46. return
  47. }
  48. if uid <= 0 {
  49. c.JSON(nil, ecode.RequestErr)
  50. return
  51. }
  52. // status
  53. status, err = strconv.Atoi(params.Get("status"))
  54. if err != nil {
  55. c.JSON(nil, ecode.RequestErr)
  56. return
  57. }
  58. ids, err = xstr.SplitInts(params.Get("ids"))
  59. if err != nil {
  60. c.JSON(nil, ecode.RequestErr)
  61. return
  62. }
  63. err = dmSvc.UptPaStatus(c, uid, ids, status)
  64. c.JSON(nil, err)
  65. }
  66. // paLs 保护弹幕申请列表
  67. func paLs(c *bm.Context) {
  68. var (
  69. err error
  70. uid, aid int64
  71. page int
  72. data *model.ApplyListResult
  73. params = c.Request.Form
  74. )
  75. // uid
  76. uid, err = strconv.ParseInt(params.Get("uid"), 10, 64)
  77. if err != nil {
  78. c.JSON(nil, ecode.RequestErr)
  79. return
  80. }
  81. aid, err = strconv.ParseInt(params.Get("aid"), 10, 64)
  82. if err != nil {
  83. aid = 0
  84. }
  85. page, err = strconv.Atoi(params.Get("page"))
  86. if err != nil {
  87. page = 1
  88. }
  89. data, err = dmSvc.ProtectApplies(c, uid, aid, page, params.Get("sort"))
  90. if err != nil {
  91. c.JSON(nil, err)
  92. log.Error("dmSvc.PaLs(%v,%v,%v,%v) error(%v)", uid, aid, page, params.Get("sort"), err)
  93. return
  94. }
  95. c.JSON(data, nil)
  96. }
  97. // paVideoLs 保护弹幕申请的视频列表
  98. func paVideoLs(c *bm.Context) {
  99. var (
  100. err error
  101. uid int64
  102. params = c.Request.Form
  103. )
  104. // uid
  105. uid, err = strconv.ParseInt(params.Get("uid"), 10, 64)
  106. if err != nil {
  107. c.JSON(nil, ecode.RequestErr)
  108. return
  109. }
  110. data, err := dmSvc.PaVideoLs(c, uid)
  111. if err != nil {
  112. log.Error("dmSvc.PaVideoLs(%v) error(%v)", uid, err)
  113. c.JSON(nil, err)
  114. return
  115. }
  116. c.JSON(data, nil)
  117. }