card.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package http
  2. import (
  3. "go-common/app/interface/main/account/model"
  4. cardv1 "go-common/app/service/main/card/api/grpc/v1"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func userCard(c *bm.Context) {
  9. mid, exists := c.Get("mid")
  10. if !exists {
  11. c.JSON(nil, ecode.AccountNotLogin)
  12. return
  13. }
  14. c.JSON(cardSvc.UserCard(c, mid.(int64)))
  15. }
  16. func cardInfo(c *bm.Context) {
  17. var err error
  18. arg := new(model.ArgCardID)
  19. if err = c.Bind(arg); err != nil {
  20. return
  21. }
  22. c.JSON(cardSvc.Card(c, arg.ID))
  23. }
  24. func cardHots(c *bm.Context) {
  25. c.JSON(cardSvc.CardHots(c))
  26. }
  27. func cardGroups(c *bm.Context) {
  28. var mid int64
  29. midi, exists := c.Get("mid")
  30. if exists {
  31. mid = midi.(int64)
  32. }
  33. c.JSON(cardSvc.AllGroup(c, mid))
  34. }
  35. func cardsByGid(c *bm.Context) {
  36. var err error
  37. arg := new(model.ArgGroupID)
  38. if err = c.Bind(arg); err != nil {
  39. return
  40. }
  41. c.JSON(cardSvc.CardsByGid(c, arg.ID))
  42. }
  43. func equip(c *bm.Context) {
  44. var err error
  45. arg := new(model.ArgCardID)
  46. if err = c.Bind(arg); err != nil {
  47. return
  48. }
  49. mid, exists := c.Get("mid")
  50. if !exists {
  51. c.JSON(nil, ecode.AccountNotLogin)
  52. return
  53. }
  54. c.JSON(nil, cardSvc.Equip(c, &cardv1.ModelArgEquip{Mid: mid.(int64), CardId: arg.ID}))
  55. }
  56. func demount(c *bm.Context) {
  57. mid, exists := c.Get("mid")
  58. if !exists {
  59. c.JSON(nil, ecode.AccountNotLogin)
  60. return
  61. }
  62. c.JSON(nil, cardSvc.Demount(c, mid.(int64)))
  63. }