user.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package http
  2. import (
  3. "go-common/app/service/main/vip/model"
  4. "go-common/library/log"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. // byMid get vipinfo by mid.
  8. func byMid(c *bm.Context) {
  9. var (
  10. res *model.VipInfoResp
  11. err error
  12. )
  13. arg := new(struct {
  14. Mid int64 `form:"mid" validate:"required"`
  15. })
  16. if err = c.Bind(arg); err != nil {
  17. log.Error("c.Bind err(%+v)", err)
  18. return
  19. }
  20. if res, err = vipSvc.ByMid(c, arg.Mid); err != nil {
  21. log.Error("vipSvc.ByMid(%d) err(%+v)", arg.Mid, err)
  22. c.JSON(nil, err)
  23. return
  24. }
  25. c.JSON(res, nil)
  26. }
  27. func vipInfos(c *bm.Context) {
  28. var (
  29. vMap map[int64]*model.VipInfoResp
  30. err error
  31. )
  32. arg := new(struct {
  33. Mids []int64 `form:"mids,split" validate:"required"`
  34. })
  35. if err = c.Bind(arg); err != nil {
  36. log.Error("c.Bind err %+v", err)
  37. return
  38. }
  39. if vMap, err = vipSvc.VipInfos(c, arg.Mids); err != nil {
  40. log.Error("vipSvc.VipInfos(%v) err(%+v)", arg.Mids, err)
  41. c.JSON(nil, err)
  42. return
  43. }
  44. c.JSON(vMap, nil)
  45. }
  46. func vipHistory(c *bm.Context) {
  47. var (
  48. err error
  49. )
  50. arg := new(model.ArgChangeHistory)
  51. if c.Bind(arg); err != nil {
  52. log.Error("vipHistory(%d) err(%+v)", arg.Mid, err)
  53. return
  54. }
  55. vh, count, err := vipSvc.History(c, arg)
  56. rel := make(map[string]interface{})
  57. rel["data"] = vh
  58. rel["total"] = count
  59. c.JSON(rel, err)
  60. }
  61. func vipH5History(c *bm.Context) {
  62. var (
  63. err error
  64. )
  65. arg := new(model.ArgChangeHistory)
  66. if c.Bind(arg); err != nil {
  67. log.Error("vipH5History(%d) err(%+v)", arg.Mid, err)
  68. return
  69. }
  70. c.JSON(vipSvc.H5History(c, arg))
  71. }
  72. // vipInfo (for old service).
  73. func vipInfo(c *bm.Context) {
  74. var (
  75. res *model.VipInfoBoResp
  76. err error
  77. )
  78. arg := new(struct {
  79. Mid int64 `form:"mid" validate:"required"`
  80. })
  81. if err = c.Bind(arg); err != nil {
  82. log.Error("c.Bind err(%+v)", err)
  83. return
  84. }
  85. if res, err = vipSvc.VipInfoBo(c, arg.Mid); err != nil {
  86. log.Error("vipSvc.VipInfo(%d) err(%+v)", arg.Mid, err)
  87. c.JSON(nil, err)
  88. return
  89. }
  90. c.JSON(res, nil)
  91. }