1
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package tao_vegetable
|
package tao_vegetable
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
request1475 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability1475/request"
|
request1475 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability1475/request"
|
||||||
domain585 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability585/domain"
|
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"
|
request589 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability589/request"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"image/jpeg"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -18,7 +20,8 @@ import (
|
|||||||
|
|
||||||
// 上传图片
|
// 上传图片
|
||||||
func TestUploadImg(t *testing.T) {
|
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) {
|
func TestAddStoreSku(t *testing.T) {
|
||||||
@@ -113,11 +116,11 @@ func TestUpdateSku(t *testing.T) {
|
|||||||
param := &request585.AlibabaWdkSkuUpdateRequest{}
|
param := &request585.AlibabaWdkSkuUpdateRequest{}
|
||||||
updateSkuList := make([]domain585.AlibabaWdkSkuUpdateSkuDo, 0, 0)
|
updateSkuList := make([]domain585.AlibabaWdkSkuUpdateSkuDo, 0, 0)
|
||||||
updateSku := domain585.AlibabaWdkSkuUpdateSkuDo{
|
updateSku := domain585.AlibabaWdkSkuUpdateSkuDo{
|
||||||
OuCode: utils.String2Pointer("JX667321"),
|
OuCode: utils.String2Pointer("JX101870"),
|
||||||
SkuCode: utils.String2Pointer("26024"),
|
SkuCode: utils.String2Pointer("6045426"),
|
||||||
ShortTitle: utils.String2Pointer("小时达"),
|
|
||||||
SkuPrice: utils.String2Pointer("80"),
|
|
||||||
CleanSkuMemberPrice: utils.Int64ToPointer(1),
|
CleanSkuMemberPrice: utils.Int64ToPointer(1),
|
||||||
|
AllowAppSale: utils.Int64ToPointer(1),
|
||||||
|
OnlineSaleFlag: utils.Int64ToPointer(1),
|
||||||
}
|
}
|
||||||
updateSkuList = append(updateSkuList, updateSku)
|
updateSkuList = append(updateSkuList, updateSku)
|
||||||
param.ParamList = &updateSkuList
|
param.ParamList = &updateSkuList
|
||||||
@@ -407,11 +410,24 @@ func uploadImg(api *API, imgs []string) *string {
|
|||||||
if strings.Contains(string(body), "Document not found") {
|
if strings.Contains(string(body), "Document not found") {
|
||||||
continue
|
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{
|
if newImg, _ := api.UploadImg(&request1475.AlibabaWdkPictureUploadRequest{
|
||||||
PictureCategoryId: utils.Int64ToPointer(0),
|
PictureCategoryId: utils.Int64ToPointer(0),
|
||||||
Img: &body,
|
Img: &body,
|
||||||
ImgInputTitle: utils.String2Pointer(v[inputTitle:]),
|
ImgInputTitle: utils.String2Pointer(v[inputTitle+1:]),
|
||||||
Title: utils.String2Pointer(v[inputTitle:title]),
|
Title: utils.String2Pointer(v[inputTitle+1 : title]),
|
||||||
}); newImg != "" {
|
}); newImg != "" {
|
||||||
result = append(result, 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("errr3 := %s", utils.Format4Output(err3, false))
|
||||||
globals.SugarLogger.Debugf("data2 := %s", utils.Format4Output(dataa, 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) {
|
func (a *API) UploadImg(param *request.AlibabaWdkPictureUploadRequest) (string, error) {
|
||||||
client := ability1475.NewAbility1475(&a.client)
|
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 {
|
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)
|
return "", fmt.Errorf(*data.Result.ErrMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user