resouce.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package http
  2. import (
  3. "go-common/app/service/main/vip/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func codeInfo(c *bm.Context) {
  8. arg := new(struct {
  9. Code string `form:"code" validate:"required"`
  10. })
  11. if err := c.Bind(arg); err != nil {
  12. return
  13. }
  14. c.JSON(vipSvc.CodeInfo(c, arg.Code))
  15. }
  16. func codeInfos(c *bm.Context) {
  17. arg := new(struct {
  18. Codes []string `form:"codes,split" validate:"required"`
  19. })
  20. if err := c.Bind(arg); err != nil {
  21. return
  22. }
  23. c.JSON(vipSvc.CodeInfos(c, arg.Codes))
  24. }
  25. func openCode(c *bm.Context) {
  26. var (
  27. token *model.TokenResq
  28. code *model.VipResourceCode
  29. err error
  30. )
  31. arg := new(struct {
  32. Token string `form:"token" validate:"required"`
  33. Code string `form:"code" validate:"required"`
  34. Verify string `form:"verify" validate:"required"`
  35. Mid int64 `form:"mid" validate:"required"`
  36. })
  37. if err = c.Bind(arg); err != nil {
  38. return
  39. }
  40. if token, err = vipSvc.Verify(c, arg.Token, arg.Verify); err != nil {
  41. c.JSON(nil, ecode.CreativeGeetestErr)
  42. return
  43. }
  44. if token.Code != 0 {
  45. c.JSON(nil, ecode.CreativeGeetestErr)
  46. return
  47. }
  48. if code, err = vipSvc.OpenCode(c, arg.Code, arg.Mid); err != nil {
  49. c.JSON(nil, err)
  50. return
  51. }
  52. c.JSON(code, nil)
  53. }
  54. func belong(c *bm.Context) {
  55. arg := new(struct {
  56. Mid int64 `form:"mid" validate:"required"`
  57. })
  58. if err := c.Bind(arg); err != nil {
  59. return
  60. }
  61. c.JSON(vipSvc.Belong(c, arg.Mid))
  62. }
  63. func actives(c *bm.Context) {
  64. arg := new(struct {
  65. RelationIDs []string `form:"relationIds,split" `
  66. })
  67. if err := c.Bind(arg); err != nil {
  68. return
  69. }
  70. c.JSON(vipSvc.Actives(c, arg.RelationIDs))
  71. }
  72. func webToken(c *bm.Context) {
  73. c.JSON(vipSvc.WebToken(c))
  74. }
  75. func codeOpened(c *bm.Context) {
  76. arg := new(model.ArgCodeOpened)
  77. if err := c.Bind(arg); err != nil {
  78. return
  79. }
  80. c.JSON(vipSvc.CodeOpened(c, arg))
  81. }