-
Notifications
You must be signed in to change notification settings - Fork 12
/
AlibabaWdkPictureUploadAPIRequest.go
126 lines (107 loc) · 4.24 KB
/
AlibabaWdkPictureUploadAPIRequest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package wdkitem
import (
"net/url"
"sync"
"github.com/bububa/opentaobao/model"
)
// AlibabaWdkPictureUploadAPIRequest 图片上传接口 API请求
// alibaba.wdk.picture.upload
//
// 上传图片
type AlibabaWdkPictureUploadAPIRequest struct {
model.Params
// 包括后缀名的图片标题,不能为空,如Bule.jpg,有些卖家希望图片上传后取图片文件的默认名
_imgInputTitle string
// 图片标题,如果为空,传的图片标题就取去掉后缀名的image_input_title,超过50字符长度会截取50字符,重名会在标题末尾加"(1)";标题末尾已经有"(数字)"了,则数字加1
_title string
// 图片分类ID,设置具体某个分类ID或设置0上传到默认分类,只能传入一个分类
_pictureCategoryId int64
// 图片二进制文件流,不能为空,允许png、jpg、gif图片格式,3M以内
_img *model.File
}
// NewAlibabaWdkPictureUploadRequest 初始化AlibabaWdkPictureUploadAPIRequest对象
func NewAlibabaWdkPictureUploadRequest() *AlibabaWdkPictureUploadAPIRequest {
return &AlibabaWdkPictureUploadAPIRequest{
Params: model.NewParams(4),
}
}
// Reset IRequest interface 方法, 清空结构体
func (r *AlibabaWdkPictureUploadAPIRequest) Reset() {
r._imgInputTitle = ""
r._title = ""
r._pictureCategoryId = 0
r._img = nil
r.Params.ToZero()
}
// GetApiMethodName IRequest interface 方法, 获取Api method
func (r AlibabaWdkPictureUploadAPIRequest) GetApiMethodName() string {
return "alibaba.wdk.picture.upload"
}
// GetApiParams IRequest interface 方法, 获取API参数
func (r AlibabaWdkPictureUploadAPIRequest) GetApiParams(params url.Values) {
for k, v := range r.Params {
params.Set(k, v.String())
}
}
// GetRawParams IRequest interface 方法, 获取API原始参数
func (r AlibabaWdkPictureUploadAPIRequest) GetRawParams() model.Params {
return r.Params
}
// SetImgInputTitle is ImgInputTitle Setter
// 包括后缀名的图片标题,不能为空,如Bule.jpg,有些卖家希望图片上传后取图片文件的默认名
func (r *AlibabaWdkPictureUploadAPIRequest) SetImgInputTitle(_imgInputTitle string) error {
r._imgInputTitle = _imgInputTitle
r.Set("img_input_title", _imgInputTitle)
return nil
}
// GetImgInputTitle ImgInputTitle Getter
func (r AlibabaWdkPictureUploadAPIRequest) GetImgInputTitle() string {
return r._imgInputTitle
}
// SetTitle is Title Setter
// 图片标题,如果为空,传的图片标题就取去掉后缀名的image_input_title,超过50字符长度会截取50字符,重名会在标题末尾加"(1)";标题末尾已经有"(数字)"了,则数字加1
func (r *AlibabaWdkPictureUploadAPIRequest) SetTitle(_title string) error {
r._title = _title
r.Set("title", _title)
return nil
}
// GetTitle Title Getter
func (r AlibabaWdkPictureUploadAPIRequest) GetTitle() string {
return r._title
}
// SetPictureCategoryId is PictureCategoryId Setter
// 图片分类ID,设置具体某个分类ID或设置0上传到默认分类,只能传入一个分类
func (r *AlibabaWdkPictureUploadAPIRequest) SetPictureCategoryId(_pictureCategoryId int64) error {
r._pictureCategoryId = _pictureCategoryId
r.Set("picture_category_id", _pictureCategoryId)
return nil
}
// GetPictureCategoryId PictureCategoryId Getter
func (r AlibabaWdkPictureUploadAPIRequest) GetPictureCategoryId() int64 {
return r._pictureCategoryId
}
// SetImg is Img Setter
// 图片二进制文件流,不能为空,允许png、jpg、gif图片格式,3M以内
func (r *AlibabaWdkPictureUploadAPIRequest) SetImg(_img *model.File) error {
r._img = _img
r.Set("img", _img)
return nil
}
// GetImg Img Getter
func (r AlibabaWdkPictureUploadAPIRequest) GetImg() *model.File {
return r._img
}
var poolAlibabaWdkPictureUploadAPIRequest = sync.Pool{
New: func() any {
return NewAlibabaWdkPictureUploadRequest()
},
}
// GetAlibabaWdkPictureUploadRequest 从 sync.Pool 获取 AlibabaWdkPictureUploadAPIRequest
func GetAlibabaWdkPictureUploadAPIRequest() *AlibabaWdkPictureUploadAPIRequest {
return poolAlibabaWdkPictureUploadAPIRequest.Get().(*AlibabaWdkPictureUploadAPIRequest)
}
// ReleaseAlibabaWdkPictureUploadAPIRequest 将 AlibabaWdkPictureUploadAPIRequest 放入 sync.Pool
func ReleaseAlibabaWdkPictureUploadAPIRequest(v *AlibabaWdkPictureUploadAPIRequest) {
v.Reset()
poolAlibabaWdkPictureUploadAPIRequest.Put(v)
}