From 3dbcf7a8e33007dc5df54ce0f0f6ee4f879f886f Mon Sep 17 00:00:00 2001 From: lmk <1095689763@qq.com> Date: Fri, 15 May 2026 14:01:15 +0800 Subject: [PATCH] =?UTF-8?q?yidun=E9=80=81=E6=A3=80=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=B4=A6=E6=88=B7=E4=B8=8B=E6=8B=89=E5=92=8C=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consts/dataengine/table.go | 1 + .../dataengine/material_verify_controller.go | 97 +++++++++++++ dao/dataengine/material_verify_log_dao.go | 20 +++ .../tencent_account_relation_dao.go | 33 +++++ .../dataengine/tencent_account_relation.go | 27 ++++ resource/frontend/material-verify.html | 106 ++++++++++---- service/dataengine/material_verify_service.go | 134 ++++++++++++++++++ 7 files changed, 388 insertions(+), 30 deletions(-) create mode 100644 dao/dataengine/tencent_account_relation_dao.go create mode 100644 model/entity/dataengine/tencent_account_relation.go diff --git a/consts/dataengine/table.go b/consts/dataengine/table.go index 531062f..d7797f3 100644 --- a/consts/dataengine/table.go +++ b/consts/dataengine/table.go @@ -5,4 +5,5 @@ const ( TencentImageTable = "tencent_image" // 图片送检表 TencentVideoTable = "tencent_video" // 视频送检表 TencentContentCheckLogTable = "tencent_content_check_log" // 送检日志表 + TencentAccountRelationTable = "tencent_account_relation" // 腾讯广告账户关系表 ) diff --git a/controller/dataengine/material_verify_controller.go b/controller/dataengine/material_verify_controller.go index c6b4559..d4333f2 100644 --- a/controller/dataengine/material_verify_controller.go +++ b/controller/dataengine/material_verify_controller.go @@ -436,6 +436,103 @@ func (c *MaterialVerifyController) BatchVerifyVideo(ctx context.Context, req *Ba }, nil } +// ============================================================================= +// 账户列表接口 +// ============================================================================= + +// ListAccountsReq 账户列表请求 +type ListAccountsReq struct{} + +// AccountItem 账户列表项 +type AccountItem struct { + AccountID int64 `json:"accountId"` + CorporationName string `json:"corporationName"` +} + +// ListAccountsRes 账户列表响应 +type ListAccountsRes struct { + List []AccountItem `json:"list"` +} + +// ListAccounts 获取所有启用的广告账户列表(用于前端下拉筛选) +func (c *MaterialVerifyController) ListAccounts(ctx context.Context, req *ListAccountsReq) (res *ListAccountsRes, err error) { + accounts, err := dao.TencentAccountRelation.GetAll(ctx) + if err != nil { + return nil, err + } + + var items []AccountItem + for _, acc := range accounts { + items = append(items, AccountItem{ + AccountID: acc.AccountID, + CorporationName: acc.CorporationName, + }) + } + + return &ListAccountsRes{ + List: items, + }, nil +} + +// ============================================================================= +// 导出接口 - 不通过数据 +// ============================================================================= + +// ExportRejectedReq 导出不通过数据请求 +type ExportRejectedReq struct { + MaterialType string `json:"materialType"` // IMAGE/VIDEO,为空则导出全部 +} + +// ExportRejectedItem 导出的不通过数据项 +type ExportRejectedItem struct { + ID int64 `json:"id"` + MaterialID string `json:"materialId"` + AccountID int64 `json:"accountId"` + CorporationName string `json:"corporationName"` + PreviewURL string `json:"previewUrl"` + Description string `json:"description"` + ErrorMsg string `json:"errorMsg"` + MaterialType string `json:"materialType"` + ImageUsage string `json:"imageUsage,omitempty"` + CreatedAt string `json:"createdAt"` +} + +// ExportRejectedRes 导出不通过数据响应 +type ExportRejectedRes struct { + Items []ExportRejectedItem `json:"items"` + Total int `json:"total"` +} + +// ExportRejected 导出不通过的图片/视频数据(含失败原因) +func (c *MaterialVerifyController) ExportRejected(ctx context.Context, req *ExportRejectedReq) (res *ExportRejectedRes, err error) { + items, err := serviceDataengine.MaterialVerify.ExportRejectedData(ctx, req.MaterialType) + if err != nil { + return nil, err + } + + // 转换为响应结构 + var respItems []ExportRejectedItem + for _, item := range items { + respItems = append(respItems, ExportRejectedItem{ + ID: item.ID, + MaterialID: item.MaterialID, + AccountID: item.AccountID, + CorporationName: item.CorporationName, + PreviewURL: item.PreviewURL, + Description: item.Description, + ErrorMsg: item.ErrorMsg, + MaterialType: item.MaterialType, + ImageUsage: item.ImageUsage, + CreatedAt: item.CreatedAt, + }) + } + + return &ExportRejectedRes{ + Items: respItems, + Total: len(respItems), + }, nil +} + // ============================================================================= // 回调处理接口 // ============================================================================= diff --git a/dao/dataengine/material_verify_log_dao.go b/dao/dataengine/material_verify_log_dao.go index e531360..42cff75 100644 --- a/dao/dataengine/material_verify_log_dao.go +++ b/dao/dataengine/material_verify_log_dao.go @@ -273,6 +273,26 @@ func (d *MaterialVerifyLogDAO) GetPendingResults(ctx context.Context, limit int) return result, nil } +// GetLastRejectedLogByMaterialID 根据素材ID获取最后一条失败的校验日志 +func (d *MaterialVerifyLogDAO) GetLastRejectedLogByMaterialID(ctx context.Context, materialID string, verifyStatus string) (*daoEntity.MaterialVerifyLog, error) { + var result daoEntity.MaterialVerifyLog + r, err := g.DB("default").Model(MaterialVerifyLogTable). + Where(daoEntity.MaterialVerifyLogCols.MaterialID, materialID). + Where(daoEntity.MaterialVerifyLogCols.VerifyStatus, verifyStatus). + OrderDesc(daoEntity.MaterialVerifyLogCols.CreatedAt). + One() + if err != nil { + return nil, err + } + if r.IsEmpty() { + return nil, nil + } + if err = r.Struct(&result); err != nil { + return nil, err + } + return &result, nil +} + // CountPendingResults 统计待查询结果的数量 func (d *MaterialVerifyLogDAO) CountPendingResults(ctx context.Context) (int, error) { count, err := g.DB("default").Model(MaterialVerifyLogTable). diff --git a/dao/dataengine/tencent_account_relation_dao.go b/dao/dataengine/tencent_account_relation_dao.go new file mode 100644 index 0000000..b32f6c1 --- /dev/null +++ b/dao/dataengine/tencent_account_relation_dao.go @@ -0,0 +1,33 @@ +package dataengine + +import ( + consts "cid/consts/dataengine" + entity "cid/model/entity/dataengine" + "context" + + "github.com/gogf/gf/v2/frame/g" +) + +// TencentAccountRelationDAO 腾讯广告账户关系数据访问层 +type TencentAccountRelationDAO struct{} + +// TencentAccountRelation DAO单例 +var TencentAccountRelation = new(TencentAccountRelationDAO) + +// GetAll 获取所有启用的账户列表 +func (d *TencentAccountRelationDAO) GetAll(ctx context.Context) ([]entity.TencentAccountRelation, error) { + var result []entity.TencentAccountRelation + r, err := Model(consts.TencentAccountRelationTable). + WhereNull("deleted_at"). + OrderAsc(entity.TencentAccountRelationCols.AccountID). + All() + if err != nil { + g.Log().Errorf(ctx, "查询账户关系表失败: %v", err) + return nil, err + } + if err = r.Structs(&result); err != nil { + g.Log().Errorf(ctx, "转换账户关系数据失败: %v", err) + return nil, err + } + return result, nil +} diff --git a/model/entity/dataengine/tencent_account_relation.go b/model/entity/dataengine/tencent_account_relation.go new file mode 100644 index 0000000..5524b59 --- /dev/null +++ b/model/entity/dataengine/tencent_account_relation.go @@ -0,0 +1,27 @@ +package dataengine + +import ( + "gitea.com/red-future/common/beans" +) + +// TencentAccountRelation 腾讯广告账户关系实体(来源:data-engine.tencent_account_relation) +type TencentAccountRelation struct { + beans.SQLBaseDO `orm:",inherit"` + // 业务字段 + AccountID int64 `orm:"account_id" json:"accountId" description:"账户ID"` + CorporationName string `orm:"corporation_name" json:"corporationName" description:"公司名称"` +} + +// TencentAccountRelationCol 账户关系表字段定义 +type TencentAccountRelationCol struct { + beans.SQLBaseCol + AccountID string + CorporationName string +} + +// TencentAccountRelationCols 账户关系表字段常量 +var TencentAccountRelationCols = TencentAccountRelationCol{ + SQLBaseCol: beans.DefSQLBaseCol, + AccountID: "account_id", + CorporationName: "corporation_name", +} diff --git a/resource/frontend/material-verify.html b/resource/frontend/material-verify.html index f62e8d0..2adfe43 100644 --- a/resource/frontend/material-verify.html +++ b/resource/frontend/material-verify.html @@ -255,8 +255,15 @@