synthesis.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/mhaya/game/game_cluster/nodes/webadmin/entity"
  5. "github.com/mhaya/game/game_cluster/nodes/webadmin/service"
  6. )
  7. type Synthesis struct {
  8. sev *service.Synthesis
  9. }
  10. func NewSynthesis() *Synthesis {
  11. return &Synthesis{
  12. sev: service.NewSynthesis(),
  13. }
  14. }
  15. // FindUserLogDaily 查询用户日活跃
  16. func (s *Synthesis) FindUserLogDaily(ctx *gin.Context) {
  17. req := &entity.UserLogDailyReq{}
  18. if err := ctx.ShouldBindJSON(req); err != nil {
  19. ctx.JSON(200, gin.H{
  20. "code": 400,
  21. "msg": err.Error(),
  22. })
  23. return
  24. }
  25. resp, err := s.sev.FindMDBUserLogDaily(req)
  26. if err != nil {
  27. ctx.JSON(200, gin.H{
  28. "code": 400,
  29. "msg": err.Error(),
  30. })
  31. return
  32. }
  33. ctx.JSON(200, gin.H{
  34. "code": 200,
  35. "msg": "success",
  36. "data": resp,
  37. })
  38. }
  39. // FindUserRetention 查询用户留存
  40. func (s *Synthesis) FindUserRetention(ctx *gin.Context) {
  41. req := &entity.UserRetentionReq{}
  42. if err := ctx.ShouldBindJSON(req); err != nil {
  43. ctx.JSON(200, gin.H{
  44. "code": 400,
  45. "msg": err.Error(),
  46. })
  47. return
  48. }
  49. resp, err := s.sev.FindUserRetention(req)
  50. if err != nil {
  51. ctx.JSON(200, gin.H{
  52. "code": 400,
  53. "msg": err.Error(),
  54. })
  55. return
  56. } else {
  57. ctx.JSON(200, gin.H{
  58. "code": 200,
  59. "msg": "success",
  60. "data": resp,
  61. })
  62. }
  63. }
  64. // FindUserCountryCount 查询用户国家分布
  65. func (s *Synthesis) FindUserCountryCount(ctx *gin.Context) {
  66. resp, err := s.sev.FindUserCountryCount()
  67. if err != nil {
  68. ctx.JSON(200, gin.H{
  69. "code": 400,
  70. "msg": err.Error(),
  71. })
  72. return
  73. } else {
  74. ctx.JSON(200, gin.H{
  75. "code": 200,
  76. "msg": "success",
  77. "data": resp,
  78. })
  79. }
  80. }
  81. // FindWithdrawal 查询提现记录
  82. func (s *Synthesis) FindWithdrawal(ctx *gin.Context) {
  83. req := &entity.UserWithdrawalReq{}
  84. if err := ctx.ShouldBindJSON(req); err != nil {
  85. ctx.JSON(200, gin.H{
  86. "code": 400,
  87. "msg": err.Error(),
  88. })
  89. return
  90. }
  91. resp, err := s.sev.FindWithdrawal(req)
  92. if err != nil {
  93. ctx.JSON(200, gin.H{
  94. "code": 400,
  95. "msg": err.Error(),
  96. })
  97. return
  98. } else {
  99. ctx.JSON(200, gin.H{
  100. "code": 200,
  101. "msg": "success",
  102. "data": resp,
  103. })
  104. }
  105. }
  106. // WithdrawalStatus 修改提现状态
  107. func (s *Synthesis) WithdrawalStatus(ctx *gin.Context) {
  108. req := &entity.UserWithdrawalStatus{}
  109. if err := ctx.ShouldBindJSON(req); err != nil {
  110. ctx.JSON(200, gin.H{
  111. "code": 400,
  112. "msg": err.Error(),
  113. })
  114. return
  115. }
  116. err := s.sev.WithdrawalStatus(req)
  117. if err != nil {
  118. ctx.JSON(200, gin.H{
  119. "code": 400,
  120. "msg": err.Error(),
  121. })
  122. return
  123. } else {
  124. ctx.JSON(200, gin.H{
  125. "code": 200,
  126. "msg": "success",
  127. })
  128. }
  129. }
  130. // FindUserLevel 查询用户等级
  131. func (s *Synthesis) FindUserLevel(ctx *gin.Context) {
  132. resp, err := s.sev.FindUserLevel()
  133. if err != nil {
  134. ctx.JSON(200, gin.H{
  135. "code": 400,
  136. "msg": err.Error(),
  137. })
  138. return
  139. } else {
  140. ctx.JSON(200, gin.H{
  141. "code": 200,
  142. "msg": "success",
  143. "data": resp,
  144. })
  145. }
  146. }