Merge branch 'master' of https://e.coding.net/rosydev/baseapi
This commit is contained in:
@@ -20,13 +20,13 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// 菜市
|
||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
|
||||
// 果园
|
||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
// api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_ovSLnyKTsMNx0RxMzJ1C7w") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_ovSLnyKTsMNx0RxMzJ1C7w") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
cookieStr := `
|
||||
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||
`
|
||||
@@ -64,7 +64,7 @@ func TestGetAccessToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAccessToken2(t *testing.T) {
|
||||
result, err := api.GetAccessToken2("17284266") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg
|
||||
result, err := api.GetAccessToken2("18574879") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tao_vegetable
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
request1475 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability1475/request"
|
||||
domain585 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability585/domain"
|
||||
@@ -9,6 +10,7 @@ import (
|
||||
request589 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability589/request"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"image/jpeg"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -18,7 +20,8 @@ import (
|
||||
|
||||
// 上传图片
|
||||
func TestUploadImg(t *testing.T) {
|
||||
uploadImg(apiTao, []string{"http://img20.360buyimg.com/vc/jfs/t2473/147/1629369634/4242813/e73adcd0/566a65f3N8aa04ec1.jpg,http://img20.360buyimg.com/vc/jfs/t1/109293/32/7166/234234/5e576c17E8e493056/cd6b8ba6db7f1522.png"})
|
||||
uploadImg(apiTao, []string{"http://img20.360buyimg.com/vc/jfs/t2473/147/1629369634/4242813/e73adcd0/566a65f3N8aa04ec1.jpg"})
|
||||
//uploadImg(apiTao, []string{"http://image.jxc4.com/image/2c28b6e2a1de59adba0f117b1519b5f7.png"})
|
||||
}
|
||||
|
||||
func TestAddStoreSku(t *testing.T) {
|
||||
@@ -113,11 +116,11 @@ func TestUpdateSku(t *testing.T) {
|
||||
param := &request585.AlibabaWdkSkuUpdateRequest{}
|
||||
updateSkuList := make([]domain585.AlibabaWdkSkuUpdateSkuDo, 0, 0)
|
||||
updateSku := domain585.AlibabaWdkSkuUpdateSkuDo{
|
||||
OuCode: utils.String2Pointer("JX667321"),
|
||||
SkuCode: utils.String2Pointer("26024"),
|
||||
ShortTitle: utils.String2Pointer("小时达"),
|
||||
SkuPrice: utils.String2Pointer("80"),
|
||||
OuCode: utils.String2Pointer("JX101870"),
|
||||
SkuCode: utils.String2Pointer("6045426"),
|
||||
CleanSkuMemberPrice: utils.Int64ToPointer(1),
|
||||
AllowAppSale: utils.Int64ToPointer(1),
|
||||
OnlineSaleFlag: utils.Int64ToPointer(1),
|
||||
}
|
||||
updateSkuList = append(updateSkuList, updateSku)
|
||||
param.ParamList = &updateSkuList
|
||||
@@ -407,11 +410,24 @@ func uploadImg(api *API, imgs []string) *string {
|
||||
if strings.Contains(string(body), "Document not found") {
|
||||
continue
|
||||
}
|
||||
if float64(len(body))/float64(1024)/float64(1024) > float64(3) {
|
||||
jpgimg, err := jpeg.Decode(strings.NewReader(string(body))) // 文件解码成图像对象
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
err = jpeg.Encode(&buf, jpgimg, &jpeg.Options{Quality: 30})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
body = buf.Bytes()
|
||||
}
|
||||
|
||||
if newImg, _ := api.UploadImg(&request1475.AlibabaWdkPictureUploadRequest{
|
||||
PictureCategoryId: utils.Int64ToPointer(0),
|
||||
Img: &body,
|
||||
ImgInputTitle: utils.String2Pointer(v[inputTitle:]),
|
||||
Title: utils.String2Pointer(v[inputTitle:title]),
|
||||
ImgInputTitle: utils.String2Pointer(v[inputTitle+1:]),
|
||||
Title: utils.String2Pointer(v[inputTitle+1 : title]),
|
||||
}); newImg != "" {
|
||||
result = append(result, newImg)
|
||||
}
|
||||
@@ -438,3 +454,8 @@ func TestUpLoadImg(t *testing.T) {
|
||||
globals.SugarLogger.Debugf("errr3 := %s", utils.Format4Output(err3, false))
|
||||
globals.SugarLogger.Debugf("data2 := %s", utils.Format4Output(dataa, false))
|
||||
}
|
||||
|
||||
// 上传文件到七牛云
|
||||
func TestQiNiuYn(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@ import (
|
||||
func (a *API) UploadImg(param *request.AlibabaWdkPictureUploadRequest) (string, error) {
|
||||
client := ability1475.NewAbility1475(&a.client)
|
||||
|
||||
data, _ := client.AlibabaWdkPictureUpload(param, a.token)
|
||||
data, err := client.AlibabaWdkPictureUpload(param, a.token)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if data.Result.ErrCode != nil {
|
||||
//globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(data.Result, false))
|
||||
return "", fmt.Errorf(*data.Result.ErrMsg)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user