usercoin.go 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package http
  2. import (
  3. "time"
  4. pb "go-common/app/service/main/coin/api"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/metadata"
  7. )
  8. // @params ModifyCoinsReq
  9. // @router post /x/internal/v1/coin/user/modify
  10. // @response ModifyCoinsReply
  11. func modify(c *bm.Context) {
  12. arg := new(pb.ModifyCoinsReq)
  13. if err := c.Bind(arg); err != nil {
  14. return
  15. }
  16. arg.IP = metadata.String(c, metadata.RemoteIP)
  17. arg.Ts = time.Now().Unix()
  18. c.JSON(coinSvc.ModifyCoins(c, arg))
  19. }
  20. // @params UserCoinsReq
  21. // @router get /x/internal/v1/coin/user/count
  22. // @response UserCoinsReply
  23. func userCoins(c *bm.Context) {
  24. v := new(pb.UserCoinsReq)
  25. if err := c.Bind(v); err != nil {
  26. return
  27. }
  28. c.JSON(coinSvc.UserCoins(c, v))
  29. }
  30. // @params CoinsLogReq
  31. // @router get /x/internal/v1/coin/user/log
  32. // @response CoinsLogReply
  33. func coinLog(c *bm.Context) {
  34. v := new(pb.CoinsLogReq)
  35. if err := c.Bind(v); err != nil {
  36. return
  37. }
  38. c.JSON(coinSvc.CoinsLog(c, v))
  39. }