-
Notifications
You must be signed in to change notification settings - Fork 43
/
get.go
67 lines (60 loc) · 1.85 KB
/
get.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
package site
import (
"encoding/json"
"strconv"
"github.com/bububa/oceanengine/marketing-api/enum"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/util"
)
// GetRequest 获取橙子建站站点列表 API Request
type GetRequest struct {
// AdvertiserID 广告主id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// Page 页数默认值: 1,page必须大于0
Page int `json:"page,omitempty"`
// PageSize 页面大小默认值:10,page_size范围为1-1000
PageSize int `json:"page_size,omitempty"`
// Status 建站粗粒度状态
Status enum.SiteSearchStatus `json:"status,omitempty"`
// Filtering 过滤字段
Filtering *GetFiltering `json:"filtering,omitempty"`
}
// Encode implement GetRequest interface
func (r GetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
if r.Filtering != nil {
filtering, _ := json.Marshal(r.Filtering)
values.Set("filtering", string(filtering))
}
if r.Page > 0 {
values.Set("page", strconv.Itoa(r.Page))
}
if r.PageSize > 0 {
values.Set("page_size", strconv.Itoa(r.PageSize))
}
if r.Status != "" {
values.Set("status", string(r.Status))
}
ret := values.Encode()
util.PutUrlValues(values)
return ret
}
// GetFiltering 过滤字段
type GetFiltering struct {
// Search 搜索字段,按照建站id和建站name进行模糊匹配,范围:1 <= 长度 <= 50
Search string `json:"search,omitempty"`
}
// GetResponse 获取橙子建站站点列表 API Response
type GetResponse struct {
model.BaseResponse
// Data json返回值
Data *GetResponseData `json:"data,omitempty"`
}
// GetResponseData json返回值
type GetResponseData struct {
// List 站点列表
List []Site `json:"list,omitempty"`
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
}