You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
920 B
42 lines
920 B
package dao |
|
|
|
import ( |
|
"context" |
|
"net/url" |
|
"strconv" |
|
|
|
"go-common/app/interface/main/web/model" |
|
"go-common/library/ecode" |
|
"go-common/library/net/metadata" |
|
|
|
"github.com/pkg/errors" |
|
) |
|
|
|
const ( |
|
_shopURI = "/mall-shop/merchant/enter/service/shop/get" |
|
_shopTypePc = "2" |
|
) |
|
|
|
// ShopInfo get shop info data. |
|
func (d *Dao) ShopInfo(c context.Context, mid int64) (data *model.ShopInfo, err error) { |
|
var ( |
|
params = url.Values{} |
|
ip = metadata.String(c, metadata.RemoteIP) |
|
) |
|
params.Set("mid", strconv.FormatInt(mid, 10)) |
|
params.Set("type", _shopTypePc) |
|
var res struct { |
|
Code int `json:"code"` |
|
Data *model.ShopInfo `json:"data"` |
|
} |
|
if err = d.httpR.Get(c, d.shopURL, ip, params, &res); err != nil { |
|
err = errors.Wrapf(err, "ShopInfo(%s) mid(%d)", d.shopURL+params.Encode(), mid) |
|
return |
|
} |
|
if res.Code != ecode.OK.Code() { |
|
err = ecode.Int(res.Code) |
|
return |
|
} |
|
data = res.Data |
|
return |
|
}
|
|
|