From 2a7c04d4ea0ec794f4a80af103c95f33eee8f847 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 25 Jul 2024 17:49:13 +0800 Subject: [PATCH 1/9] 1 --- app/mix/service/textauditservice.go | 21 ++++++++++++++++ .../service/textaudittask_result_handler.go | 20 ++++++++++++++++ dbstruct/zone.go | 24 ++++++++++--------- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/app/mix/service/textauditservice.go b/app/mix/service/textauditservice.go index 694dd8b3..14201ff8 100644 --- a/app/mix/service/textauditservice.go +++ b/app/mix/service/textauditservice.go @@ -149,6 +149,27 @@ func (s *Service) CreateStreamerAuthApprovalDetailsTextAudit(ctx *gin.Context, n return } +func (s *Service) CreateZoneTextAudit(ctx *gin.Context, newZone *dbstruct.Zone) (tasks []*dbstruct.TextAuditTask) { + tasks = make([]*dbstruct.TextAuditTask, 0) + + if newZone.Profile != nil { + + tasks = append(tasks, &dbstruct.TextAuditTask{ + RouteUrl: goproto.String(ctx.Request.URL.Path), + AssociativeDatabase: goproto.String("zone"), + AssociativeTableName: goproto.String("zone"), + AssociativeTableId: newZone.Id, + AssociativeTableColumn: goproto.String("profile"), + AuditedText: newZone.Profile, + OldText: goproto.String(""), + }) + } + + addTextAuditTasks(ctx, tasks, true) + + return +} + func addTextAuditTasks(ctx *gin.Context, tasks []*dbstruct.TextAuditTask, options ...any) error { for _, task := range tasks { err := addTextAuditTask(ctx, task, options...) diff --git a/app/mix/service/textaudittask_result_handler.go b/app/mix/service/textaudittask_result_handler.go index 52821565..19c69bdb 100644 --- a/app/mix/service/textaudittask_result_handler.go +++ b/app/mix/service/textaudittask_result_handler.go @@ -7,6 +7,7 @@ import ( momentproto "service/api/proto/moment/proto" streamerproto "service/api/proto/streamer/proto" streamerauthapprovaldetailsproto "service/api/proto/streamerauthapprovaldetails/proto" + zoneproto "service/api/proto/zone/proto" zonemomentproto "service/api/proto/zonemoment/proto" "service/bizcommon/util" "service/dbstruct" @@ -44,6 +45,7 @@ func (handler *TextAuditTaskResultHandler) initTextAuditTaskUpdateFuncGeneratorM handler.generateZoneMomentTextUpdateFunc() handler.generateStreamerAuthApprovalDetailsBioUpdateFunc() handler.generateStreamerAuthApprovalDetailsAutoResponseMessageUpdateFunc() + handler.generateZoneProfileUpdateFunc() } func (handler *TextAuditTaskResultHandler) getTextAuditTaskUpdateFunc(ctx *gin.Context, task *dbstruct.TextAuditTask, option int) func() error { @@ -223,6 +225,24 @@ func (handler *TextAuditTaskResultHandler) generateZoneMomentTextUpdateFunc() { } } +// 空间表->简介 +func (handler *TextAuditTaskResultHandler) generateZoneProfileUpdateFunc() { + handler.textAuditTaskUpdateFuncGeneratorMap["zone|zone|profile"] = func(ctx *gin.Context, task *dbstruct.TextAuditTask, option int) func() error { + return func() error { + id := task.AssociativeTableId + auditcomp, reviewcomp, finalText := getTextUpdateInfo(task, option) + return _DefaultZone.OpUpdate(ctx, &zoneproto.OpUpdateReq{ + Zone: &dbstruct.Zone{ + Id: id, + Profile: finalText, + ProfileAudit: auditcomp, + ProfileReview: reviewcomp, + }, + }) + } + } +} + // 尝试完成审核 func tryToFinishTextAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.TextAuditTask) error { // 机审通过,尝试触发moment_audit_task的人审 diff --git a/dbstruct/zone.go b/dbstruct/zone.go index 1b89ec0e..44a89946 100644 --- a/dbstruct/zone.go +++ b/dbstruct/zone.go @@ -1,17 +1,19 @@ package dbstruct type Zone struct { - Id *int64 `json:"id" bson:"_id"` // 空间表id - Mid *int64 `json:"mid" bson:"mid"` // 用户表id - Profile *string `json:"profile" bson:"profile"` // 空间简介 - LastZoneMomentCt *int64 `json:"last_zone_moment_ct" bson:"last_zone_moment_ct"` // 最后空间动态创建时间 - ZoneMomentCount *int64 `json:"zone_moment_count" bson:"zone_moment_count"` // 空间内动态总数 - ImageCount *int64 `json:"image_count" bson:"image_count"` // 空间内图片总数 - VideoCount *int64 `json:"video_count" bson:"video_count"` // 空间内视频总数 - IsZoneThirdPartnerHided *int64 `json:"is_zone_third_partner_hided" bson:"is_zone_third_partner_hided"` // 是否隐藏空间代运营 - Ct *int64 `json:"ct" bson:"ct"` // 创建时间 - Ut *int64 `json:"ut" bson:"ut"` // 更新时间 - DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记 + Id *int64 `json:"id" bson:"_id"` // 空间表id + Mid *int64 `json:"mid" bson:"mid"` // 用户表id + Profile *string `json:"profile" bson:"profile"` // 空间简介 + LastZoneMomentCt *int64 `json:"last_zone_moment_ct" bson:"last_zone_moment_ct"` // 最后空间动态创建时间 + ZoneMomentCount *int64 `json:"zone_moment_count" bson:"zone_moment_count"` // 空间内动态总数 + ImageCount *int64 `json:"image_count" bson:"image_count"` // 空间内图片总数 + VideoCount *int64 `json:"video_count" bson:"video_count"` // 空间内视频总数 + IsZoneThirdPartnerHided *int64 `json:"is_zone_third_partner_hided" bson:"is_zone_third_partner_hided"` // 是否隐藏空间代运营 + Ct *int64 `json:"ct" bson:"ct"` // 创建时间 + Ut *int64 `json:"ut" bson:"ut"` // 更新时间 + DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记 + ProfileAudit *AuditComponent `json:"profile_audit" bson:"profile_audit"` // 空间简介审核 + ProfileReview *AuditComponent `json:"profile_review" bson:"profile_review"` // 空间简介人审 } func (p *Zone) GetId() int64 { From 8fcef422bb49e142f4d486ac70ec3e09565c0ed6 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Mon, 29 Jul 2024 15:48:39 +0800 Subject: [PATCH 2/9] by Robin at 20240729 --- api/consts/consts.go | 1 + app/mix/service/apiservice.go | 18 ++++++++++++++++++ dbstruct/zone.go | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/api/consts/consts.go b/api/consts/consts.go index 04fe0472..666e4274 100644 --- a/api/consts/consts.go +++ b/api/consts/consts.go @@ -57,6 +57,7 @@ const ( ZoneVIPConfigKey = "zone_vip_config" StreamerScoreFormulaKey = "streamer_score_formula" HvyogoSingleDistributeChargePercentageKey = "hvyogo_single_distribute_charge_percentage" + DefaultZoneTextKey = "default_zone_text" ) // del_flag diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 5df27ac9..669fe6df 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2530,11 +2530,23 @@ func (s *Service) ApiCreateZone(ctx *gin.Context, req *zoneproto.ApiCreateReq) ( return } + //读取默认动态文字配置 + defaultZoneText, err := apollo.GetStringValue(consts.DefaultZoneTextKey, apollo.ApolloOpts().SetNamespace("application")) + if err != nil { + logger.Error("Apollo read failed : %v", err) + ec = errcode.ErrCodeApolloReadFail + return + } + + // 暂存空间简介 + profile := req.Zone.GetProfile() + req.Zone.Mid = goproto.Int64(req.GetBaseRequest().Mid) req.Zone.ZoneMomentCount = goproto.Int64(0) req.Zone.ImageCount = goproto.Int64(0) req.Zone.VideoCount = goproto.Int64(0) req.Zone.IsZoneThirdPartnerHided = goproto.Int64(consts.IsHided_No) + req.Zone.Profile = goproto.String(defaultZoneText) err, zid := _DefaultZone.OpCreate(ctx, &zoneproto.OpCreateReq{ Zone: req.Zone, }) @@ -2564,6 +2576,10 @@ func (s *Service) ApiCreateZone(ctx *gin.Context, req *zoneproto.ApiCreateReq) ( return } + // 创建文字审核任务 + req.Zone.Profile = goproto.String(profile) + s.CreateZoneTextAudit(ctx, req.Zone) + // 创建默认动态 cfg := apollostruct.ReferentialZoneMoment{} err = apollo.GetJson(consts.ReferentialZoneMomentKey, &cfg, apollo.ApolloOpts().SetNamespace("zone")) @@ -2628,6 +2644,8 @@ func (s *Service) ApiUpdateZone(ctx *gin.Context, req *zoneproto.ApiUpdateReq) ( return } + s.CreateZoneTextAudit(ctx, req.Zone) + return } diff --git a/dbstruct/zone.go b/dbstruct/zone.go index 44a89946..f73accfa 100644 --- a/dbstruct/zone.go +++ b/dbstruct/zone.go @@ -43,3 +43,10 @@ func (p *Zone) GetIsZoneThirdPartnerHided() int64 { } return 0 } + +func (p *Zone) GetProfile() string { + if p != nil && p.Profile != nil { + return *p.Profile + } + return "" +} From 2e08c98384d0aafc788cb2ba5b344e1f7202bb9f Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 30 Jul 2024 12:08:21 +0800 Subject: [PATCH 3/9] 1 --- api/proto/imageaudittask/proto/imageaudittask_op.go | 1 + app/mix/dao/mongo.go | 1 + app/mix/service/service.go | 2 +- library/contentaudit/imageaudit/imageaudit.go | 7 ++++--- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/proto/imageaudittask/proto/imageaudittask_op.go b/api/proto/imageaudittask/proto/imageaudittask_op.go index 99b81dbb..edea796a 100644 --- a/api/proto/imageaudittask/proto/imageaudittask_op.go +++ b/api/proto/imageaudittask/proto/imageaudittask_op.go @@ -61,6 +61,7 @@ type OpListReq struct { Limit int `json:"limit"` Sort string NotAlignedOpt int + IndexName string } type OpListData struct { diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 2c327b66..51370a72 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -3471,6 +3471,7 @@ 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 diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 97361b59..93747f66 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3163,7 +3163,7 @@ func (s *Service) OpGetImageAuditTaskVOList(ctx *gin.Context, req *imageaudittas // 仅查询未对齐的任务 req.NotAlignedOpt = 1 - + req.IndexName = "idx_list" // 指定索引 list, err := _DefaultImageAuditTask.OpList(ctx, req) if err != nil { logger.Error("OpGetImageAuditTaskListByMid fail, req: %v, err: %v", util.ToJson(req), err) diff --git a/library/contentaudit/imageaudit/imageaudit.go b/library/contentaudit/imageaudit/imageaudit.go index b247281c..81ace85a 100644 --- a/library/contentaudit/imageaudit/imageaudit.go +++ b/library/contentaudit/imageaudit/imageaudit.go @@ -33,9 +33,10 @@ 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", + BatchId: goproto.String(batchId), + Status: goproto.Int64(consts.ImageAudit_Created), + Sort: "ct", + IndexName: "idx_batch_id", }) if err != nil { logger.Info("_DefaultImageAuditTask OpList fail: %v", err) From d9ef34138b577d5c4717968cac5ce0d396d65627 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 30 Jul 2024 15:35:27 +0800 Subject: [PATCH 4/9] 1 --- api/consts/consts.go | 1 + .../imageaudittask/proto/imageaudittask_op.go | 38 ++++++++++++++++- apollostruct/audit_task_collection_reflect.go | 11 +++++ app/mix/dao/mongo.go | 31 +++++++++++++- app/mix/service/logic/audit_task_decorator.go | 4 ++ app/mix/service/logic/imageaudittask.go | 9 ++++ app/mix/service/service.go | 42 +++++++++++++++++-- library/contentaudit/imageaudit/imageaudit.go | 7 ++-- 8 files changed, 133 insertions(+), 10 deletions(-) create mode 100644 apollostruct/audit_task_collection_reflect.go create mode 100644 app/mix/service/logic/audit_task_decorator.go diff --git a/api/consts/consts.go b/api/consts/consts.go index 666e4274..20f81e3f 100644 --- a/api/consts/consts.go +++ b/api/consts/consts.go @@ -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 diff --git a/api/proto/imageaudittask/proto/imageaudittask_op.go b/api/proto/imageaudittask/proto/imageaudittask_op.go index edea796a..e1ffae8c 100644 --- a/api/proto/imageaudittask/proto/imageaudittask_op.go +++ b/api/proto/imageaudittask/proto/imageaudittask_op.go @@ -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"` +} diff --git a/apollostruct/audit_task_collection_reflect.go b/apollostruct/audit_task_collection_reflect.go new file mode 100644 index 00000000..312ca3fd --- /dev/null +++ b/apollostruct/audit_task_collection_reflect.go @@ -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"` // 表名 +} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 51370a72..37410720 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -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() diff --git a/app/mix/service/logic/audit_task_decorator.go b/app/mix/service/logic/audit_task_decorator.go new file mode 100644 index 00000000..c4e78828 --- /dev/null +++ b/app/mix/service/logic/audit_task_decorator.go @@ -0,0 +1,4 @@ +package logic + +type ContentAuditTaskService interface { +} diff --git a/app/mix/service/logic/imageaudittask.go b/app/mix/service/logic/imageaudittask.go index 44326651..822123e9 100644 --- a/app/mix/service/logic/imageaudittask.go +++ b/app/mix/service/logic/imageaudittask.go @@ -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 { diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 93747f66..6428ba9e 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -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 diff --git a/library/contentaudit/imageaudit/imageaudit.go b/library/contentaudit/imageaudit/imageaudit.go index 81ace85a..b247281c 100644 --- a/library/contentaudit/imageaudit/imageaudit.go +++ b/library/contentaudit/imageaudit/imageaudit.go @@ -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) From 7af7d2d6f1fd024652ce81f5dcd30e2a60c0eba8 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 30 Jul 2024 18:40:15 +0800 Subject: [PATCH 5/9] by Robin at 20240730 --- .../imageaudittask/proto/imageaudittask_op.go | 37 ----- app/mix/dao/mongo.go | 94 +++++++++++-- app/mix/service/logic/audit_task_decorator.go | 131 +++++++++++++++++- app/mix/service/logic/imageaudittask.go | 4 +- app/mix/service/logic/textaudittask.go | 9 ++ .../service/logic/video_moderation_task.go | 9 ++ app/mix/service/service.go | 54 ++------ 7 files changed, 241 insertions(+), 97 deletions(-) diff --git a/api/proto/imageaudittask/proto/imageaudittask_op.go b/api/proto/imageaudittask/proto/imageaudittask_op.go index e1ffae8c..99b81dbb 100644 --- a/api/proto/imageaudittask/proto/imageaudittask_op.go +++ b/api/proto/imageaudittask/proto/imageaudittask_op.go @@ -2,7 +2,6 @@ package proto import ( "service/api/base" - "service/bizcommon/util" "service/dbstruct" ) @@ -75,18 +74,6 @@ 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 @@ -117,27 +104,3 @@ 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"` -} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 37410720..34e1c973 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -3479,29 +3479,31 @@ 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) { +func (m *Mongo) GetImageAuditTaskListByCollectionInfos(ctx *gin.Context, databases []string, tableNames []string, status int64, offset, limit int) ([]*dbstruct.ImageAuditTask, error) { list := make([]*dbstruct.ImageAuditTask, 0) + + if len(databases) != len(tableNames) { + return list, fmt.Errorf("length of databases is not equal to length of tableNames") + } + col := m.getColImageAuditTask() query := qmgo.M{ "is_aligned": qmgo.M{ "$ne": consts.ImageAuditIsAligned_Yes, }, + "status": status, "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 + + orClause := make([]qmgo.M, 0) + for i := range databases { + orClause = append(orClause, qmgo.M{ + "associative_database": databases[i], + "associative_table_name": tableNames[i], + }) } - 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) + query["$or"] = orClause + err := col.Find(ctx, query).Sort("-ct").Skip(int64(offset)).Limit(int64(limit)).All(&list) if err == qmgo.ErrNoSuchDocuments { err = nil return list, err @@ -3745,6 +3747,38 @@ func (m *Mongo) GetTextAuditTaskList(ctx *gin.Context, req *textaudittaskproto.O return list, err } +func (m *Mongo) GetTextAuditTaskListByCollectionInfos(ctx *gin.Context, databases []string, tableNames []string, status int64, offset, limit int) ([]*dbstruct.TextAuditTask, error) { + list := make([]*dbstruct.TextAuditTask, 0) + + if len(databases) != len(tableNames) { + return list, fmt.Errorf("length of databases is not equal to length of tableNames") + } + + col := m.getColTextAuditTask() + query := qmgo.M{ + "is_aligned": qmgo.M{ + "$ne": consts.TextAuditIsAligned_Yes, + }, + "status": status, + "del_flag": 0, + } + + orClause := make([]qmgo.M, 0) + for i := range databases { + orClause = append(orClause, qmgo.M{ + "associative_database": databases[i], + "associative_table_name": tableNames[i], + }) + } + query["$or"] = orClause + err := col.Find(ctx, query).Sort("-ct").Skip(int64(offset)).Limit(int64(limit)).All(&list) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return list, err + } + return list, err +} + func (m *Mongo) GetTextAuditTaskListByIds(ctx *gin.Context, ids []string) ([]*dbstruct.TextAuditTask, error) { list := make([]*dbstruct.TextAuditTask, 0) col := m.getColTextAuditTask() @@ -5644,6 +5678,38 @@ func (m *Mongo) GetVideoModerationTaskList(ctx *gin.Context, req *video_moderati return list, err } +func (m *Mongo) GetVideoModerationTaskListByCollectionInfos(ctx *gin.Context, databases []string, tableNames []string, status int64, offset, limit int) ([]*dbstruct.VideoModerationTask, error) { + list := make([]*dbstruct.VideoModerationTask, 0) + + if len(databases) != len(tableNames) { + return list, fmt.Errorf("length of databases is not equal to length of tableNames") + } + + col := m.getColVideoModerationTask() + query := qmgo.M{ + "is_aligned": qmgo.M{ + "$ne": consts.VideoModerationIsAligned_Yes, + }, + "status": status, + "del_flag": 0, + } + + orClause := make([]qmgo.M, 0) + for i := range databases { + orClause = append(orClause, qmgo.M{ + "associative_database": databases[i], + "associative_table_name": tableNames[i], + }) + } + query["$or"] = orClause + err := col.Find(ctx, query).Sort("-ct").Skip(int64(offset)).Limit(int64(limit)).All(&list) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return list, err + } + return list, err +} + func (m *Mongo) GetVideoModerationTaskListByIds(ctx *gin.Context, ids []string) ([]*dbstruct.VideoModerationTask, error) { list := make([]*dbstruct.VideoModerationTask, 0) col := m.getColVideoModerationTask() diff --git a/app/mix/service/logic/audit_task_decorator.go b/app/mix/service/logic/audit_task_decorator.go index c4e78828..87126ad3 100644 --- a/app/mix/service/logic/audit_task_decorator.go +++ b/app/mix/service/logic/audit_task_decorator.go @@ -1,4 +1,133 @@ package logic -type ContentAuditTaskService interface { +import ( + "fmt" + "service/api/consts" + imageaudittaskproto "service/api/proto/imageaudittask/proto" + textaudittaskproto "service/api/proto/textaudittask/proto" + videomoderationtaskproto "service/api/proto/video_moderation_task/proto" + "service/apollostruct" + "service/bizcommon/util" + "service/dbstruct" + "service/library/apollo" + "service/library/logger" + + "github.com/gin-gonic/gin" +) + +type ImageAuditTaskDecorator struct { + ImageAuditTask *ImageAuditTask +} + +func (p *ImageAuditTaskDecorator) OpList(ctx *gin.Context, req *imageaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error) { + + // 获取映射表 + 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([]*dbstruct.ImageAuditTask, 0), err + } + + // 将查询的集合信息进行映射,决定查询方式 + 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 p.ImageAuditTask.OpList(ctx, req) + } + } else { + queryFunc = func(ctx *gin.Context, req *imageaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error) { + databases := make([]string, 0) + tableNames := make([]string, 0) + for _, collectionInfo := range collectionInfos { + databases = append(databases, collectionInfo.Database) + tableNames = append(tableNames, collectionInfo.TableName) + } + return p.ImageAuditTask.OpListByCollectionInfos(ctx, databases, tableNames, util.DerefInt64(req.Status), req.Offset, req.Limit) + } + } + return queryFunc(ctx, req) +} + +type TextAuditTaskDecorator struct { + TextAuditTask *TextAuditTask +} + +func (p *TextAuditTaskDecorator) OpList(ctx *gin.Context, req *textaudittaskproto.OpListReq) ([]*dbstruct.TextAuditTask, error) { + + // 获取映射表 + 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([]*dbstruct.TextAuditTask, 0), err + } + + // 将查询的集合信息进行映射,决定查询方式 + 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 *textaudittaskproto.OpListReq) ([]*dbstruct.TextAuditTask, error) + if !ok || len(collectionInfos) == 0 { + queryFunc = func(ctx *gin.Context, req *textaudittaskproto.OpListReq) ([]*dbstruct.TextAuditTask, error) { + // 仅查询未对齐的任务 + req.NotAlignedOpt = 1 + return p.TextAuditTask.OpList(ctx, req) + } + } else { + queryFunc = func(ctx *gin.Context, req *textaudittaskproto.OpListReq) ([]*dbstruct.TextAuditTask, error) { + databases := make([]string, 0) + tableNames := make([]string, 0) + for _, collectionInfo := range collectionInfos { + databases = append(databases, collectionInfo.Database) + tableNames = append(tableNames, collectionInfo.TableName) + } + return p.TextAuditTask.OpListByCollectionInfos(ctx, databases, tableNames, util.DerefInt64(req.Status), req.Offset, req.Limit) + } + } + return queryFunc(ctx, req) +} + +type VideoModerationTaskDecorator struct { + VideoModerationTask *VideoModerationTask +} + +func (p *VideoModerationTaskDecorator) OpList(ctx *gin.Context, req *videomoderationtaskproto.OpListReq) ([]*dbstruct.VideoModerationTask, error) { + + // 获取映射表 + 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([]*dbstruct.VideoModerationTask, 0), err + } + + // 将查询的集合信息进行映射,决定查询方式 + 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 *videomoderationtaskproto.OpListReq) ([]*dbstruct.VideoModerationTask, error) + if !ok || len(collectionInfos) == 0 { + queryFunc = func(ctx *gin.Context, req *videomoderationtaskproto.OpListReq) ([]*dbstruct.VideoModerationTask, error) { + // 仅查询未对齐的任务 + req.NotAlignedOpt = 1 + return p.VideoModerationTask.OpList(ctx, req) + } + } else { + queryFunc = func(ctx *gin.Context, req *videomoderationtaskproto.OpListReq) ([]*dbstruct.VideoModerationTask, error) { + databases := make([]string, 0) + tableNames := make([]string, 0) + for _, collectionInfo := range collectionInfos { + databases = append(databases, collectionInfo.Database) + tableNames = append(tableNames, collectionInfo.TableName) + } + return p.VideoModerationTask.OpListByCollectionInfos(ctx, databases, tableNames, util.DerefInt64(req.Status), req.Offset, req.Limit) + } + } + return queryFunc(ctx, req) } diff --git a/app/mix/service/logic/imageaudittask.go b/app/mix/service/logic/imageaudittask.go index 822123e9..1cc263fa 100644 --- a/app/mix/service/logic/imageaudittask.go +++ b/app/mix/service/logic/imageaudittask.go @@ -65,8 +65,8 @@ 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) +func (p *ImageAuditTask) OpListByCollectionInfos(ctx *gin.Context, databases []string, tableNames []string, status int64, offset, limit int) ([]*dbstruct.ImageAuditTask, error) { + list, err := p.store.GetImageAuditTaskListByCollectionInfos(ctx, databases, tableNames, status, offset, limit) if err != nil { logger.Error("GetImageAuditTaskListByCollectionInfos fail, err: %v", err) return make([]*dbstruct.ImageAuditTask, 0), err diff --git a/app/mix/service/logic/textaudittask.go b/app/mix/service/logic/textaudittask.go index 879c8bfb..66c697e3 100644 --- a/app/mix/service/logic/textaudittask.go +++ b/app/mix/service/logic/textaudittask.go @@ -65,6 +65,15 @@ func (p *TextAuditTask) OpList(ctx *gin.Context, req *textaudittaskproto.OpListR return list, nil } +func (p *TextAuditTask) OpListByCollectionInfos(ctx *gin.Context, databases []string, tableNames []string, status int64, offset, limit int) ([]*dbstruct.TextAuditTask, error) { + list, err := p.store.GetTextAuditTaskListByCollectionInfos(ctx, databases, tableNames, status, offset, limit) + if err != nil { + logger.Error("GetTextAuditTaskListByCollectionInfos fail, err: %v", err) + return make([]*dbstruct.TextAuditTask, 0), err + } + return list, nil +} + func (p *TextAuditTask) OpUpdateByBatchId(ctx *gin.Context, batchId string, textaudittask *dbstruct.TextAuditTask) error { err := p.store.UpdateTextAuditTaskByBatchId(ctx, batchId, textaudittask) if err != nil { diff --git a/app/mix/service/logic/video_moderation_task.go b/app/mix/service/logic/video_moderation_task.go index 40ba0ce7..74747e76 100644 --- a/app/mix/service/logic/video_moderation_task.go +++ b/app/mix/service/logic/video_moderation_task.go @@ -65,6 +65,15 @@ func (p *VideoModerationTask) OpList(ctx *gin.Context, req *video_moderation_tas return list, nil } +func (p *VideoModerationTask) OpListByCollectionInfos(ctx *gin.Context, databases []string, tableNames []string, status int64, offset, limit int) ([]*dbstruct.VideoModerationTask, error) { + list, err := p.store.GetVideoModerationTaskListByCollectionInfos(ctx, databases, tableNames, status, offset, limit) + if err != nil { + logger.Error("GetVideoModerationTaskListByCollectionInfos fail, err: %v", err) + return make([]*dbstruct.VideoModerationTask, 0), err + } + return list, nil +} + func (p *VideoModerationTask) OpUpdateByBatchId(ctx *gin.Context, batchId string, video_moderation_task *dbstruct.VideoModerationTask) error { err := p.store.UpdateVideoModerationTaskByBatchId(ctx, batchId, video_moderation_task) if err != nil { diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 6428ba9e..081a3b5e 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3161,44 +3161,10 @@ func (s *Service) OpGetImageAuditTaskVOList(ctx *gin.Context, req *imageaudittas return } - // 获取映射表 - 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 + imageAuditTaskProxy := &logic.ImageAuditTaskDecorator{ + ImageAuditTask: _DefaultImageAuditTask, } - - // 将查询的集合信息进行映射,决定查询方式 - 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) + list, err := imageAuditTaskProxy.OpList(ctx, req) if err != nil { logger.Error("OpGetImageAuditTaskListByMid fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeImageAuditTaskSrvFail @@ -3287,10 +3253,10 @@ func (s *Service) OpGetTextAuditTaskVOList(ctx *gin.Context, req *textaudittaskp return } - // 仅查询未对齐的任务 - req.NotAlignedOpt = 1 - - list, err := _DefaultTextAuditTask.OpList(ctx, req) + textAuditTaskProxy := &logic.TextAuditTaskDecorator{ + TextAuditTask: _DefaultTextAuditTask, + } + list, err := textAuditTaskProxy.OpList(ctx, req) if err != nil { logger.Error("OpGetTextAuditTaskListByMid fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeTextAuditTaskSrvFail @@ -3376,9 +3342,11 @@ func (s *Service) OpGetVideoModerationTaskVOList(ctx *gin.Context, req *videomod ec = errcode.ErrCodeVideoModerationTaskSrvOk // 仅查询未对齐的任务 - req.NotAlignedOpt = 1 + videoModerationTaskProxy := &logic.VideoModerationTaskDecorator{ + VideoModerationTask: _DefaultVideoModerationTask, + } - list, err := _DefaultVideoModerationTask.OpList(ctx, req) + list, err := videoModerationTaskProxy.OpList(ctx, req) if err != nil { logger.Error("OpGetVideoModerationTaskListByMid fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeVideoModerationTaskSrvFail From dbda736b5d8c336a7d6a799f936d6b9849dd7a9a Mon Sep 17 00:00:00 2001 From: Leufolium Date: Wed, 31 Jul 2024 15:55:59 +0800 Subject: [PATCH 6/9] by Robin at 20240731 --- api/proto/imageaudittask/proto/imageaudittask_op.go | 2 +- api/proto/textaudittask/proto/textaudittask_op.go | 2 +- .../video_moderation_task/proto/video_moderation_task_op.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/proto/imageaudittask/proto/imageaudittask_op.go b/api/proto/imageaudittask/proto/imageaudittask_op.go index 99b81dbb..fc4d3987 100644 --- a/api/proto/imageaudittask/proto/imageaudittask_op.go +++ b/api/proto/imageaudittask/proto/imageaudittask_op.go @@ -51,7 +51,7 @@ type OpUpdateResp struct { type OpListReq struct { base.BaseRequest RouteUrl *string `json:"route_url"` - AssociativeDatabase *string `json:"associative_data_base"` + AssociativeDatabase *string `json:"associative_database"` AssociativeTableName *string `json:"associative_table_name"` AssociativeTableId *int64 `json:"associative_table_id"` AssociativeTableColumn *string `json:"associative_table_column"` diff --git a/api/proto/textaudittask/proto/textaudittask_op.go b/api/proto/textaudittask/proto/textaudittask_op.go index 735ff153..1028960d 100644 --- a/api/proto/textaudittask/proto/textaudittask_op.go +++ b/api/proto/textaudittask/proto/textaudittask_op.go @@ -51,7 +51,7 @@ type OpUpdateResp struct { type OpListReq struct { base.BaseRequest RouteUrl *string `json:"route_url"` - AssociativeDatabase *string `json:"associative_data_base"` + AssociativeDatabase *string `json:"associative_database"` AssociativeTableName *string `json:"associative_table_name"` AssociativeTableId *int64 `json:"associative_table_id"` AssociativeTableColumn *string `json:"associative_table_column"` diff --git a/api/proto/video_moderation_task/proto/video_moderation_task_op.go b/api/proto/video_moderation_task/proto/video_moderation_task_op.go index 8641d222..7e04011c 100644 --- a/api/proto/video_moderation_task/proto/video_moderation_task_op.go +++ b/api/proto/video_moderation_task/proto/video_moderation_task_op.go @@ -51,7 +51,7 @@ type OpUpdateResp struct { type OpListReq struct { base.BaseRequest RouteUrl *string `json:"route_url"` - AssociativeDatabase *string `json:"associative_data_base"` + AssociativeDatabase *string `json:"associative_database"` AssociativeTableName *string `json:"associative_table_name"` AssociativeTableId *int64 `json:"associative_table_id"` AssociativeTableColumn *string `json:"associative_table_column"` From 70febfc4217f7cdcab5f7a4ed30d079e1e8c6715 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Wed, 31 Jul 2024 16:08:51 +0800 Subject: [PATCH 7/9] by Robin at 20240731 --- app/mix/service/imageauditservice.go | 2 ++ app/mix/service/textauditservice.go | 3 +++ app/mix/service/video_moderation_service.go | 1 + 3 files changed, 6 insertions(+) diff --git a/app/mix/service/imageauditservice.go b/app/mix/service/imageauditservice.go index 8a0a70ed..a106cf7b 100644 --- a/app/mix/service/imageauditservice.go +++ b/app/mix/service/imageauditservice.go @@ -119,6 +119,7 @@ func (s *Service) CreateStreamerAuthApprovalDetailsImageAudit(ctx *gin.Context, if newStreamerAuthApprovalDetails.Cover != nil && len(newStreamerAuthApprovalDetails.Cover.GetImageIds()) > 0 { tasks = append(tasks, &dbstruct.ImageAuditTask{ + Mid: newStreamerAuthApprovalDetails.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer_auth_approval_details"), AssociativeTableName: goproto.String("streamer_auth_approval_details"), @@ -132,6 +133,7 @@ func (s *Service) CreateStreamerAuthApprovalDetailsImageAudit(ctx *gin.Context, if newStreamerAuthApprovalDetails.Album != nil && len(newStreamerAuthApprovalDetails.Album.GetImageIds()) > 0 { tasks = append(tasks, &dbstruct.ImageAuditTask{ + Mid: newStreamerAuthApprovalDetails.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer_auth_approval_details"), AssociativeTableName: goproto.String("streamer_auth_approval_details"), diff --git a/app/mix/service/textauditservice.go b/app/mix/service/textauditservice.go index 14201ff8..4f5f037f 100644 --- a/app/mix/service/textauditservice.go +++ b/app/mix/service/textauditservice.go @@ -121,6 +121,7 @@ func (s *Service) CreateStreamerAuthApprovalDetailsTextAudit(ctx *gin.Context, n if newStreamerAuthApprovalDetails.Bio != nil { tasks = append(tasks, &dbstruct.TextAuditTask{ + Mid: newStreamerAuthApprovalDetails.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer_auth_approval_details"), AssociativeTableName: goproto.String("streamer_auth_approval_details"), @@ -134,6 +135,7 @@ func (s *Service) CreateStreamerAuthApprovalDetailsTextAudit(ctx *gin.Context, n if newStreamerAuthApprovalDetails.AutoResponseMessage != nil { tasks = append(tasks, &dbstruct.TextAuditTask{ + Mid: newStreamerAuthApprovalDetails.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer_auth_approval_details"), AssociativeTableName: goproto.String("streamer_auth_approval_details"), @@ -155,6 +157,7 @@ func (s *Service) CreateZoneTextAudit(ctx *gin.Context, newZone *dbstruct.Zone) if newZone.Profile != nil { tasks = append(tasks, &dbstruct.TextAuditTask{ + Mid: newZone.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("zone"), AssociativeTableName: goproto.String("zone"), diff --git a/app/mix/service/video_moderation_service.go b/app/mix/service/video_moderation_service.go index 01790a3c..dfd0d90a 100644 --- a/app/mix/service/video_moderation_service.go +++ b/app/mix/service/video_moderation_service.go @@ -79,6 +79,7 @@ func (s *Service) CreateStreamerAuthApprovalDetailsVideoModeration(ctx *gin.Cont if newStreamerAuthApprovalDetails.Shorts != nil && len(newStreamerAuthApprovalDetails.Shorts.GetVideoIds()) > 0 { tasks = append(tasks, &dbstruct.VideoModerationTask{ + Mid: newStreamerAuthApprovalDetails.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer_auth_approval_details"), AssociativeTableName: goproto.String("streamer_auth_approval_details"), From bbb3f06e3a3628064d2b5edef5d9e2bcdb308265 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Wed, 31 Jul 2024 16:50:37 +0800 Subject: [PATCH 8/9] 1 --- app/mix/service/apiservice.go | 22 +++++++++++++++++++--- app/mix/service/textauditservice.go | 9 +++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 669fe6df..a24c0bbf 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2578,7 +2578,7 @@ func (s *Service) ApiCreateZone(ctx *gin.Context, req *zoneproto.ApiCreateReq) ( // 创建文字审核任务 req.Zone.Profile = goproto.String(profile) - s.CreateZoneTextAudit(ctx, req.Zone) + s.CreateZoneTextAudit(ctx, nil, req.Zone) // 创建默认动态 cfg := apollostruct.ReferentialZoneMoment{} @@ -2610,7 +2610,22 @@ func (s *Service) ApiCreateZone(ctx *gin.Context, req *zoneproto.ApiCreateReq) ( func (s *Service) ApiUpdateZone(ctx *gin.Context, req *zoneproto.ApiUpdateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeZoneSrvOk - err := _DefaultZone.OpUpdate(ctx, &zoneproto.OpUpdateReq{ + + oldZone, err := _DefaultZone.GetById(ctx, req.Zone.GetId()) + if err == qmgo.ErrNoSuchDocuments { + ec = errcode.ErrCodeZoneNotExist + err = nil + return + } + if err != nil { + logger.Error("OpUpdate fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } + + profile := req.Zone.GetProfile() + req.Zone.Profile = nil + err = _DefaultZone.OpUpdate(ctx, &zoneproto.OpUpdateReq{ Zone: req.Zone, }) if err == qmgo.ErrNoSuchDocuments { @@ -2644,7 +2659,8 @@ func (s *Service) ApiUpdateZone(ctx *gin.Context, req *zoneproto.ApiUpdateReq) ( return } - s.CreateZoneTextAudit(ctx, req.Zone) + req.Zone.Profile = goproto.String(profile) + s.CreateZoneTextAudit(ctx, oldZone, req.Zone) return } diff --git a/app/mix/service/textauditservice.go b/app/mix/service/textauditservice.go index 4f5f037f..b467d0fe 100644 --- a/app/mix/service/textauditservice.go +++ b/app/mix/service/textauditservice.go @@ -151,11 +151,16 @@ func (s *Service) CreateStreamerAuthApprovalDetailsTextAudit(ctx *gin.Context, n return } -func (s *Service) CreateZoneTextAudit(ctx *gin.Context, newZone *dbstruct.Zone) (tasks []*dbstruct.TextAuditTask) { +func (s *Service) CreateZoneTextAudit(ctx *gin.Context, oldZone *dbstruct.Zone, newZone *dbstruct.Zone) (tasks []*dbstruct.TextAuditTask) { tasks = make([]*dbstruct.TextAuditTask, 0) if newZone.Profile != nil { + oldTextPtr := goproto.String("") + if oldZone != nil { + oldTextPtr = oldZone.Profile + } + tasks = append(tasks, &dbstruct.TextAuditTask{ Mid: newZone.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), @@ -164,7 +169,7 @@ func (s *Service) CreateZoneTextAudit(ctx *gin.Context, newZone *dbstruct.Zone) AssociativeTableId: newZone.Id, AssociativeTableColumn: goproto.String("profile"), AuditedText: newZone.Profile, - OldText: goproto.String(""), + OldText: oldTextPtr, }) } From 191123ca6444014523242e5f72082ef2a221d9ad Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 1 Aug 2024 20:38:22 +0800 Subject: [PATCH 9/9] 1 --- app/mix/service/imageauditservice.go | 4 ++-- app/mix/service/textauditservice.go | 9 ++++++--- app/mix/service/video_moderation_service.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/mix/service/imageauditservice.go b/app/mix/service/imageauditservice.go index a106cf7b..99d74a2d 100644 --- a/app/mix/service/imageauditservice.go +++ b/app/mix/service/imageauditservice.go @@ -44,7 +44,7 @@ func (s *Service) CreateUpdateStreamerImageAudit(ctx *gin.Context, oldStreamer * if newStreamer.Cover != nil && !util.IsInt64SliceEqualAsSet(oldStreamer.Cover.GetImageIds(), newStreamer.Cover.GetImageIds()) { tasks = append(tasks, &dbstruct.ImageAuditTask{ - Mid: newStreamer.Mid, + Mid: oldStreamer.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer"), AssociativeTableName: goproto.String("streamer"), @@ -57,7 +57,7 @@ func (s *Service) CreateUpdateStreamerImageAudit(ctx *gin.Context, oldStreamer * if newStreamer.Album != nil && !util.IsInt64SliceEqualAsSet(oldStreamer.Album.GetImageIds(), newStreamer.Album.GetImageIds()) { tasks = append(tasks, &dbstruct.ImageAuditTask{ - Mid: newStreamer.Mid, + Mid: oldStreamer.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer"), AssociativeTableName: goproto.String("streamer"), diff --git a/app/mix/service/textauditservice.go b/app/mix/service/textauditservice.go index b467d0fe..c347f793 100644 --- a/app/mix/service/textauditservice.go +++ b/app/mix/service/textauditservice.go @@ -44,7 +44,7 @@ func (s *Service) CreateUpdateStreamerTextAudit(ctx *gin.Context, oldStreamer *d if newStreamer.Bio != nil && oldStreamer.GetBio() != newStreamer.GetBio() { tasks = append(tasks, &dbstruct.TextAuditTask{ - Mid: newStreamer.Mid, + Mid: oldStreamer.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer"), AssociativeTableName: goproto.String("streamer"), @@ -58,7 +58,7 @@ func (s *Service) CreateUpdateStreamerTextAudit(ctx *gin.Context, oldStreamer *d if newStreamer.AutoResponseMessage != nil && oldStreamer.GetAutoResponseMessage() != newStreamer.GetAutoResponseMessage() { tasks = append(tasks, &dbstruct.TextAuditTask{ - Mid: newStreamer.Mid, + Mid: oldStreamer.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer"), AssociativeTableName: goproto.String("streamer"), @@ -154,15 +154,18 @@ func (s *Service) CreateStreamerAuthApprovalDetailsTextAudit(ctx *gin.Context, n func (s *Service) CreateZoneTextAudit(ctx *gin.Context, oldZone *dbstruct.Zone, newZone *dbstruct.Zone) (tasks []*dbstruct.TextAuditTask) { tasks = make([]*dbstruct.TextAuditTask, 0) + midp := newZone.Mid + if newZone.Profile != nil { oldTextPtr := goproto.String("") if oldZone != nil { oldTextPtr = oldZone.Profile + midp = oldZone.Mid } tasks = append(tasks, &dbstruct.TextAuditTask{ - Mid: newZone.Mid, + Mid: midp, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("zone"), AssociativeTableName: goproto.String("zone"), diff --git a/app/mix/service/video_moderation_service.go b/app/mix/service/video_moderation_service.go index dfd0d90a..926328ab 100644 --- a/app/mix/service/video_moderation_service.go +++ b/app/mix/service/video_moderation_service.go @@ -17,7 +17,7 @@ func (s *Service) CreateUpdateStreamerVideoModeration(ctx *gin.Context, oldStrea if newStreamer.Shorts != nil && !util.IsInt64SliceEqualAsSet(oldStreamer.Shorts.GetVideoIds(), newStreamer.Shorts.GetVideoIds()) { tasks = append(tasks, &dbstruct.VideoModerationTask{ - Mid: newStreamer.Mid, + Mid: oldStreamer.Mid, RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer"), AssociativeTableName: goproto.String("streamer"),