controller.go 931 B

123456789101112131415161718192021222324252627282930313233343536
  1. package dot
  2. import (
  3. "net/http"
  4. "strings"
  5. "bet24.com/log"
  6. dotservice "bet24.com/servers/micros/dotservice/proto"
  7. "github.com/gin-gonic/gin"
  8. )
  9. func AddDot(c *gin.Context) {
  10. var dotScope dotservice.DotScope
  11. if err := c.ShouldBind(&dotScope); err != nil {
  12. log.Error("dot.addDot get params fail %v", err)
  13. c.String(http.StatusOK, "dot.addDot get params fail %v", err)
  14. return
  15. }
  16. // !!! 必须检查是否是 登录 或者 启动场景 不应该是其它场景。否则容易 被刷其它场景
  17. if dotScope.Scene != dotservice.Scene_Login {
  18. c.String(http.StatusBadRequest, "failed!")
  19. return
  20. }
  21. if 1 > dotScope.Action || 2 < dotScope.Action {
  22. c.String(http.StatusBadRequest, "failed!")
  23. return
  24. }
  25. IpAddress := strings.Split(c.Request.RemoteAddr, ":")[0]
  26. dotScope.IpAddress = IpAddress
  27. log.Error("dot.addDot get params: %v", dotScope)
  28. go dotservice.AddDot(0, dotScope)
  29. c.String(http.StatusOK, "success")
  30. }