代码初始化
This commit is contained in:
70
entities/request.go
Normal file
70
entities/request.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package entities
|
||||
|
||||
// RequestParams 请求参数
|
||||
type RequestParams struct {
|
||||
AdvertiserID int64 `json:"advertiser_id"`
|
||||
StartTime int64 `json:"start_time"`
|
||||
EndTime int64 `json:"end_time"`
|
||||
SelectColumns []string `json:"select_columns"`
|
||||
GroupType int `json:"group_type"`
|
||||
QueryVersion int `json:"query_version"`
|
||||
SelectParam *SelectParam `json:"select_param"`
|
||||
PageInfo *PageInfo `json:"page_info"`
|
||||
}
|
||||
|
||||
// SelectParam 筛选参数
|
||||
type SelectParam struct {
|
||||
CampaignIDs []int64 `json:"campaign_ids,omitempty"`
|
||||
AuthorID int64 `json:"author_id,omitempty"`
|
||||
AdTypeStr string `json:"ad_type_str,omitempty"`
|
||||
MarketingObjective int `json:"marketing_objective,omitempty"`
|
||||
DeliveryScenario int `json:"delivery_scenario,omitempty"`
|
||||
DeliveryMethod int `json:"delivery_method,omitempty"`
|
||||
SupportType string `json:"support_type,omitempty"`
|
||||
OcpcActionType string `json:"ocpc_action_type,omitempty"`
|
||||
SpeedType string `json:"speed_type,omitempty"`
|
||||
ItemType string `json:"item_type,omitempty"`
|
||||
CreativeBuildType string `json:"creative_build_type,omitempty"`
|
||||
AdScene string `json:"ad_scene,omitempty"`
|
||||
IncrementExploreType []int `json:"increment_explore_type,omitempty"`
|
||||
}
|
||||
|
||||
// PageInfo 分页信息
|
||||
type PageInfo struct {
|
||||
CurrentPage int `json:"current_page"`
|
||||
PageSize int `json:"page_size"`
|
||||
TotalCount int `json:"total_count,omitempty"`
|
||||
}
|
||||
|
||||
// NewRequestParams 创建默认请求参数
|
||||
func NewRequestParams() *RequestParams {
|
||||
return &RequestParams{
|
||||
SelectColumns: []string{"impression", "click", "cost", "t0GMV"},
|
||||
GroupType: 1,
|
||||
QueryVersion: 1,
|
||||
SelectParam: &SelectParam{},
|
||||
PageInfo: &PageInfo{
|
||||
CurrentPage: 1,
|
||||
PageSize: 20,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// SetPage 设置页码
|
||||
func (p *RequestParams) SetPage(page int) *RequestParams {
|
||||
p.PageInfo.CurrentPage = page
|
||||
return p
|
||||
}
|
||||
|
||||
// SetPageSize 设置每页大小
|
||||
func (p *RequestParams) SetPageSize(pageSize int) *RequestParams {
|
||||
p.PageInfo.PageSize = pageSize
|
||||
return p
|
||||
}
|
||||
|
||||
// ResetPage 重置分页信息
|
||||
func (p *RequestParams) ResetPage() *RequestParams {
|
||||
p.PageInfo.CurrentPage = 1
|
||||
p.PageInfo.TotalCount = 0
|
||||
return p
|
||||
}
|
||||
Reference in New Issue
Block a user