elec.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package http
  2. import (
  3. "net/http"
  4. api "go-common/app/interface/main/ugcpay-rank/api/http"
  5. "go-common/app/interface/main/ugcpay-rank/internal/conf"
  6. bm "go-common/library/net/http/blademaster"
  7. "github.com/json-iterator/go"
  8. )
  9. const (
  10. _contentTypeJSON = "application/json; charset=utf-8"
  11. )
  12. func elecMonthUP(ctx *bm.Context) {
  13. var (
  14. err error
  15. arg = &api.ArgRankElecMonthUP{}
  16. resp *api.RespRankElecMonthUP
  17. bytes []byte
  18. )
  19. if err = ctx.Bind(arg); err != nil {
  20. return
  21. }
  22. if arg.RankSize <= 0 || arg.RankSize > conf.Conf.Biz.ElecUPRankSize {
  23. arg.RankSize = conf.Conf.Biz.ElecUPRankSize
  24. }
  25. if resp, err = svc.RankElecMonthUP(ctx, arg.UPMID, arg.RankSize); err != nil {
  26. ctx.JSON(nil, err)
  27. return
  28. }
  29. if bytes, err = jsoniter.ConfigFastest.Marshal(resp); err != nil {
  30. ctx.JSON(nil, err)
  31. return
  32. }
  33. ctx.Bytes(http.StatusOK, _contentTypeJSON, bytes)
  34. }
  35. func elecMonth(ctx *bm.Context) {
  36. var (
  37. err error
  38. arg = &api.ArgRankElecMonth{}
  39. resp *api.RespRankElecMonth
  40. bytes []byte
  41. )
  42. if err = ctx.Bind(arg); err != nil {
  43. return
  44. }
  45. if arg.RankSize <= 0 || arg.RankSize > conf.Conf.Biz.ElecAVRankSize {
  46. arg.RankSize = conf.Conf.Biz.ElecAVRankSize
  47. }
  48. if resp, err = svc.RankElecMonth(ctx, arg.UPMID, arg.AVID, arg.RankSize); err != nil {
  49. ctx.JSON(nil, err)
  50. return
  51. }
  52. if bytes, err = jsoniter.ConfigFastest.Marshal(resp); err != nil {
  53. ctx.JSON(nil, err)
  54. return
  55. }
  56. ctx.Bytes(http.StatusOK, _contentTypeJSON, bytes)
  57. }
  58. func elecAllAV(ctx *bm.Context) {
  59. var (
  60. err error
  61. arg = &api.ArgRankElecMonth{}
  62. resp *api.RespRankElecAllAV
  63. bytes []byte
  64. )
  65. if err = ctx.Bind(arg); err != nil {
  66. return
  67. }
  68. if arg.RankSize <= 0 || arg.RankSize > conf.Conf.Biz.ElecAVRankSize {
  69. arg.RankSize = conf.Conf.Biz.ElecAVRankSize
  70. }
  71. if resp, err = svc.RankElecAllAV(ctx, arg.UPMID, arg.AVID, arg.RankSize); err != nil {
  72. ctx.JSON(nil, err)
  73. return
  74. }
  75. if bytes, err = jsoniter.ConfigFastest.Marshal(resp); err != nil {
  76. ctx.JSON(nil, err)
  77. return
  78. }
  79. ctx.Bytes(http.StatusOK, _contentTypeJSON, bytes)
  80. }