Skip to content

Commit

Permalink
feat(tools): 增加评论管理相关API
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Jan 6, 2022
1 parent e5ce6fa commit 5cecd98
Show file tree
Hide file tree
Showing 27 changed files with 689 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,14 @@
- 获取起量的后验数据 [ Result(clt *core.SDKClient, accessToken string, req *adraise.ResultRequest) (*adraise.Result, error) ]
- 获取一键起量报告 [ Report(clt *core.SDKClient, accessToken string, req *adraise.ReportRequest) (*adraise.ReportResponseData, error) ]
- 获取起量版本信息 [ Version(clt *core.SDKClient, accessToken string, req *adraise.VersionRequest) (*adraise.VersionResponseData, error) ]
- 评论管理 (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) ]
- 评论操作 [ Operate(clt *core.SDKClient, accessToken string, req *comment.OperateRequest) (*comment.OperateResponseData, error) ]
- 获取屏蔽词列表 [ TermsBandedGet(clt *core.SDKClient, accessToken string, req *comment.TermsBandedGetRequest) (*comment.TermsBandedGetResponseData, error) ]
- 添加屏蔽词 [ TermsBandedAdd(clt *core.SDKClient, accessToken string, req *comment.TermsBandedAddRequest) error ]
- 更新屏蔽词 [ TermsBandedUpdate(clt *core.SDKClient, accessToken string, req *comment.TermsBandedUpdateRequest) error ]
- 删除屏蔽词 [ TermsBandedDelete(clt *core.SDKClient, accessToken string, req *comment.TermsBandedDeleteRequest) error ]
- 获取屏蔽用户列表 [ AwemeBandedList(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedListRequest) (*comment.AwemeBandedListResponseData, error) ]
- 添加屏蔽用户 [ AwemeBandedCreate(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedCreateRequest) (*comment.AwemeBandedCreateResponseData, error) ]
- 删除屏蔽用户 [ AwemeBandedDelete(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedCreateRequest) (*comment.AwemeBandedCreateResponseData, error) ]
11 changes: 11 additions & 0 deletions marketing-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,14 @@
- 获取起量的后验数据 [ Result(clt *core.SDKClient, accessToken string, req *adraise.ResultRequest) (*adraise.Result, error) ]
- 获取一键起量报告 [ Report(clt *core.SDKClient, accessToken string, req *adraise.ReportRequest) (*adraise.ReportResponseData, error) ]
- 获取起量版本信息 [ Version(clt *core.SDKClient, accessToken string, req *adraise.VersionRequest) (*adraise.VersionResponseData, error) ]
- 评论管理 (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) ]
- 评论操作 [ Operate(clt *core.SDKClient, accessToken string, req *comment.OperateRequest) (*comment.OperateResponseData, error) ]
- 获取屏蔽词列表 [ TermsBandedGet(clt *core.SDKClient, accessToken string, req *comment.TermsBandedGetRequest) (*comment.TermsBandedGetResponseData, error) ]
- 添加屏蔽词 [ TermsBandedAdd(clt *core.SDKClient, accessToken string, req *comment.TermsBandedAddRequest) error ]
- 更新屏蔽词 [ TermsBandedUpdate(clt *core.SDKClient, accessToken string, req *comment.TermsBandedUpdateRequest) error ]
- 删除屏蔽词 [ TermsBandedDelete(clt *core.SDKClient, accessToken string, req *comment.TermsBandedDeleteRequest) error ]
- 获取屏蔽用户列表 [ AwemeBandedList(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedListRequest) (*comment.AwemeBandedListResponseData, error) ]
- 添加屏蔽用户 [ AwemeBandedCreate(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedCreateRequest) (*comment.AwemeBandedCreateResponseData, error) ]
- 删除屏蔽用户 [ AwemeBandedDelete(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedCreateRequest) (*comment.AwemeBandedCreateResponseData, error) ]
17 changes: 17 additions & 0 deletions marketing-api/api/tools/comment/aweme_banded_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// AwemeBandedCreate 添加屏蔽用户
// 添加屏蔽用户接口用于添加屏蔽抖音用户,抖音用户屏蔽需要广告主绑定抖音账号,每个绑定的抖音账号最多屏蔽5000个抖音id与5000个昵称关键词,广告主当前可添加屏蔽的抖音id和昵称关键词以绑定的抖音账号中已屏蔽最多的抖音账号为准。
func AwemeBandedCreate(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedCreateRequest) (*comment.AwemeBandedCreateResponseData, error) {
var resp comment.AwemeBandedCreateResponse
err := clt.Post("2/tools/comment/aweme_banded/create/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions marketing-api/api/tools/comment/aweme_banded_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// AwemeBandedDelete 删除屏蔽用户
// 删除屏蔽用户接口用于删除已屏蔽的抖音用户,抖音用户屏蔽需要广告主绑定抖音账号。
func AwemeBandedDelete(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedCreateRequest) (*comment.AwemeBandedCreateResponseData, error) {
var resp comment.AwemeBandedCreateResponse
err := clt.Post("2/tools/comment/aweme_banded/delete/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions marketing-api/api/tools/comment/aweme_banded_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// AwemeBandedList 获取屏蔽用户列表
// 获取屏蔽用户列表用于获取广告主绑定的抖音账号(第一个绑定的抖音账号)屏蔽的抖音id列表或昵称关键词列表。
func AwemeBandedList(clt *core.SDKClient, accessToken string, req *comment.AwemeBandedListRequest) (*comment.AwemeBandedListResponseData, error) {
var resp comment.AwemeBandedListResponse
err := clt.Get("2/tools/comment/aweme_banded/list/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data, nil
}
2 changes: 2 additions & 0 deletions marketing-api/api/tools/comment/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package comment 评论管理
package comment
16 changes: 16 additions & 0 deletions marketing-api/api/tools/comment/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"
)

// Get 获取评论列表
func Get(clt *core.SDKClient, accessToken string, req *comment.GetRequest) (*comment.GetResponseData, error) {
var resp comment.GetResponse
err := clt.Get("2/tools/comment/get/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions marketing-api/api/tools/comment/operate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// Operate 操作广告计划的评论
// 为保证接口使用的安全性,避免操作他人的评论信息,该接口只可用于操作广告主自身计划下的评论信息,即需查询的广告主账号的主体需与APPID对应开发者的主体保持一致,才可操作评论的信息,否则会报错! 说明:评论回复会经过审核,一般有10s的审核时间,如果审核未通过的评论将无法展现和查询出来,并且无拒审理由,意味着10S后回复列表没有查出来那回复内容大概率就是被审核拒绝了。
func Operate(clt *core.SDKClient, accessToken string, req *comment.OperateRequest) (*comment.OperateResponseData, error) {
var resp comment.OperateResponse
err := clt.Post("2/tools/comment/operate/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions marketing-api/api/tools/comment/reply_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// ReplyGet 获取评论回复列表
// 说明:评论回复会经过审核,一般有10s的审核时间,如果审核未通过的评论将无法展现和查询出来,并且无拒审理由,意味着10S后回复列表没有查出来那回复内容大概率就是被审核拒绝了。
func ReplyGet(clt *core.SDKClient, accessToken string, req *comment.ReplyGetRequest) (*comment.ReplyGetResponseData, error) {
var resp comment.ReplyGetResponse
err := clt.Get("2/tools/comment_reply/get/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data, nil
}
14 changes: 14 additions & 0 deletions marketing-api/api/tools/comment/terms_banded_add.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// TermsBandedAdd 添加屏蔽词
// 本接口用于添加评论屏蔽词。该屏蔽词针对该广告主下的所有评论生效,命中屏蔽词的抖音评论将直接隐藏,不对外进行展示。屏蔽词管理模块目前只针对“抖音”广告位生效。屏蔽词数量最多500个。
func TermsBandedAdd(clt *core.SDKClient, accessToken string, req *comment.TermsBandedAddRequest) error {
var resp model.BaseResponse
return clt.Post("2/tools/comment/terms_banded/add/", req, &resp, accessToken)
}
14 changes: 14 additions & 0 deletions marketing-api/api/tools/comment/terms_banded_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// TermsBandedDelete 删除屏蔽词
// 本接口用于删除评论屏蔽词。屏蔽词会针对该广告主下的所有评论生效,命中屏蔽词的抖音评论将直接隐藏,不对外进行展示,删除后后续评论可正常展示。屏蔽词管理模块目前只针对“抖音”广告位生效。屏蔽词数量最多500个。
func TermsBandedDelete(clt *core.SDKClient, accessToken string, req *comment.TermsBandedDeleteRequest) error {
var resp model.BaseResponse
return clt.Post("2/tools/comment/terms_banded/delete/", req, &resp, accessToken)
}
17 changes: 17 additions & 0 deletions marketing-api/api/tools/comment/terms_banded_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// TermsBandedGet 获取屏蔽词列表
// 本接口用于获取广告主下的屏蔽词列表。该屏蔽词针对该广告主下的所有评论生效,命中屏蔽词的抖音评论将直接隐藏,不对外进行展示。屏蔽词管理模块目前只针对“抖音”广告位生效。屏蔽词数量最多500个。
func TermsBandedGet(clt *core.SDKClient, accessToken string, req *comment.TermsBandedGetRequest) (*comment.TermsBandedGetResponseData, error) {
var resp comment.TermsBandedGetResponse
err := clt.Get("2/tools/comment/terms_banded/get/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data, nil
}
15 changes: 15 additions & 0 deletions marketing-api/api/tools/comment/terms_banded_update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package comment

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/model/tools/comment"
)

// TermsBandedUpdate 更新屏蔽词
// 本接口用于对单一评论屏蔽词进行更新,可以选择指定的屏蔽词进行更新,效果等同于删除老屏蔽词后再添加新屏蔽词。该屏蔽词针对该广告主下的所有评论生效,命中屏蔽词的抖音评论将直接隐藏,不对外进行展示。屏蔽词管理模块目前只针对“抖音”广告位生效。屏蔽词数量最多500个。
// 如果new_terms已存在,则等同于删除origin_terms;如果origin_terms不存在,则等同于新增new_terms
func TermsBandedUpdate(clt *core.SDKClient, accessToken string, req *comment.TermsBandedUpdateRequest) error {
var resp model.BaseResponse
return clt.Post("2/tools/comment/terms_banded/update/", req, &resp, accessToken)
}
19 changes: 19 additions & 0 deletions marketing-api/enum/comment_operate_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package enum

// CommentOperateType 评论操作类型
type CommentOperateType string

const (
// CommentOperateType_REPLY 回复评论,可批量
CommentOperateType_REPLY CommentOperateType = "REPLY"
// CommentOperateType_REPLY_TO_REPLY 二级回复,回复该评论下的其他回复
CommentOperateType_REPLY_TO_REPLY CommentOperateType = "REPLY_TO_REPLY"
// CommentOperateType_STICK_ON_TOP 置顶
CommentOperateType_STICK_ON_TOP CommentOperateType = "STICK_ON_TOP"
// CommentOperateType_CANCEL_STICK 取消置顶
CommentOperateType_CANCEL_STICK CommentOperateType = "CANCEL_STICK"
// CommentOperateType_HIDE 隐藏评论,仅评论者自己可见
CommentOperateType_HIDE CommentOperateType = "HIDE"
// CommentOperateType_BLOCK_USERS 屏蔽用户,将用户加入黑名单,该用户之后的评论自动设置为仅评论者自见
CommentOperateType_BLOCK_USERS CommentOperateType = "BLOCK_USERS"
)
11 changes: 11 additions & 0 deletions marketing-api/enum/comment_reply_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package enum

// CommentReplyStatus 评论回复状态
type CommentReplyStatus string

const (
// CommentReplyStatus_REPLIED 已回复
CommentReplyStatus_REPLIED CommentReplyStatus = "REPLIED"
// CommentReplyStatus_NO_REPLY 未回复
CommentReplyStatus_NO_REPLY CommentReplyStatus = "NO_REPLY"
)
46 changes: 46 additions & 0 deletions marketing-api/model/tools/comment/aweme_banded_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package comment

import (
"encoding/json"

"github.com/bububa/oceanengine/marketing-api/model"
)

// AwemeBandedCreateRequest 添加屏蔽用户 API Request
type AwemeBandedCreateRequest struct {
// AdvertiserID 广告主ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// BandedType 屏蔽类型,; 允许值:CUSTOM_TYPE:自定义规则,根据昵称关键词屏蔽;AWEME_TYPE:根据抖音id屏蔽。
BandedType string `json:"banded_type,omitempty"`
// AwemeIDs 抖音id列表,抖音id为抖音页面展示id;当banned_type为AWEME_TYPE时必填;每次最多传50个抖音id,抖音id限制长度20,纯数字id不能以0开头;最多屏蔽5000个抖音ID。
AwemeIDs []string `json:"aweme_ids,omitempty"`
// NicknameKeywords 抖音昵称关键词列表,当banned_type为CUSTOM_TYPE时必填;关键词长度不大于40个字符,中文算2个字符;每次最多传50个关键词;最多屏蔽5000个关键词。
NicknameKeywords []string `json:"nickname_keywords,omitempty"`
}

// Encode implement PostRequest interface
func (r AwemeBandedCreateRequest) Encode() []byte {
js, _ := json.Marshal(r)
return js
}

// AwemeBandedCreateResponse 添加屏蔽用户 API Response
type AwemeBandedCreateResponse struct {
model.BaseResponse
// Data json 返回值
Data *AwemeBandedCreateResponseData `json:"data,omitempty"`
}

type AwemeBandedCreateResponseData struct {
// Success 屏蔽成功的昵称关键词列表或抖音id列表
Success []string `json:"success,omitempty"`
// Fail 屏蔽失败的昵称关键词列表或抖音id列表
Fail []FailItem `json:"fail,omitempty"`
}

type FailItem struct {
// Message 失败原因
Message string `json:"message,omitempty"`
// ResultKey 屏蔽失败的昵称关键词列表或抖音id
ResultKey string `json:"result_key,omitempty"`
}
74 changes: 74 additions & 0 deletions marketing-api/model/tools/comment/aweme_banded_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package comment

import (
"encoding/json"
"net/url"
"strconv"

"github.com/bububa/oceanengine/marketing-api/model"
)

// AwemeBandedList 获取屏蔽用户列表 API Request
type AwemeBandedListRequest struct {
// AdvertiserID 广告主ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// Filtering 筛选条件
Filtering *AwemeBandedListFiltering `json:"filtering,omitempty"`
// Page 页数 默认值: 1
Page int `json:"page,omitempty"`
// PageSize 页面大小默认值: 10
PageSize int `json:"page_size,omitempty"`
}

type AwemeBandedListFiltering struct {
// BandType 屏蔽类型,允许值:CUSTOM_TYPE:自定义规则,根据昵称关键词屏蔽;AWEME_TYPE:根据抖音id屏蔽。
BandType string `json:"band_type,omitempty"`
// AwemeID 抖音id,抖音id限制长度20,纯数字id不能以0开头。
AwemeID string `json:"aweme_id,omitempty"`
// NicknameKeyword 昵称关键词,关键词长度不大于40个字符,中文算2个字符。
NicknameKeyword string `json:"nickname_keyword,omitempty"`
}

// Encode implement GetRequest interface
func (r AwemeBandedListRequest) Encode() string {
values := &url.Values{}
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
if r.Filtering != nil {
filter, _ := json.Marshal(r.Filtering)
values.Set("filtering", string(filter))
}
if r.Page > 0 {
values.Set("page", strconv.Itoa(r.Page))
}
if r.PageSize > 0 {
values.Set("page_size", strconv.Itoa(r.PageSize))
}
return values.Encode()
}

// AwemeBandedListResponse 获取屏蔽用户列表 API Response
type AwemeBandedListResponse struct {
model.BaseResponse
// Data json 返回值
Data *AwemeBandedListResponseData `json:"data,omitempty"`
}

// AwemeBandedListResponseData json 返回值
type AwemeBandedListResponseData struct {
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// List 结果列表
List []BandedAweme `json:"list,omitempty"`
}

// BandedAweme 屏蔽用户
type BandedAweme struct {
// AwemeID 抖音id
AwemeID string `json:"aweme_id,omitempty"`
// AwemeName 抖音昵称
AwemeName string `json:"aweme_name,omitempty"`
// BandedType 屏蔽类型,CUSTOM_TYPE:自定义规则,根据昵称关键词屏蔽;AWEME_TYPE:根据抖音id屏蔽。
BandedType string `json:"banded_type,omitempty"`
// NicknameKeyword 昵称关键词
NicknameKeyword string `json:"nickname_keyword,omitempty"`
}
41 changes: 41 additions & 0 deletions marketing-api/model/tools/comment/comment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package comment

import "github.com/bububa/oceanengine/marketing-api/enum"

// Comment 评论
type Comment struct {
// ID 评论ID
ID uint64 `json:"id,omitempty"`
// AppName app名
AppName string `json:"app_name,omitempty"`
// UserInfo 评论用户信息
UserInfo UserInfo `json:"user_info,omitempty"`
// AdID 计划ID
AdID uint64 `json:"ad_id,omitempty"`
// AdName 计划名
AdName string `json:"ad_name,omitempty"`
// CreativeID 评论所属创意id
CreativeID uint64 `json:"creative_id,omitempty"`
// Text 评论内容
Text string `json:"text,omitempty"`
// LikeCount 点赞数
LikeCount int `json:"like_count,omitempty"`
// ReplyCount 评论的回复数量
ReplyCount int `json:"reply_count,omitempty"`
// Stick 是否置顶,0:表示不置顶,1:表示置顶
Stick int `json:"stick,omitempty"`
// InBlackList 评论发布者是否在黑名单内,0表示不在,1表示在
InBlackList int `json:"in_black_list,omitempty"`
// ReplyStatus 评论回复状态,REPLIED表示已回复,NO_REPLY表示未回复
ReplyStatus enum.CommentReplyStatus `json:"reply_status,omitempty"`
// CreateTime 评论创建时间
CreateTime string `json:"create_time,omitempty"`
}

// UserInfo 评论用户信息
type UserInfo struct {
// UserScreenName 评论用户昵称
UserScreenName string `json:"user_screen_name,omitempty"`
// AwemeAccount 评论用户抖音号
AwemeAccount string `json:"aweme_account,omitempty"`
}
Loading

0 comments on commit 5cecd98

Please sign in to comment.