Skip to content

Commit

Permalink
feat(comment): 工具-评论管理:新增「获取评论统计指标」接口,支持获取评论统计指标;「获取评论列表」接口新增请求和返回参数。
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Oct 13, 2023
1 parent 1279251 commit d885229
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 21 deletions.
1 change: 1 addition & 0 deletions marketing-api/OCEANENGINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) ]
Expand Down
16 changes: 16 additions & 0 deletions marketing-api/api/tools/comment/metrics_get.go
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 11 additions & 0 deletions marketing-api/enum/comment_permission.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package enum

// CommentPermission 评论权限
type CommentPermission string

const (
// CommentPermission_READ 只读
CommentPermission_READ CommentPermission = "READ"
// CommentPermission_WRITE 可写
CommentPermission_WRITE CommentPermission = "WRITE"
)
13 changes: 13 additions & 0 deletions marketing-api/enum/comment_type.go
Original file line number Diff line number Diff line change
@@ -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"
)
2 changes: 2 additions & 0 deletions marketing-api/model/agent/advertiser_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions marketing-api/model/tools/comment/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 评论用户信息
Expand Down
30 changes: 9 additions & 21 deletions marketing-api/model/tools/comment/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 按点赞数量排序
Expand All @@ -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: 一级评论
Expand All @@ -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)
}
Expand Down Expand Up @@ -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"`
}
66 changes: 66 additions & 0 deletions marketing-api/model/tools/comment/metrics_get.go
Original file line number Diff line number Diff line change
@@ -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"`
}

0 comments on commit d885229

Please sign in to comment.