Skip to content

Commit

Permalink
feat(report): 数据报表API
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Feb 28, 2024
1 parent 9fe2e7e commit 732335f
Show file tree
Hide file tree
Showing 24 changed files with 719 additions and 6 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@
- 获取单元列表接口 [ List(ctx context.Context, clt *core.SDKClient, req *unit.ListRequest, accessToken string) (*unit.ListResult, error) ]

- 数据报表
- 离线报表(api/report/offline)
- 账户层级离线报表数据 [ Advertiser(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) ]
- 计划层级离线报表数据 [ Campaign(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) ]
- 单元层级离线报表数据 [ Unit(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) ]
- 创意层级离线报表数据 [ Creativity(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) ]
- 关键词层级离线报表数据 [ Keyword(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) ]
- 实时报表(api/report/realtime)
- 账户层级实时数据 [ Advertiser(ctx context.Context, clt *core.SDKClient, req *realtime.AdvertiserRequest, accessToken string) (*report.Metric, error) ]
- 计划层级实时数据 [ Campaign(ctx context.Context, clt *core.SDKClient, req *realtime.CampaignRequest, accessToken string) (*realtime.CampaignResponse, error) ]
- 单元层级实时数据 [ Unit(ctx context.Context, clt *core.SDKClient, req *realtime.UnitRequest, accessToken string) (*realtime.UnitResponse, error) ]
- 创意层级实时数据 [ Creativity(ctx context.Context, clt *core.SDKClient, req *realtime.CreativityRequest, accessToken string) (*realtime.CreativityResponse, error) ]
- 关键词层级实时数据 [ Keyword(ctx context.Context, clt *core.SDKClient, req *realtime.KeywordRequest, accessToken string) (*realtime.KeywordResponse, error) ]

- 转化追踪(api/conversion)
- 生成点击监测链接 [ ClickMonitorLink(ctx context.Context, clt *core.SDKClient, req string) (string, error) ]
Expand Down
17 changes: 17 additions & 0 deletions api/report/offline/advertiser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package offline

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/offline"
)

// Advertiser 账户层级离线数据
func Advertiser(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) {
var resp offline.Response
if err := clt.Post(ctx, "/jg/data/report/offline/account", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions api/report/offline/campaign.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package offline

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/offline"
)

// Campaign 广告计划层级离线数据
func Campaign(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) {
var resp offline.Response
if err := clt.Post(ctx, "/jg/data/report/offline/campaign", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions api/report/offline/creativity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package offline

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/offline"
)

// Creativity 广告创意层级离线数据
func Creativity(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) {
var resp offline.Response
if err := clt.Post(ctx, "/jg/data/report/offline/creativity", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
2 changes: 2 additions & 0 deletions api/report/offline/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package offline 离线报表
package offline
17 changes: 17 additions & 0 deletions api/report/offline/keyword.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package offline

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/offline"
)

// Keyword 关键词层级离线数据
func Keyword(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) {
var resp offline.Response
if err := clt.Post(ctx, "/jg/data/report/offline/keyword", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions api/report/offline/unit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package offline

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/offline"
)

// Unit 广告单元层级离线数据
func Unit(ctx context.Context, clt *core.SDKClient, req *offline.Request, accessToken string) (*offline.ReportList, error) {
var resp offline.Response
if err := clt.Post(ctx, "/jg/data/report/offline/unit", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
2 changes: 1 addition & 1 deletion api/report/realtime/advertiser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// Advertiser 账户层级实时数据
func Advertiser(ctx context.Context, clt *core.SDKClient, req *realtime.AdvertiserRequest, accessToken string) (*report.Metric, error) {
func Advertiser(ctx context.Context, clt *core.SDKClient, req *realtime.AdvertiserRequest, accessToken string) (*report.DataReportDTO, error) {
var resp realtime.AdvertiserResponse
if err := clt.Post(ctx, "/jg/data/report/realtime/account", req, &resp, accessToken); err != nil {
return nil, err
Expand Down
17 changes: 17 additions & 0 deletions api/report/realtime/campaign.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package realtime

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/realtime"
)

// Campaign 计划层级实时数据
func Campaign(ctx context.Context, clt *core.SDKClient, req *realtime.CampaignRequest, accessToken string) (*realtime.CampaignResponse, error) {
resp := new(realtime.CampaignResponse)
if err := clt.Post(ctx, "/jg/data/report/realtime/campaign", req, resp, accessToken); err != nil {
return nil, err
}
return resp, nil
}
17 changes: 17 additions & 0 deletions api/report/realtime/creativity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package realtime

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/realtime"
)

// Creativity 创意层级实时数据
func Creativity(ctx context.Context, clt *core.SDKClient, req *realtime.CreativityRequest, accessToken string) (*realtime.CreativityResponse, error) {
resp := new(realtime.CreativityResponse)
if err := clt.Post(ctx, "/jg/data/report/realtime/creativity", req, resp, accessToken); err != nil {
return nil, err
}
return resp, nil
}
17 changes: 17 additions & 0 deletions api/report/realtime/keyword.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package realtime

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/realtime"
)

// Keyword 关键词层级实时数据
func Keyword(ctx context.Context, clt *core.SDKClient, req *realtime.KeywordRequest, accessToken string) (*realtime.KeywordResponse, error) {
resp := new(realtime.KeywordResponse)
if err := clt.Post(ctx, "/jg/data/report/realtime/keyword", req, resp, accessToken); err != nil {
return nil, err
}
return resp, nil
}
17 changes: 17 additions & 0 deletions api/report/realtime/unit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package realtime

import (
"context"

"github.com/bububa/spotlight-mapi/core"
"github.com/bububa/spotlight-mapi/model/report/realtime"
)

// Unit 单元层级实时数据
func Unit(ctx context.Context, clt *core.SDKClient, req *realtime.UnitRequest, accessToken string) (*realtime.UnitResponse, error) {
resp := new(realtime.UnitResponse)
if err := clt.Post(ctx, "/jg/data/report/realtime/unit", req, resp, accessToken); err != nil {
return nil, err
}
return resp, nil
}
9 changes: 9 additions & 0 deletions enum/sort_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package enum

// SortType 升降序asc:升序desc:降序
type SortType string

const (
SortType_ASC SortType = "asc"
SortType_DESC SortType = "desc"
)
13 changes: 13 additions & 0 deletions enum/time_unit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package enum

// TimeUnit 时间维度
type TimeUnit string

const (
// TimeUnit_DAY 分天
TimeUnit_DAY TimeUnit = "DAY"
// TimeUnit_HOUR 分时
TimeUnit_HOUR TimeUnit = "HOUR"
// TimeUnit_SUMMARY 汇总,默认分天
TimeUnit_SUMMARY TimeUnit = "SUMMARY"
)
8 changes: 8 additions & 0 deletions model/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,11 @@ type CodeNamePair struct {
// Children 子节点
Children []CodeNamePair `json:"children,omitempty"`
}

// PageRespDTO 分页信息
type PageRespDTO struct {
// PageIndex 页码
PageIndex int64 `json:"page_index,omitempty"`
// TotalCount 总数量
TotalCount int64 `json:"total_count,omitempty"`
}
2 changes: 2 additions & 0 deletions model/report/offline/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package offline 离线报表
package offline
98 changes: 98 additions & 0 deletions model/report/offline/request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package offline

import (
"github.com/bububa/spotlight-mapi/enum"
"github.com/bububa/spotlight-mapi/util"
)

// Request 离线报表数据 API Request
type Request struct {
// AdvertiserID 广告主ID
AdvertiserID string `json:"advertiser_id"`
// StartDate 开始时间,格式 yyyy-MM-dd
StartDate string `json:"start_date,omitempty"`
// EndDate 结束时间,格式 yyyy-MM-dd
EndDate string `json:"end_date,omitempty"`
// TimeUnit 时间维度:
// "DAY":分天
// "HOUR":分时
// "SUMMARY":汇总,默认分天
TimeUnit enum.TimeUnit `json:"time_unit,omitempty"`
// SortColumn 排序字段见附录column字段
SortColumn string `json:"sort_column,omitempty"`
// Sort 升降序asc:升序desc:降序
Sort enum.SortType `json:"sort,omitempty"`
// PageNum 页数,默认1
PageNum int64 `json:"page_num,omitempty"`
// PageSize 页大小,默认20,最大1000
PageSize int64 `json:"page_size,omitempty"`
// MarketingStrategy 营销诉求过滤条件:
// 3:商品销售日常推广
// 4:产品种草
// 8:直播推广_日常推广
// 9:客资收集
// 10:抢占赛道
// 14:直播推广_直播预热
MarketingStrategy []int `json:"marketing_strategy,omitempty"`
// BiddingStrategy 出价方式过滤条件:2:手动出价3:自动出价
BiddingStrategy []int `json:"bidding_strategy,omitempty"`
// OptimizeTarget 推广目标过滤条件:
// 0:点击量
// 1:互动量
// 3:表单提交量
// 4:商品成单量
// 5:私信咨询量
// 6:直播间观看量
// 11:商品访客量
// 12:落地页访问量
// 13:私信开口量
// 14:有效观看量
// 18:站外转化量
// 20:TI人群规模
// 21:行业商品成单
// 23:直播预热量
// 24:直播间成交
// 25:直播间支付ROI
OptimizeTarget []int `json:"optimize_target,omitempty"`
// Placement 广告类型过滤条件
// 1:信息流推广
// 2:搜索推广
// 4:全站智投
// 7:视频内流
Placement []int `json:"placement,omitempty"`
// PromotionTarget 推广标的类型过滤条件
// 1:笔记
// 2:商品
// 9:落地页
// 18:直播间
// 商品、落地页、直播间笔记只能三选一
PromotionTarget []int `json:"promotion_target,omitempty"`
// BuildType 搭建方式过滤条件
// 0:标准搭建
// 1:省心智投
BuildType []int `json:"build_type,omitempty"`
// SplitColumns 细分条件(相当于group by)
// marketingTarget:营销诉求
// buildType:搭建方式
// placement:广告类型
// optimizeTarget:推广目标
// biddingStrategy:出价方式
// promotionTarget:推广标的类型
// jumpType:创意跳转类型
// itemId:商品
// pageId:落地页
// liveRedId:直播间笔记
// keyword:关键词
SplitColumns []string `json:"split_columns,omitempty"`
// Programmatic 创意组合方式过滤条件
// 0:自定义创意
// 1:程序化创意
Programmatic []int `json:"programmatic,omitempty"`
// MarketingTarget 营销诉求过滤条件:3:商品销量_日常推广4:产品种草8:直播推广_日常推广9:客资收集10:抢占赛道14:直播推广_直播预热
MarketingTarget []int `json:"marketing_target,omitempty"`
}

// Encode implement PostRequest interface
func (r Request) Encode() []byte {
return util.JSONMarshal(r)
}
65 changes: 65 additions & 0 deletions model/report/offline/response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package offline

import (
"github.com/bububa/spotlight-mapi/model"
"github.com/bububa/spotlight-mapi/model/report"
)

// Response 离线数据 API Response
type Response struct {
model.BaseResponse
Data *ReportList `json:"data,omitempty"`
}

// ReportList 离线数据列表
type ReportList struct {
List []Report `json:"data_list,omitempty"`
TotalCount int64 `json:"total_count,omitempty"`
}

// Report 离线数据报表
type Report struct {
Dimension
report.DataReportDTO
}

type Dimension struct {
// Time 时间
Time string `json:"time,omitempty"`
// CampaignID 计划id
CampaignID model.Uint64 `json:"campaign_id,omitempty"`
// CampaignName 计划名称
CampaignName string `json:"campaign_name,omitempty"`
// UnitID 单元id
UnitID model.Uint64 `json:"unit_id,omitempty"`
// UnitName 单元名称
UnitName string `json:"unit_name,omitempty"`
// CreativityID 创意id
CreativityID model.Uint64 `json:"creativity_id,omitempty"`
// CreativityName 创意名称
CreativityName string `json:"creativity_name,omitempty"`
// CreativityImage 创意图片
CreativityImage string `json:"creativity_image,omitempty"`
// Keyword 关键词
Keyword string `json:"keyword,omitempty"`
// Placement 广告类型
Placement model.Int `json:"placement,omitempty"`
// OptimizeTarget 优化目标
OptimizeTarget model.Int `json:"optimize_target,omitempty"`
// PromotionTarget 推广标的
PromotionTarget model.Int `json:"promotion_target,omitempty"`
// BiddingStrategy 出价方式
BiddingStrategy model.Int `json:"bidding_strategy,omitempty"`
// BuildType 搭建类型
BuildType model.Int `json:"build_type,omitempty"`
// MarketingTarget 营销诉求
MarketingTarget model.Int `json:"marketing_target,omitempty"`
// NoteID 笔记id
NoteID string `json:"note_id,omitempty"`
// PageID 落地页id
PageID string `json:"page_id,omitempty"`
// ItemID 商品id
ItemID string `json:"item_id,omitempty"`
// LiveRedID 直播间id
LiveRedID string `json:"live_red_id,omitempty"`
}

0 comments on commit 732335f

Please sign in to comment.