item.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package http
  2. import (
  3. "strings"
  4. item "go-common/app/service/openplatform/ticket-item/api/grpc/v1"
  5. "go-common/app/service/openplatform/ticket-item/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. "go-common/library/net/http/blademaster/binding"
  10. "github.com/pkg/errors"
  11. )
  12. // @params ParamID
  13. // @router get /openplatform/internal/ticket/item/info
  14. // @response InfoReply
  15. func info(c *bm.Context) {
  16. arg := new(model.ParamID)
  17. if err := c.Bind(arg); err != nil {
  18. errors.Wrap(err, "参数验证失败")
  19. return
  20. }
  21. c.JSON(itemSvc.Info(c, &item.InfoRequest{ID: arg.ID}))
  22. }
  23. // @params ParamCards
  24. // @router get /openplatform/internal/ticket/item/cards
  25. // @response CardsReply
  26. func cards(c *bm.Context) {
  27. arg := new(model.ParamCards)
  28. if err := c.Bind(arg); err != nil {
  29. errors.Wrap(err, "参数验证失败")
  30. return
  31. }
  32. ids := model.UniqueInt64(model.String2Int64(strings.Split(arg.IDs, ",")))
  33. if len(ids) == 0 {
  34. err := ecode.RequestErr
  35. errors.Wrap(err, "参数验证失败")
  36. log.Error("ItemID invalid %v", arg.IDs)
  37. return
  38. }
  39. c.JSON(itemSvc.Cards(c, &item.CardsRequest{IDs: ids}))
  40. }
  41. // @params ParamBill
  42. // @router get /openplatform/internal/ticket/item/billinfo
  43. // @response BillReply
  44. func billInfo(c *bm.Context) {
  45. arg := new(model.ParamBill)
  46. if err := c.Bind(arg); err != nil {
  47. errors.Wrap(err, "参数验证失败")
  48. return
  49. }
  50. ids := model.UniqueInt64(model.String2Int64(strings.Split(arg.IDs, ",")))
  51. if len(ids) == 0 {
  52. err := ecode.RequestErr
  53. errors.Wrap(err, "参数验证失败")
  54. log.Error("ItemID empty %v", arg.IDs)
  55. return
  56. }
  57. sids := model.UniqueInt64(model.String2Int64(strings.Split(arg.Sids, ",")))
  58. if len(ids) == 0 {
  59. log.Info("ScreenID empty %v", arg.Sids)
  60. return
  61. }
  62. tids := model.UniqueInt64(model.String2Int64(strings.Split(arg.Tids, ",")))
  63. if len(ids) == 0 {
  64. log.Info("TicketID empty %v", arg.Tids)
  65. return
  66. }
  67. c.JSON(itemSvc.BillInfo(c, &item.BillRequest{IDs: ids, ScIDs: sids, TkIDs: tids}))
  68. }
  69. // @params WishRequest
  70. // @router post /openplatform/internal/ticket/item/wishstatus
  71. // @response WishReply
  72. func wish(c *bm.Context) {
  73. arg := new(item.WishRequest)
  74. if err := c.BindWith(arg, binding.JSON); err != nil {
  75. errors.Wrap(err, "参数验证失败")
  76. return
  77. }
  78. c.JSON(itemSvc.Wish(c, arg))
  79. }
  80. // @params FavRequest
  81. // @router post /openplatform/internal/ticket/item/favstatus
  82. // @response FavReply
  83. func fav(c *bm.Context) {
  84. arg := new(item.FavRequest)
  85. if err := c.BindWith(arg, binding.JSON); err != nil {
  86. errors.Wrap(err, "参数验证失败")
  87. return
  88. }
  89. c.JSON(itemSvc.Fav(c, arg))
  90. }