account.go 952 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/app/interface/main/player/model"
  7. "go-common/library/ecode"
  8. "go-common/library/log"
  9. "go-common/library/net/metadata"
  10. )
  11. const _blockTimeURI = "/api/member/getBlockAndMoralStatus"
  12. // BlockTime get user block time from account by mid
  13. func (d *Dao) BlockTime(c context.Context, mid int64) (res *model.BlockTime, err error) {
  14. var (
  15. params = url.Values{}
  16. ip = metadata.String(c, metadata.RemoteIP)
  17. )
  18. params.Set("mid", strconv.FormatInt(mid, 10))
  19. var rs struct {
  20. Code int `json:"code"`
  21. Data *model.BlockTime `json:"data"`
  22. }
  23. if err = d.client.Get(c, d.blockTimeURL, ip, params, &rs); err != nil {
  24. log.Error("d.client.Get(%s,%d) error(%v)", d.blockTimeURL, mid, err)
  25. return
  26. }
  27. if rs.Code != ecode.OK.Code() {
  28. log.Error("d.client.Get(%s,%d) error code(%d)", d.blockTimeURL, mid, rs.Code)
  29. err = ecode.Int(rs.Code)
  30. return
  31. }
  32. res = rs.Data
  33. return
  34. }