user.go 748 B

123456789101112131415161718192021222324252627282930
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "net/url"
  6. "strconv"
  7. "go-common/app/job/main/sms/model"
  8. "go-common/library/log"
  9. )
  10. // UserMobile get user mobile
  11. func (d *Dao) UserMobile(c context.Context, mid int64) (*model.UserMobile, error) {
  12. res := struct {
  13. Code int `json:"code"`
  14. Data model.UserMobile `json:"data"`
  15. }{}
  16. params := url.Values{}
  17. params.Set("mid", strconv.FormatInt(mid, 10))
  18. if err := d.httpClient.Get(c, d.c.Sms.PassportMobileURL, "", params, &res); err != nil {
  19. log.Error("d.GetUserMobile(%d) error(%v)", mid, err)
  20. return nil, err
  21. }
  22. if res.Code != 0 {
  23. return nil, fmt.Errorf("GetUserMobile(%d) error, res(%+v)", mid, &res)
  24. }
  25. log.Info("GetUserMobile(%d) res(%+v)", mid, &res)
  26. return &res.Data, nil
  27. }