This commit is contained in:
Leufolium 2024-07-30 15:35:27 +08:00
parent 2e08c98384
commit d9ef34138b
8 changed files with 133 additions and 10 deletions

View File

@ -58,6 +58,7 @@ const (
StreamerScoreFormulaKey = "streamer_score_formula"
HvyogoSingleDistributeChargePercentageKey = "hvyogo_single_distribute_charge_percentage"
DefaultZoneTextKey = "default_zone_text"
AuditTaskCollectionReflectKey = "audit_task_collection_reflect"
)
// del_flag

View File

@ -2,6 +2,7 @@ package proto
import (
"service/api/base"
"service/bizcommon/util"
"service/dbstruct"
)
@ -61,7 +62,6 @@ type OpListReq struct {
Limit int `json:"limit"`
Sort string
NotAlignedOpt int
IndexName string
}
type OpListData struct {
@ -75,6 +75,18 @@ type OpListResp struct {
Data *OpListData `json:"data"`
}
func (p *OpListReq) GetQueryArgs() (db string, tn string, status int64, offset int, limit int) {
if p == nil {
return "", "", 0, 0, 0
}
db = util.DerefString(p.AssociativeDatabase)
tn = util.DerefString(p.AssociativeTableName)
status = util.DerefInt64(p.Status)
offset = p.Offset
limit = p.Limit
return
}
// op 批量更新
type OpUpdateByIdsReq struct {
base.BaseRequest
@ -105,3 +117,27 @@ type OpReviewBatchResp struct {
base.BaseResponse
Data *OpReviewBatchData `json:"data"`
}
type OpListByCollectionInfosReq struct {
base.BaseRequest
AssociativeCollections []*CollectionInfo `json:"associative_collections"`
Status *int64 `json:"status"`
Offset int `json:"offset"`
Limit int `json:"limit"`
}
type OpListByCollectionInfosData struct {
List []*ImageAuditTaskVO `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
}
type OpListByCollectionInfosResp struct {
base.BaseResponse
Data *OpListByCollectionInfosData `json:"data"`
}
type CollectionInfo struct {
AssociativeDatabase string `json:"associative_data_base"`
AssociativeTableName string `json:"associative_table_name"`
}

View File

@ -0,0 +1,11 @@
package apollostruct
// 账户初始化数据
type AuditTaskCollectionReflectCfg struct {
Map map[string][]*CollectionInfo `json:"map"`
}
type CollectionInfo struct {
Database string `json:"database"` // 数据库
TableName string `json:"table_name"` // 表名
}

View File

@ -3471,7 +3471,6 @@ func (m *Mongo) GetImageAuditTaskList(ctx *gin.Context, req *imageaudittaskproto
if req.Sort != "" {
sortClause = req.Sort
}
opt := options2.Find().SetHint(req.IndexName)
err := col.Find(ctx, query).Sort(sortClause).Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments {
err = nil
@ -3480,6 +3479,36 @@ func (m *Mongo) GetImageAuditTaskList(ctx *gin.Context, req *imageaudittaskproto
return list, err
}
func (m *Mongo) GetImageAuditTaskListByCollectionInfos(ctx *gin.Context, req *imageaudittaskproto.OpListByCollectionInfosReq) ([]*dbstruct.ImageAuditTask, error) {
list := make([]*dbstruct.ImageAuditTask, 0)
col := m.getColImageAuditTask()
query := qmgo.M{
"is_aligned": qmgo.M{
"$ne": consts.ImageAuditIsAligned_Yes,
},
"del_flag": 0,
}
if len(req.AssociativeCollections) > 0 {
orClause := make([]qmgo.M, 0)
for _, collectionInfo := range req.AssociativeCollections {
orClause = append(orClause, qmgo.M{
"associative_database": collectionInfo.AssociativeDatabase,
"associative_table_name": collectionInfo.AssociativeTableName,
})
}
query["$or"] = orClause
}
if req.Status != nil {
query["status"] = util.DerefInt64(req.Status)
}
err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments {
err = nil
return list, err
}
return list, err
}
func (m *Mongo) GetImageAuditTaskListByIds(ctx *gin.Context, ids []string) ([]*dbstruct.ImageAuditTask, error) {
list := make([]*dbstruct.ImageAuditTask, 0)
col := m.getColImageAuditTask()

View File

@ -0,0 +1,4 @@
package logic
type ContentAuditTaskService interface {
}

View File

@ -65,6 +65,15 @@ func (p *ImageAuditTask) OpList(ctx *gin.Context, req *imageaudittaskproto.OpLis
return list, nil
}
func (p *ImageAuditTask) OpListByCollectionInfos(ctx *gin.Context, req *imageaudittaskproto.OpListByCollectionInfosReq) ([]*dbstruct.ImageAuditTask, error) {
list, err := p.store.GetImageAuditTaskListByCollectionInfos(ctx, req)
if err != nil {
logger.Error("GetImageAuditTaskListByCollectionInfos fail, err: %v", err)
return make([]*dbstruct.ImageAuditTask, 0), err
}
return list, nil
}
func (p *ImageAuditTask) OpUpdateByBatchId(ctx *gin.Context, batchId string, imageaudittask *dbstruct.ImageAuditTask) error {
err := p.store.UpdateImageAuditTaskByBatchId(ctx, batchId, imageaudittask)
if err != nil {

View File

@ -3161,10 +3161,44 @@ func (s *Service) OpGetImageAuditTaskVOList(ctx *gin.Context, req *imageaudittas
return
}
// 仅查询未对齐的任务
req.NotAlignedOpt = 1
req.IndexName = "idx_list" // 指定索引
list, err := _DefaultImageAuditTask.OpList(ctx, req)
// 获取映射表
cfg := apollostruct.AuditTaskCollectionReflectCfg{}
err := apollo.GetJson(consts.AuditTaskCollectionReflectKey, &cfg, apollo.ApolloOpts().SetNamespace("application"))
if err != nil {
logger.Error("Apollo read failed : %v", err)
return make([]*imageaudittaskproto.ImageAuditTaskVO, 0), errcode.ErrCodeApolloReadFail
}
// 将查询的集合信息进行映射,决定查询方式
key := fmt.Sprintf("%v|%v", util.DerefString(req.AssociativeDatabase), util.DerefString(req.AssociativeTableName))
collectionInfos, ok := cfg.Map[key]
var queryFunc func(ctx *gin.Context, req *imageaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error)
if !ok || len(collectionInfos) == 0 {
queryFunc = func(ctx *gin.Context, req *imageaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error) {
// 仅查询未对齐的任务
req.NotAlignedOpt = 1
return _DefaultImageAuditTask.OpList(ctx, req)
}
} else {
queryFunc = func(ctx *gin.Context, req *imageaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error) {
associativeCollections := make([]*imageaudittaskproto.CollectionInfo, 0)
for _, collectionInfo := range collectionInfos {
associativeCollections = append(associativeCollections, &imageaudittaskproto.CollectionInfo{
AssociativeDatabase: collectionInfo.Database,
AssociativeTableName: collectionInfo.TableName,
})
}
return _DefaultImageAuditTask.OpListByCollectionInfos(ctx, &imageaudittaskproto.OpListByCollectionInfosReq{
BaseRequest: req.BaseRequest,
AssociativeCollections: associativeCollections,
Status: req.Status,
Offset: req.Offset,
Limit: req.Limit,
})
}
}
list, err := queryFunc(ctx, req)
if err != nil {
logger.Error("OpGetImageAuditTaskListByMid fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeImageAuditTaskSrvFail

View File

@ -33,10 +33,9 @@ func Run(batchId string) (successNum int, failNum int, err error) {
// 查询该批次所有审核任务
imageaudittasks, err := _DefaultImageAuditTask.OpList(&gin.Context{}, &imageaudittaskproto.OpListReq{
BatchId: goproto.String(batchId),
Status: goproto.Int64(consts.ImageAudit_Created),
Sort: "ct",
IndexName: "idx_batch_id",
BatchId: goproto.String(batchId),
Status: goproto.Int64(consts.ImageAudit_Created),
Sort: "ct",
})
if err != nil {
logger.Info("_DefaultImageAuditTask OpList fail: %v", err)