From d88522994867db884733205cfa6a83178149a8ea Mon Sep 17 00:00:00 2001 From: Syd Xu Date: Fri, 13 Oct 2023 16:22:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(comment):=20=E5=B7=A5=E5=85=B7-=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E7=AE=A1=E7=90=86=EF=BC=9A=E6=96=B0=E5=A2=9E=E3=80=8C?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=AF=84=E8=AE=BA=E7=BB=9F=E8=AE=A1=E6=8C=87?= =?UTF-8?q?=E6=A0=87=E3=80=8D=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=AF=84=E8=AE=BA=E7=BB=9F=E8=AE=A1=E6=8C=87?= =?UTF-8?q?=E6=A0=87=EF=BC=9B=E3=80=8C=E8=8E=B7=E5=8F=96=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E3=80=8D=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=92=8C=E8=BF=94=E5=9B=9E=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- marketing-api/OCEANENGINE.md | 1 + .../api/tools/comment/metrics_get.go | 16 +++++ marketing-api/enum/comment_permission.go | 11 ++++ marketing-api/enum/comment_type.go | 13 ++++ .../model/agent/advertiser_update.go | 2 + marketing-api/model/tools/comment/comment.go | 6 ++ marketing-api/model/tools/comment/get.go | 30 +++------ .../model/tools/comment/metrics_get.go | 66 +++++++++++++++++++ 8 files changed, 124 insertions(+), 21 deletions(-) create mode 100644 marketing-api/api/tools/comment/metrics_get.go create mode 100644 marketing-api/enum/comment_permission.go create mode 100644 marketing-api/enum/comment_type.go create mode 100644 marketing-api/model/tools/comment/metrics_get.go diff --git a/marketing-api/OCEANENGINE.md b/marketing-api/OCEANENGINE.md index 3ac73124..b11fe5a5 100644 --- a/marketing-api/OCEANENGINE.md +++ b/marketing-api/OCEANENGINE.md @@ -443,6 +443,7 @@ - 评论管理 (tools/comment) - 获取评论列表 [ Get(clt *core.SDKClient, accessToken string, req *comment.GetRequest) (*comment.GetResponseData, error) ] - 获取评论回复列表 [ ReplyGet(clt *core.SDKClient, accessToken string, req *comment.ReplyGetRequest) (*comment.ReplyGetResponseData, error) ] + - 获取评论统计指标 [ MetricsGet(clt *core.SDKClient, accessToken string, req *comment.MetricsGetRequest) (*comment.MetricsGetResult, error) ] - 评论操作 [ Operate(clt *core.SDKClient, accessToken string, req *comment.OperateRequest) (*comment.OperateResponseData, error) ] - 屏蔽词/屏蔽用户 - 获取屏蔽词列表 [ TermsBandedGet(clt *core.SDKClient, accessToken string, req *comment.TermsBandedGetRequest) (*comment.TermsBandedGetResponseData, error) ] diff --git a/marketing-api/api/tools/comment/metrics_get.go b/marketing-api/api/tools/comment/metrics_get.go new file mode 100644 index 00000000..4c2ec5b1 --- /dev/null +++ b/marketing-api/api/tools/comment/metrics_get.go @@ -0,0 +1,16 @@ +package comment + +import ( + "github.com/bububa/oceanengine/marketing-api/core" + "github.com/bububa/oceanengine/marketing-api/model/tools/comment" +) + +// MetricsGet 获取评论统计指标 +// 获取广告账户下评论的「可见评论数」、「可见负评数」、「可见评论负评率」 +func MetricsGet(clt *core.SDKClient, accessToken string, req *comment.MetricsGetRequest) (*comment.MetricsGetResult, error) { + var resp comment.MetricsGetResponse + if err := clt.Get("v3.0/tools/comment_metrics/get/", req, &resp, accessToken); err != nil { + return nil, err + } + return resp.Data, nil +} diff --git a/marketing-api/enum/comment_permission.go b/marketing-api/enum/comment_permission.go new file mode 100644 index 00000000..6fa87726 --- /dev/null +++ b/marketing-api/enum/comment_permission.go @@ -0,0 +1,11 @@ +package enum + +// CommentPermission 评论权限 +type CommentPermission string + +const ( + // CommentPermission_READ 只读 + CommentPermission_READ CommentPermission = "READ" + // CommentPermission_WRITE 可写 + CommentPermission_WRITE CommentPermission = "WRITE" +) diff --git a/marketing-api/enum/comment_type.go b/marketing-api/enum/comment_type.go new file mode 100644 index 00000000..9cbdc448 --- /dev/null +++ b/marketing-api/enum/comment_type.go @@ -0,0 +1,13 @@ +package enum + +// CommentType 评论内容类型 +type CommentType string + +const ( + // IMAGE_COMMENT 图片评论 + IMAGE_COMMENT CommentType = "IMAGE_COMMENT" + // IMAGE_TEXT_COMMENT 图文评论 + IMAGE_TEXT_COMMENT CommentType = "IMAGE_TEXT_COMMENT" + // TEXT_COMMENT 文字评论 + TEXT_COMMENT CommentType = "TEXT_COMMENT" +) diff --git a/marketing-api/model/agent/advertiser_update.go b/marketing-api/model/agent/advertiser_update.go index 85daf1c4..1c6ef46d 100644 --- a/marketing-api/model/agent/advertiser_update.go +++ b/marketing-api/model/agent/advertiser_update.go @@ -17,6 +17,8 @@ type AdvertiserUpdateRequest struct { Phonenumber string `json:"phonenumber,omitempty"` // Telephone 固定电话 Telephone string `json:"telephone,omitempty"` + // Note 备注 + Note string `json:"note,omitempty"` } // Encode implement PostRequest interface diff --git a/marketing-api/model/tools/comment/comment.go b/marketing-api/model/tools/comment/comment.go index 02c22844..4aa05f7c 100644 --- a/marketing-api/model/tools/comment/comment.go +++ b/marketing-api/model/tools/comment/comment.go @@ -44,6 +44,12 @@ type Comment struct { ItemID uint64 `json:"item_id,omitempty"` // ItemTitle 视频标题 ItemTitle string `json:"item_title,omitempty"` + // CommentPermission 评论权限,允许值: + // READ 只读 + // WRITE 可写 + CommentPermission enum.CommentPermission `json:"comment_permission,omitempty"` + // MaterialID 评论关联的视频素材id + MaterialID uint64 `json:"material_id,omitempty"` } // UserInfo 评论用户信息 diff --git a/marketing-api/model/tools/comment/get.go b/marketing-api/model/tools/comment/get.go index 929547a4..1cb9c954 100644 --- a/marketing-api/model/tools/comment/get.go +++ b/marketing-api/model/tools/comment/get.go @@ -13,16 +13,10 @@ import ( type GetRequest struct { // AdvertiserID 广告主ID AdvertiserID uint64 `json:"advertiser_id,omitempty"` - // PlatformVersion 查询的平台版本,查询体验版需传入V2,允许值: - // V1: 1.0平台(默认值) - // V2: 2.0平台 - PlatformVersion enum.PlatformVersion `json:"platform_version,omitempty"` // StartTime 查询起始时间,格式:yyyy-MM-dd,若不填,默认6天前(即获取最近七天的内容) StartTime string `json:"start_time,omitempty"` // EndTime 查询截止时间,格式:yyyy-MM-dd,若不填,默认当天 EndTime string `json:"end_time,omitempty"` - // IncludeMetrics 是否包含计算指标,传入True则返回负评数和负评率,默认为True - IncludeMetrics bool `json:"include_metrics,omitempty"` // OrderField 排序字段,允许值: // REPLY_COUNT按评论回复数量排序 // LIKE_COUNT 按点赞数量排序 @@ -43,15 +37,8 @@ type GetRequest struct { type GetFilter struct { // AdIDs 计划id列表,一次最多10个 AdIDs []uint64 `json:"ad_ids,omitempty"` - // CreativeIDs 广告创意id列表,一次最多100个,仅当platform_version=V1时传入生效 - CreativeIDs []uint64 `json:"creative_ids,omitempty"` // ItemIDs 广告视频id列表,一次最多100个,仅当platform_version=V2时传入生效,可通过【获取抖音授权关系】获取item_id和视频相关信息 ItemIDs []uint64 `json:"item_ids,omitempty"` - // BindRelation 抖音号分类,可选值: - // ALL: 全部抖音号(默认值) - // BIND_AWEME: 绑定的抖音号 - // VIRTUAL_AWEME: 虚拟抖音号 - BindRelation string `json:"bind_relation,omitempty"` // LevelType 查询的评论等级,可选值: // LEVEL_ALL: 所有评论(默认值) // LEVEL_ONE: 一级评论 @@ -69,20 +56,25 @@ type GetFilter struct { // NEUTRAL: 中性评论 // POSITIVE: 正向评论 EmotionType enum.CommentEmotionType `json:"emotion_type,omitempty"` + // Content 评论关键词,最长支持10个字符 + Content string `json:"content,omitempty"` + // AuthorIDs 视频作者抖音id,最多支持100个 + AuthorIDs []uint64 `json:"author_ids,omitempty"` + // CommentType 评论内容类型,不传返回所有评论,允许值: + // IMAGE_COMMENT 图片评论 + // IMAGE_TEXT_COMMENT 图文评论 + // TEXT_COMMENT 文字评论 + CommentType enum.CommentType `json:"comment_type,omitempty"` } // Encode implement GetRequest interface func (r GetRequest) Encode() string { values := util.GetUrlValues() values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10)) - values.Set("platform_version", string(r.PlatformVersion)) if r.Filtering != nil { bs, _ := json.Marshal(r.Filtering) values.Set("filtering", string(bs)) } - if !r.IncludeMetrics { - values.Set("include_metrics", "false") - } if r.OrderField != "" { values.Set("order_field", r.OrderField) } @@ -117,10 +109,6 @@ type GetResponse struct { type GetResponseData struct { // PageInfo 分页信息 PageInfo *model.PageInfo `json:"page_info,omitempty"` - // NegativeVolumn 负评数 - NegativeVolumn int `json:"negative_volumn,omitempty"` - // NegativeVolumnRate 负评率 - NegativeVolumnRate float64 `json:"negative_volumn_rate,omitempty"` // CommentsList 评论列表 CommentsList []Comment `json:"comment_list,omitempty"` } diff --git a/marketing-api/model/tools/comment/metrics_get.go b/marketing-api/model/tools/comment/metrics_get.go new file mode 100644 index 00000000..769cfcdc --- /dev/null +++ b/marketing-api/model/tools/comment/metrics_get.go @@ -0,0 +1,66 @@ +package comment + +import ( + "strconv" + + "github.com/bububa/oceanengine/marketing-api/enum" + "github.com/bububa/oceanengine/marketing-api/model" + "github.com/bububa/oceanengine/marketing-api/util" +) + +// MetricsGetRequest 获取评论统计指标 API Request +type MetricsGetRequest struct { + // AdvertiserID 广告主id + AdvertiserID uint64 `json:"advertiser_id,omitempty"` + // StartTime 查询起始时间,格式:yyyy-MM-dd,时间跨度最大90天 + StartTime string `json:"start_time,omitempty"` + // EndTime 查询截止时间,格式:yyyy-MM-dd,时间跨度最大90天 + EndTime string `json:"end_time,omitempty"` + // Filtering 筛选条件 + Filtering *MetricsGetFilter `json:"filtering,omitempty"` +} + +type MetricsGetFilter struct { + // LevelType 评论层级,不传返回所有评论,可选值: + // LEVEL_ALL 所有等级 + // LEVEL_ONE 一级评论 + // LEVEL_TWO 二级评论 + LevelType enum.CommentLevelType `json:"level_type,omitempty"` + // AuthorIDs 抖音号,一次最多查询100个抖音号id + AuthorIDs []uint64 `json:"author_ids,omitempty"` + // ItemIDs 广告视频id列表,一次最多100个,可通过【获取抖音授权关系】获取item_id和视频相关信息 + ItemIDs []uint64 `json:"item_ids,omitempty"` + // HideStatus 隐藏状态,不传返回全部,可选值: + // ALL 全部 + // HIDE 已隐藏 + // NOT_HIDE 未隐藏 + HideStatus enum.CommentHideStatus `json:"hide_status,omitempty"` +} + +func (r MetricsGetRequest) Encode() string { + values := util.GetUrlValues() + values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10)) + values.Set("start_time", r.StartTime) + values.Set("end_time", r.EndTime) + if r.Filtering != nil { + values.Set("filtering", string(util.JSONMarshal(r.Filtering))) + } + ret := values.Encode() + util.PutUrlValues(values) + return ret +} + +// MetricsGetResponse 获取评论统计指标 API Response +type MetricsGetResponse struct { + model.BaseResponse + Data *MetricsGetResult `json:"data,omitempty"` +} + +type MetricsGetResult struct { + // TotalCount 可见评论数 + TotalCount int64 `json:"total_count,omitempty"` + // NegativeCount 可见负评数 + NegativeCount int64 `json:"negative_count,omitempty"` + // NegativeRate 可见评论负评率 + NegativeRate float64 `json:"negative_rate,omitempty"` +}