shop.go 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/app/interface/main/web/model"
  7. "go-common/library/ecode"
  8. "go-common/library/net/metadata"
  9. "github.com/pkg/errors"
  10. )
  11. const (
  12. _shopURI = "/mall-shop/merchant/enter/service/shop/get"
  13. _shopTypePc = "2"
  14. )
  15. // ShopInfo get shop info data.
  16. func (d *Dao) ShopInfo(c context.Context, mid int64) (data *model.ShopInfo, err error) {
  17. var (
  18. params = url.Values{}
  19. ip = metadata.String(c, metadata.RemoteIP)
  20. )
  21. params.Set("mid", strconv.FormatInt(mid, 10))
  22. params.Set("type", _shopTypePc)
  23. var res struct {
  24. Code int `json:"code"`
  25. Data *model.ShopInfo `json:"data"`
  26. }
  27. if err = d.httpR.Get(c, d.shopURL, ip, params, &res); err != nil {
  28. err = errors.Wrapf(err, "ShopInfo(%s) mid(%d)", d.shopURL+params.Encode(), mid)
  29. return
  30. }
  31. if res.Code != ecode.OK.Code() {
  32. err = ecode.Int(res.Code)
  33. return
  34. }
  35. data = res.Data
  36. return
  37. }