Skip to content

Commit

Permalink
feat(tools/security): 新增支持风控违规积分API和SPI能力,系统化提效风控治理
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Nov 1, 2024
1 parent 60cb763 commit 3fa233f
Show file tree
Hide file tree
Showing 12 changed files with 424 additions and 42 deletions.
35 changes: 19 additions & 16 deletions marketing-api/OCEANENGINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,23 +377,26 @@
- 查询白名单能力 [ GrayGet(clt *core.SDKClient, accessToken string, req *tools.GrayGetRequest) ([]tools.GrayItem, error) ]
- 查询建议出价(巨量广告升级版) [ tools.v3.BidSuggest(clt *core.SDKClient, accessToken string, req *v3.BidSuggestRequest) (*tools.BidSuggest, error) ]
- 获取绑定的抖音号 [ IesAccountSearch(clt *core.SDKClient, accessToken string, req *tools.IesAccountSearchRequest) ([]tools.IesAccount, error) ]
- 应用管理 (tools/appmanagement)
- 查询游戏信息 [ BookingGet(clt *core.SDKClient, accessToken string, req *appmanagement.AppListRequest) (*appmanagement.AppListResponseData, error) ]
- 查询应用信息 [ AppGet(clt *core.SDKClient, accessToken string, req *appmanagement.AppListRequest) (*appmanagement.AppListResponseData, error) ]
- 查询安卓应用信息(支持所有账户体系) [ AndroidAppList(clt *core.SDKClient, accessToken string, req *appmanagement.AndroidAppListRequest) (*appmanagement.AppListResponseData, error) ]
- 查询应用预约记录 [ BookingRecordsGet(clt *core.SDKClient, accessToken string, req *appmanagement.BookingRecordsGetRequest) (*appmanagement.BookingRecordsGetData, error) ]
- 提交解析应用包任务 [ DownloadPackageParse(clt *core.SDKClient, accessToken string, req *appmanagement.DownloadPackageParseRequest) (string, error) ]
- 查询包解析状态 [ DownloadPackageGet(clt *core.SDKClient, accessToken string, req *appmanagement.DownloadPackageGetRequest) (appmanagement.DownloadPackageStatus, error) ]
- 查询应用分包列表 [ ExtendPackageList(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageListRequest) (*appmanagement.ExtendPackageListData, error) ]
- 查询应用分包列表 (支持所有账户体系) [ ExtendPackageListV2(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageListV2Request) (*appmanagement.ExtendPackageListData, error) ]
- 创建应用分包 [ ExtendPackageCreate(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageCreateRequest) error ]
- 创建应用分包 (支持所有账户体系)[ ExtendPackageCreateV2(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageCreateV2Request) error ]
- 更新应用子包版本 [ ExtendPackageUpdate(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageUpdateRequest) error ]
- 查看应用共享范围 [ ShareAccountList(clt *core.SDKClient, accessToken string, req *appmanagement.ShareAccountListRequest) (*appmanagement.ShareAccountListData, error) ]
- 设置应用共享 [ BpShare(clt *core.SDKClient, accessToken string, req *appmanagement.BpShareRequest) (*appmanagement.BpShareData, error) ]
- 取消应用共享关系 [ BpShareCancel(clt *core.SDKClient, accessToken string, req *appmanagement.BpShareRequest) (*appmanagement.BpShareData, error) ]
- 更新应用共享关系 [ UpdateAuthorization(clt *core.SDKClient, accessToken string, req *appmanagement.UpdateAuthorizationRequest) error ]
- 获取账户下原生锚点 [ tools.NativeAnchorGet(clt *core.SDKClient, accessToken string, req *tools.NativeAnchorGetRequest) (*tools.NativeAnchorGetResponseData, error) ]
- 查询账户累计积分 [ security.ScoreTotalGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *security.ScoreTotalGetRequest) (*security.ScoreTotalGetResult, error) ]
- 查询违规积分明细 [ security.ScoreViolationEventGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *security.ScoreViolationEventGetRequest) (*security.ScoreViolationEventGetResult, error) ]
- 查看积分处置详情 [ security.ScoreDisposalInfoGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *security.ScoreDisposalInfoGetRequest) (*security.ScoreDisposalInfoGetResult, error) ]
- 应用管理 (tools/appmanagement)
- 查询游戏信息 [ BookingGet(clt *core.SDKClient, accessToken string, req *appmanagement.AppListRequest) (*appmanagement.AppListResponseData, error) ]
- 查询应用信息 [ AppGet(clt *core.SDKClient, accessToken string, req *appmanagement.AppListRequest) (*appmanagement.AppListResponseData, error) ]
- 查询安卓应用信息(支持所有账户体系) [ AndroidAppList(clt *core.SDKClient, accessToken string, req *appmanagement.AndroidAppListRequest) (*appmanagement.AppListResponseData, error) ]
- 查询应用预约记录 [ BookingRecordsGet(clt *core.SDKClient, accessToken string, req *appmanagement.BookingRecordsGetRequest) (*appmanagement.BookingRecordsGetData, error) ]
- 提交解析应用包任务 [ DownloadPackageParse(clt *core.SDKClient, accessToken string, req *appmanagement.DownloadPackageParseRequest) (string, error) ]
- 查询包解析状态 [ DownloadPackageGet(clt *core.SDKClient, accessToken string, req *appmanagement.DownloadPackageGetRequest) (appmanagement.DownloadPackageStatus, error) ]
- 查询应用分包列表 [ ExtendPackageList(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageListRequest) (*appmanagement.ExtendPackageListData, error) ]
- 查询应用分包列表 (支持所有账户体系) [ ExtendPackageListV2(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageListV2Request) (*appmanagement.ExtendPackageListData, error) ]
- 创建应用分包 [ ExtendPackageCreate(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageCreateRequest) error ]
- 创建应用分包 (支持所有账户体系)[ ExtendPackageCreateV2(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageCreateV2Request) error ]
- 更新应用子包版本 [ ExtendPackageUpdate(clt *core.SDKClient, accessToken string, req *appmanagement.ExtendPackageUpdateRequest) error ]
- 查看应用共享范围 [ ShareAccountList(clt *core.SDKClient, accessToken string, req *appmanagement.ShareAccountListRequest) (*appmanagement.ShareAccountListData, error) ]
- 设置应用共享 [ BpShare(clt *core.SDKClient, accessToken string, req *appmanagement.BpShareRequest) (*appmanagement.BpShareData, error) ]
- 取消应用共享关系 [ BpShareCancel(clt *core.SDKClient, accessToken string, req *appmanagement.BpShareRequest) (*appmanagement.BpShareData, error) ]
- 更新应用共享关系 [ UpdateAuthorization(clt *core.SDKClient, accessToken string, req *appmanagement.UpdateAuthorizationRequest) error ]
- 抖音达人 (tools/aweme)
- 查询抖音帐号和类目信息 [ AwemeInfoSearch(clt *core.SDKClient, accessToken string, req *aweme.AwemeInfoSearchRequest) (*aweme.AwemeInfoSearchResult, error) ]
- 查询抖音类似帐号 [ AwemeSimilarAuthorSearch(clt *core.SDKClient, accessToken string, req *aweme.AwemeSimilarAuthorSearchRequest) ([]aweme.Author, error) ]
Expand Down
2 changes: 2 additions & 0 deletions marketing-api/api/tools/security/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package security 风控违规积分
package security
17 changes: 17 additions & 0 deletions marketing-api/api/tools/security/score_disposal_info_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package security

import (
"context"

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

// ScoreDisposalInfoGet 查看积分处置详情
func ScoreDisposalInfoGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *security.ScoreDisposalInfoGetRequest) (*security.ScoreDisposalInfoGetResult, error) {
var resp security.ScoreDisposalInfoGetResponse
if err := clt.GetAPI(ctx, "v3.0/security/score_disposal_info/get/", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions marketing-api/api/tools/security/score_violation_event_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package security

import (
"context"

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

// ScoreViolationEventGet 查询违规积分明细
func ScoreViolationEventGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *security.ScoreViolationEventGetRequest) (*security.ScoreViolationEventGetResult, error) {
var resp security.ScoreViolationEventGetResponse
if err := clt.GetAPI(ctx, "v3.0/security/score_violation_event/get/", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
17 changes: 17 additions & 0 deletions marketing-api/api/tools/security/total_score_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package security

import (
"context"

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

// ScoreTotalGet 查询账户累计积分
func ScoreTotalGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *security.ScoreTotalGetRequest) (*security.ScoreTotalGetResult, error) {
var resp security.ScoreTotalGetResponse
if err := clt.GetAPI(ctx, "v3.0/security/score_total/get/", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
11 changes: 11 additions & 0 deletions marketing-api/enum/security_score_illegal_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package enum

// SecurityScoreIllegalType 违规类型
type SecurityScoreIllegalType string

const (
// SecurityScoreIllegalType_GENERAL 一般违规(AD)
SecurityScoreIllegalType_GENERAL SecurityScoreIllegalType = "GENERAL"
// SecurityScoreIllegalType_SERIOUS 严重违规(AD)
SecurityScoreIllegalType_SERIOUS SecurityScoreIllegalType = "SERIOUS"
)
15 changes: 15 additions & 0 deletions marketing-api/enum/security_score_violation_event_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package enum

// SecurityScoreViolationEventStatus 生效状态
type SecurityScoreViolationEventStatus string

const (
// SecurityScoreViolationEventStatus_APPEAL 已申诉(失效)
SecurityScoreViolationEventStatus_APPEAL SecurityScoreViolationEventStatus = "APPEAL"
// SecurityScoreViolationEventStatus_FAILAPPEAL 申诉失败
SecurityScoreViolationEventStatus_FAILAPPEAL SecurityScoreViolationEventStatus = "FAILAPPEAL"
// SecurityScoreViolationEventStatus_ONAPPEAL 申诉中
SecurityScoreViolationEventStatus_ONAPPEAL SecurityScoreViolationEventStatus = "ONAPPEAL"
// SecurityScoreViolationEventStatus_VALID 生效
SecurityScoreViolationEventStatus_VALID SecurityScoreViolationEventStatus = "VALID"
)
76 changes: 50 additions & 26 deletions marketing-api/model/spi/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import (
type Message struct {
// MessageID 唯一标识一条推送消息/数据; 64字符
MessageID string `json:"message_id,omitempty"`
// SubscribeTaskID 订阅任务id,订阅任务的主键; 64字符
SubscribeTaskID uint64 `json:"subscribe_task_id,omitempty"`
// AdvertiserIDs 消息对应的广告主账号,report.advertiser.beforeday 时返回所有已产出的广告主ID组,其余服务类型一次仅返回一个广告主ID
AdvertiserIDs []uint64 `json:"advertiser_ids,omitempty"`
// AccountRelation 推送广告主账号的订阅来源,是订阅的哪个账号下的广告主数据; min=1,max=1k
AccountRelation string `json:"account_relation,omitempty"`
// ServiceLabel 订阅服务类型
ServiceLabel string `json:"service_label,omitempty"`
// Data 推送数据信息,具体结构参考子文档
Data string `json:"data,omitempty"`
// AdvertiserIDs 消息对应的广告主账号,report.advertiser.beforeday 时返回所有已产出的广告主ID组,其余服务类型一次仅返回一个广告主ID
AdvertiserIDs []uint64 `json:"advertiser_ids,omitempty"`
// SubscribeTaskID 订阅任务id,订阅任务的主键; 64字符
SubscribeTaskID uint64 `json:"subscribe_task_id,omitempty"`
// PublishTime 消息实际产生时间
PublishTime int64 `json:"publish_time,omitempty"`
// Timestamp 毫秒时间戳,本条消息实际推送时间
Expand All @@ -34,30 +34,22 @@ type AccountRelation struct {
AgentIDs map[string][]uint64 `json:"agent_ids,omitempty"`
// CoreUserIDs 用户授权账号
CoreUserIDs map[string][]uint64 `json:"core_user_ids,omitempty"`
// AdvertiserIDs 广告主id直接授权
AdvertiserIDs []uint64 `json:"advertiser_ids,omitempty"`
// CcIDs 巨量纵横账号
Ccids map[string][]uint64 `json:"cc_ids,omitempty"`
// AdvertiserIDs 广告主id直接授权
AdvertiserIDs []uint64 `json:"advertiser_ids,omitempty"`
}

// MessageDataBase .
type MessageDataBase struct {
// AppID 应用APPID
AppID uint64 `json:"app_id,omitempty"`
// UserID 创意归属广告主id
UserID uint64 `json:"user_id,omitempty"`
// Event 事件名称
Event string `json:"event,omitempty"`
// FromUserID 触发事件发送者open_id
FromUserID string `json:"from_user_id,omitempty"`
// ToUserID 触发事件接收者open_id
ToUserID string `json:"to_user_id,omitempty"`
// CoreUserID 登陆用户id
CoreUserID uint64 `json:"core_user_id,omitempty"`
// AdvertiserID 广告主I D
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// CoreUserIDs 登陆用户ids
CoreUserIDs []uint64 `json:"core_user_ids,omitempty"`
// AdID 创意归属计划id
AdID uint64 `json:"ad_id,omitempty"`
// AdIDs 聚合周期内发生指标变更的计划列表,service_label 为report.ad.activeprogram时有值
AdIDs []uint64 `json:"ad_ids,omitempty"`
// CreativeIDs 聚合周期内发生指标变更的创意列表,service_label 为report.creative.activeprogram时有值
Expand All @@ -68,22 +60,30 @@ type MessageDataBase struct {
PromotionIDs []uint64 `json:"promotion_ids,omitempty"`
// MaterialIDs 聚合周期内发生指标变更的素材列表,service_label 为report.material.activeprogram时有值
MaterialIDs []uint64 `json:"material_ids,omitempty"`
// Event 事件名称
Event string `json:"event,omitempty"`
// AppID 应用APPID
AppID uint64 `json:"app_id,omitempty"`
// UserID 创意归属广告主id
UserID uint64 `json:"user_id,omitempty"`
// CoreUserID 登陆用户id
CoreUserID uint64 `json:"core_user_id,omitempty"`
// AdvertiserID 广告主I D
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// AdID 创意归属计划id
AdID uint64 `json:"ad_id,omitempty"`
}

// MessageData .
type MessageData struct {
MessageDataBase
// Content 事件内容
Content *EventContent `json:"content,omitempty"`
MessageDataBase
}

// MessageDataV2 .
type MessageDataV2 struct {
MessageDataBase
// Content 事件内容
Content string `json:"content,omitempty"`
MessageDataBase
}

// EventContent 事件内容
Expand Down Expand Up @@ -175,12 +175,8 @@ type EventContent struct {
QualificationType enum.DeliveryQualificationType `json:"qualification_type,omitempty"`
// QualificationID 资质ID
QualificationID []uint64 `json:"qualification_id,omitempty"`
// Status 资质状态
// STATUS_CONFIRM 审核通过
// STATUS_CONFIRM_FAIL 审核不通过
// STATUS_PENDING_CONFIRM 审核中
// STATUS_WAIT_CONFIRM 待审核
Status enum.DeliveryQualificationStatus `json:"status,omitempty"`
// Status 状态
Status string `json:"status,omitempty"`
// MaterialIDs 聚合周期内发生指标变更的素材列表
MaterialIDs []uint64 `json:"material_ids,omitempty"`
// MaterialType 素材类型:
Expand All @@ -189,6 +185,34 @@ type EventContent struct {
MaterialType string `json:"material_type,omitempty"`
// IllegalMaterialIDs 违规素材id list
IllegalMaterialIDs []uint64 `json:"illegal_material_ids,omitempty"`
// EventID 违规单id
EventID uint64 `json:"event_id,omitempty"`
// BusinessLine 业务线AD
BusinessLine string `json:"business_line,omitempty"`
// AdID 计划id(AD2.0为广告id)
AdID uint64 `json:"ad_id,omitempty"`
// MaterialID 素材id
MaterialID uint64 `json:"material_id,omitempty"`
// ViolationEvidenceImg 违规证据截图
ViolationEvidenceImg string `json:"violation_evidence_img,omitempty"`
// Score 扣罚分值
Score int64 `json:"score,omitempty"`
// RejectReason 拒绝理由
RejectReason string `json:"reject_reason,omitempty"`
// IllegalType 违规类型 可选值:
// GENERAL 一般违规(AD)
// SERIOUS 严重违规(AD)
IllegalType enum.SecurityScoreIllegalType `json:"illegal_type,omitempty"`
// DisposalID 处置单id
DisposalID uint64 `json:"disposal_id,omitempty"`
// DisposalTerm 执行时长
DisposalTerm string `json:"disposal_term,omitempty"`
// DisposalStartTime 处置开始时间
DisposalStartTime string `json:"disposal_start_time,omitempty"`
// DisposalEndTime 处置结束时间
DisposalEndTime string `json:"disposal_end_time,omitempty"`
// DisposalReason 处置原因
DisposalReason string `json:"disposal_reason,omitempty"`
}

// CommentUser 用户信息
Expand Down
2 changes: 2 additions & 0 deletions marketing-api/model/tools/security/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package security 风控违规积分
package security
99 changes: 99 additions & 0 deletions marketing-api/model/tools/security/score_disposal_info_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package security

import (
"strconv"

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

// ScoreDisposalInfoGetRequest 查看积分处置详情 API Request
type ScoreDisposalInfoGetRequest struct {
// Filtering 过滤条件
Filtering *ScoreDisposalInfoGetFilter `json:"filtering,omitempty"`
// BusinessLine 业务线,允许值:
// AD 巨量广告
BusinessLine string `json:"business_line,omitempty"`
// OrderField 排序字段 ,允许值:
// disposal_start_time 处置开始时间
// disposal_end_time 处置结束时间
OrderField string `json:"order_field,omitempty"`
// OrderType 排序方式 可选值:
// ASC 升序,默认
// DESC 降序
OrderType string `json:"order_type,omitempty"`
// AdvertiserID 广告主ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// Page 页数,默认值:1,page范围为[1,99999]
Page int `json:"page,omitempty"`
// PageSize 页面大小,默认值:10,page_size范围为[1,100]
PageSize int `json:"page_size,omitempty"`
}

type ScoreDisposalInfoGetFilter struct {
// DisposalAction 处置行为,允许值:
// ACCOUNTCLEAR 账号封停+主体限制新开
// 默认值: ACCOUNTCLEAR
DisposalAction string `json:"disposal_action,omitempty"`
// DisposalStatus 处置状态,允许值:
// DISPOSAL 已处置
// 默认值: DISPOSAL
DisposalStatus string `json:"disposal_status,omitempty"`
}

func (r ScoreDisposalInfoGetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
values.Set("page", strconv.Itoa(r.Page))
values.Set("page_size", strconv.Itoa(r.PageSize))
if r.BusinessLine != "" {
values.Set("business_line", r.BusinessLine)
}
if r.OrderField != "" {
values.Set("order_field", r.OrderField)
}
if r.OrderType != "" {
values.Set("order_type", r.OrderType)
}
if r.Filtering != nil {
values.Set("filtering", string(util.JSONMarshal(r.Filtering)))
}
ret := values.Encode()
util.PutUrlValues(values)
return ret
}

// ScoreDisposalInfoGetResponse 查看积分处置详情 API Response
type ScoreDisposalInfoGetResponse struct {
Data *ScoreDisposalInfoGetResult `json:"data,omitempty"`
model.BaseResponse
}

type ScoreDisposalInfoGetResult struct {
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// DisposalInfoList 处置信息
DisposalInfoList []DisposalInfo `json:"disposal_info_list,omitempty"`
}

// DisposalInfo 处置信息
type DisposalInfo struct {
// DisposalAction 处置行为
// ACCOUNTCLEAR 账户封停+主体限制新建账户
DisposalAction string `json:"disposal_action,omitempty"`
// DisposalTerm 处置时长
DisposalTerm string `json:"disposal_term,omitempty"`
// DisposalStartTime 处置开始时间
DisposalStartTime string `json:"disposal_start_time,omitempty"`
// DisposalEndTime 处置结束时间
DisposalEndTime string `json:"disposal_end_time,omitempty"`
// DisposalStatus 处置状态
// DISPOSAL 已处置
DisposalStatus string `json:"disposal_status,omitempty"`
// OuterText 对外文案
OuterText string `json:"outer_text,omitempty"`
// AdvertiserID 广告主id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// DisposalScore 落罚分值
DisposalScore int64 `json:"disposal_score,omitempty"`
}
Loading

0 comments on commit 3fa233f

Please sign in to comment.