提交 45d38965 authored 作者: 赵雪如's avatar 赵雪如

base

上级 e85ddea7
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/yc-sdk-golang.iml" filepath="$PROJECT_DIR$/.idea/yc-sdk-golang.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
# yc-sdk-golang
####引用 gitlab.jxhh.com/stbz/weimob.git/weimob
例 : import ("gitlab.jxhh.com/stbz/weimob.git/weimob")
#### 初始化方法 NewWeChatClient(项目名,微盟调用接口地址)
例 : var weimob = weimob.NewWeChatClient("you.serverName", "https://dopen.weimob.com/")
####调用接口
例 : res,err := weimob.GetShopAccessToken(clientId, clientSecret, refreshToken)
\ No newline at end of file
package examples
import (
"fmt"
"gitlab.jxhh.com/zhaoxueru/yc-sdk-golang.git/sdk"
"testing"
)
var (
_apiUrl = "http://127.0.0.1:6301/"//请求url
_serverName = "test"
)
func TestNewClient(t *testing.T) {
client, _:= sdk.NewClientWithConfig(_apiUrl,_serverName,"asd123456")
res,err := client.GoodsList(map[string]interface{}{})
fmt.Println(err)
fmt.Println(res)
}
\ No newline at end of file
module gitlab.jxhh.com/zhaoxueru/yc-sdk-golang.git
go 1.16
package sdk
//保证金
package sdk
import "encoding/json"
//品牌列表
func (c *Client) BrandList(req map[string]interface{}) (res *BrandListRes, err error) {
method := "/local/brand/list"
data, _ := json.Marshal(req)
result, err := c.Get(method, string(data))
if err != nil {
return
}
err = json.Unmarshal(result, &res)
return
}
package sdk
import (
"io/ioutil"
"net/http"
"strings"
"time"
)
type Client struct {
apiUrl string
serverName string
requestId string
}
func NewClient() (client *Client, err error) {
client = new(Client)
return
}
func NewClientWithConfig(apiUrl, serverName, requestId string) (client *Client, err error) {
client = &Client{
apiUrl: apiUrl,
serverName: serverName,
requestId: requestId,
}
return
}
func (c *Client)Post(urlMethod string, params string) (res []byte, err error) {
urlMethod = c.apiUrl + urlMethod
req, err := http.NewRequest("POST", urlMethod, strings.NewReader(params))
if err != nil {
return
}
req.Header.Set("service_name", c.serverName)
req.Header.Set("request_id", c.requestId)
resp, err := (&http.Client{
Timeout: time.Second * 30,//
}).Do(req)
if err != nil {
return
}
res, _ = ioutil.ReadAll(resp.Body)
err = resp.Body.Close()
if err != nil {
return
}
return
}
func (c *Client)Get(urlMethod string, params string) (res []byte, err error) {
urlMethod = c.apiUrl + urlMethod
req, err := http.NewRequest("GET", urlMethod, strings.NewReader(params))
if err != nil {
return
}
req.Header.Set("service_name", c.serverName)
req.Header.Set("request_id", c.requestId)
resp, err := (&http.Client{
Timeout: time.Second * 30,//
}).Do(req)
if err != nil {
return
}
res, _ = ioutil.ReadAll(resp.Body)
err = resp.Body.Close()
if err != nil {
return
}
return
}
\ No newline at end of file
package sdk
import "encoding/json"
//商品
//商品列表
func (c *Client) GoodsList(req map[string]interface{}) (res *GoodsListRes, err error) {
method := "/local/goods"
param := req
data, _ := json.Marshal(param)
resData, err := c.Get(method, string(data))
if err != nil {
return
}
err = json.Unmarshal(resData, &res)
return
}
\ No newline at end of file
package sdk
type commonRes struct {
Code int `json:"code"`
Message string `json:"message"`
}
type GoodsListRes struct {
commonRes
Data GoodsList `json:"data"`
}
type GoodsList struct {
GoodsId uint `json:"goods_id"` // 商品ID
GoodsName string `json:"goods_name"` // 商品名称
CategoryId uint `json:"category_id"` // 商品类别ID
DefaultImage string `json:"default_image"` // 默认商品图片
JsPrice int `json:"js_price"` // 商家平台结算价格
Price int `json:"price"` // 现价
ScPrice int `json:"sc_price"` // 市场价
GoodsNowStock int `json:"stock"` // 当前库存
AddTime int `json:"add_time"` // 添加时间
IsOn int `json:"is_on"` //
SellerId int `json:"seller_id"` // 添加用户ID
UpOnsale int `json:"up_onsale"` // 申请上线 1:申请2:驳回
IsOnsale int `json:"is_onsale"` // 是否上架
ProducingArea string `json:"producing_area"` // 商品产地
Weight float64 `json:"weight"` // 商品重量
ProfitRate float64 `json:"profit_rate"` // 商品利润率
AftersaleTime int `json:"aftersale_time"` // 售后时长
GoodsBrand string `json:"goods_brand"` // 商品品牌
Unit string `json:"unit"` // 单位, 如: 个/件/包
StoreName string `json:"store_name"` // 店铺名称
LastPerateContent string `json:"last_perate_content"` // 最后审核内容
ChannelName string `json:"channel_name"`
ChannelId int `json:"channel_id"`
OperateTime int `json:"operate_time"`
PushStatus int `json:"push_status"`
}
type BrandListRes struct {
commonRes
Data struct {
Count int `json:"count"`
Data []BrandListInfo `json:"data"`
} `json:"data"`
}
type BrandListInfo struct {
BrandAuth string `json:"brand_auth"`
BrandAuthTime int `json:"brand_auth_time"`
BrandBusinessAuth string `json:"brand_business_auth"`
BrandCn string `json:"brand_cn"`
BrandEn string `json:"brand_en"`
BrandLogo string `json:"brand_logo"`
BrandNumber string `json:"brand_number"`
BrandRange int `json:"brand_range"`
BrandRegisterCert string `json:"brand_register_cert"`
BrandType int `json:"brand_type"`
CreatedTime int `json:"created_time"`
ID int `json:"id"`
SellerID int `json:"seller_id"`
Status int `json:"status"`
StoreName string `json:"store_name"`
UpdatedTime int `json:"updated_time"`
BrandStartTime int `json:"brand_start_time"`
BrandEndTime int `json:"brand_end_time"`
IsDel int `json:"is_del"`
LastCheckTime int `json:"last_check_time"`
LastCheckContent string `json:"last_check_content"`
}
package sdk
//订单
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论