controller.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package agent
  2. import (
  3. "net/http"
  4. "bet24.com/log"
  5. "github.com/gin-gonic/gin"
  6. )
  7. // 配置信息
  8. func GetConfig(c *gin.Context) {
  9. resp := mgr.getConfig()
  10. c.JSON(http.StatusOK, resp)
  11. }
  12. // 修改配置
  13. func UpdateConfig(c *gin.Context) {
  14. var req configUp_in
  15. if err := c.ShouldBind(&req); err != nil {
  16. log.Debug("%s shouldBind err %v", "agent.UpdateConfig", err)
  17. return
  18. }
  19. mgr.updateConfig(&req)
  20. c.JSON(http.StatusOK, "")
  21. return
  22. }
  23. // 代理列表
  24. func GetList(c *gin.Context) {
  25. var req struct {
  26. Info *request_base
  27. SortType int
  28. }
  29. if err := c.ShouldBind(&req); err != nil {
  30. log.Debug("%s shouldBind err %v", "agent.GetList", err)
  31. return
  32. }
  33. resp := mgr.getAgentList(req.Info, req.SortType)
  34. c.JSON(http.StatusOK, resp)
  35. return
  36. }
  37. // 申请列表
  38. func ApplyList(c *gin.Context) {
  39. var req *request_base
  40. if err := c.ShouldBind(&req); err != nil {
  41. log.Debug("%s shouldBind err %v", "agent.ApplyList", err)
  42. return
  43. }
  44. resp := mgr.getApplyList(req)
  45. c.JSON(http.StatusOK, resp)
  46. return
  47. }
  48. // 处理申请
  49. func DealApply(c *gin.Context) {
  50. var req *dealApply_req
  51. if err := c.ShouldBind(&req); err != nil {
  52. log.Debug("%s shouldBind err %v", "agent.DealApply", err)
  53. return
  54. }
  55. retCode := mgr.dealApply(req)
  56. c.JSON(http.StatusOK, struct {
  57. RetCode int
  58. }{
  59. RetCode: retCode,
  60. })
  61. return
  62. }
  63. // 会员列表
  64. func GetMemberList(c *gin.Context) {
  65. req := new(request_base)
  66. if err := c.ShouldBind(&req); err != nil {
  67. log.Debug("%s shouldBind err %v", "agent.GetMemberList", err)
  68. return
  69. }
  70. resp := mgr.getMemberList(req)
  71. c.JSON(http.StatusOK, resp)
  72. return
  73. }
  74. // 佣金日志
  75. func GetCommissionLog(c *gin.Context) {
  76. req := new(request_base)
  77. if err := c.ShouldBind(&req); err != nil {
  78. log.Debug("%s shouldBind err %v", "agent.GetCommissionLog", err)
  79. return
  80. }
  81. resp := mgr.getCommissionLog(req)
  82. c.JSON(http.StatusOK, resp)
  83. return
  84. }
  85. // 佣金排行榜
  86. func GetCommissionRankList(c *gin.Context) {
  87. req := new(request_base)
  88. if err := c.ShouldBind(&req); err != nil {
  89. log.Debug("%s shouldBind err %v", "agent.GetCommissionRankList", err)
  90. return
  91. }
  92. list := mgr.getCommissionRankList(req.UserID, req.BeginTime, req.EndTime)
  93. c.JSON(http.StatusOK, struct {
  94. RecordCount int
  95. List interface{}
  96. }{
  97. RecordCount: len(list),
  98. List: list,
  99. })
  100. return
  101. }
  102. // 创建代理
  103. func Create(c *gin.Context) {
  104. var req struct {
  105. OpUserID int
  106. OpUserName string
  107. UserId int
  108. Grade int
  109. IpAddress string
  110. }
  111. if err := c.ShouldBind(&req); err != nil {
  112. log.Debug("%s shouldBind err %v", "agent.Create", err)
  113. return
  114. }
  115. retCode := mgr.createAgent(req.OpUserID, req.OpUserName, req.UserId, req.Grade, req.IpAddress)
  116. c.JSON(http.StatusOK, struct {
  117. RetCode int
  118. }{
  119. RetCode: retCode,
  120. })
  121. return
  122. }
  123. // 设置代理状态
  124. func SetStatus(c *gin.Context) {
  125. var req struct {
  126. OpUserID int
  127. OpUserName string
  128. UserId int
  129. Enabled int
  130. }
  131. if err := c.ShouldBind(&req); err != nil {
  132. log.Debug("%s shouldBind err %v", "agent.SetStatus", err)
  133. return
  134. }
  135. mgr.setStatus(req.OpUserID, req.OpUserName, req.UserId, req.Enabled)
  136. c.JSON(http.StatusOK, nil)
  137. return
  138. }