diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 6579861a..2dd9b501 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -2409,6 +2409,31 @@ func (m *Mongo) UpdateImageAuditTaskByIds(ctx *gin.Context, imageaudittask *dbst return err } +func (m *Mongo) UpdateOverdueImageAuditTasksStatus(ctx *gin.Context, imageaudittask *dbstruct.ImageAuditTask, batchId string) (*qmgo.UpdateResult, error) { + col := m.getColImageAuditTask() + set := qmgo.M{ + "status": consts.ImageAudit_Expired, + "remarks": "已有新批次任务处理该字段,该审核任务已过期", + } + up := qmgo.M{ + "$set": set, + } + filter := qmgo.M{ + "associative_database": util.DerefString(imageaudittask.AssociativeDatabase), + "associative_table_name": util.DerefString(imageaudittask.AssociativeTableName), + "associative_table_id": util.DerefInt64(imageaudittask.AssociativeTableId), + "associative_table_column": util.DerefString(imageaudittask.AssociativeTableColumn), + "batch_id": qmgo.M{ + "$ne": batchId, + }, + "status": qmgo.M{ + "$in": []int64{consts.ImageAudit_Rollbacked, consts.ImageAudit_ServiceFailed}, + }, + } + result, err := col.UpdateAll(ctx, filter, up) + return result, err +} + // 文字审核相关 func (m *Mongo) CreateTextAudit(ctx *gin.Context, textaudit *dbstruct.TextAudit) error { col := m.getColTextAudit() @@ -2594,6 +2619,31 @@ func (m *Mongo) UpdateTextAuditTaskByIds(ctx *gin.Context, textaudittask *dbstru return err } +func (m *Mongo) UpdateOverdueTextAuditTasksStatus(ctx *gin.Context, textaudittask *dbstruct.TextAuditTask, batchId string) (*qmgo.UpdateResult, error) { + col := m.getColTextAuditTask() + set := qmgo.M{ + "status": consts.TextAudit_Expired, + "remarks": "已有新批次任务处理该字段,该审核任务已过期", + } + up := qmgo.M{ + "$set": set, + } + filter := qmgo.M{ + "associative_database": util.DerefString(textaudittask.AssociativeDatabase), + "associative_table_name": util.DerefString(textaudittask.AssociativeTableName), + "associative_table_id": util.DerefInt64(textaudittask.AssociativeTableId), + "associative_table_column": util.DerefString(textaudittask.AssociativeTableColumn), + "batch_id": qmgo.M{ + "$ne": batchId, + }, + "status": qmgo.M{ + "$in": []int64{consts.TextAudit_Rollbacked, consts.TextAudit_ServiceFailed}, + }, + } + result, err := col.UpdateAll(ctx, filter, up) + return result, err +} + // 联系客服对话表相关 func (m *Mongo) CreateContactCustomerServiceSession(ctx *gin.Context, contact_customer_service_session *dbstruct.ContactCustomerServiceSession) error { col := m.getColContactCustomerServiceSession() diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 03bd4209..5f30ef92 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -655,6 +655,8 @@ func (s *Service) ApiGetFollowAccountRelationList(ctx *gin.Context, req *account list, err := _DefaultAccountRelation.OpListBySubMidAndPredicate(ctx, &accountrelationproto.OpListBySubMidAndPredicateReq{ SubMid: req.Mid, Predicate: goproto.Int64(consts.Follow), + Offset: req.Offset, + Limit: req.Limit, }) if err != nil { logger.Error("OpListBySubMidAndPredicate fail, req: %v, err: %v", util.ToJson(req), err) @@ -676,6 +678,8 @@ func (s *Service) ApiGetIsFollowedAccountRelationList(ctx *gin.Context, req *acc list, err := _DefaultAccountRelation.OpListBySubMidAndPredicate(ctx, &accountrelationproto.OpListBySubMidAndPredicateReq{ SubMid: req.Mid, Predicate: goproto.Int64(consts.IsFollowed), + Offset: req.Offset, + Limit: req.Limit, }) if err != nil { logger.Error("OpListBySubMidAndPredicate fail, req: %v, err: %v", util.ToJson(req), err) @@ -717,6 +721,8 @@ func (s *Service) ApiGetIgnoreAccountRelationList(ctx *gin.Context, req *account list, err := _DefaultAccountRelation.OpListBySubMidAndPredicate(ctx, &accountrelationproto.OpListBySubMidAndPredicateReq{ SubMid: req.Mid, Predicate: goproto.Int64(consts.Ignore), + Offset: req.Offset, + Limit: req.Limit, }) if err != nil { logger.Error("OpListBySubMidAndPredicate fail, req: %v, err: %v", util.ToJson(req), err) @@ -737,6 +743,8 @@ func (s *Service) ApiGetAbleToAccessWeixinOfAccountRelationList(ctx *gin.Context list, err := _DefaultAccountRelation.OpListBySubMidAndPredicate(ctx, &accountrelationproto.OpListBySubMidAndPredicateReq{ SubMid: req.Mid, Predicate: goproto.Int64(consts.AbleToAccessWeixinOf), + Offset: req.Offset, + Limit: req.Limit, }) if err != nil { logger.Error("OpListBySubMidAndPredicate fail, req: %v, err: %v", util.ToJson(req), err) diff --git a/app/mix/service/logic/imageaudittask.go b/app/mix/service/logic/imageaudittask.go index defc6c43..bcba02c9 100644 --- a/app/mix/service/logic/imageaudittask.go +++ b/app/mix/service/logic/imageaudittask.go @@ -81,3 +81,16 @@ func (p *ImageAuditTask) OpUpdateByIds(ctx *gin.Context, req *imageaudittaskprot } return nil } + +// 处理批次号早于参数提供的批次号的审核任务,全部置为已失效 +func (p *ImageAuditTask) OpHandleOverdue(ctx *gin.Context, task *dbstruct.ImageAuditTask, batchId string) error { + result, err := p.store.UpdateOverdueImageAuditTasksStatus(ctx, task, batchId) + if err != nil { + logger.Error("UpdateOverdueImageAuditTasksStatus fail, err: %v", err) + return err + } + if result.ModifiedCount > 0 { + logger.Info("Set %v tasks overdued", result.ModifiedCount) + } + return nil +} diff --git a/app/mix/service/logic/textaudittask.go b/app/mix/service/logic/textaudittask.go index 0e5dfc22..7dd1b60a 100644 --- a/app/mix/service/logic/textaudittask.go +++ b/app/mix/service/logic/textaudittask.go @@ -81,3 +81,16 @@ func (p *TextAuditTask) OpUpdateByIds(ctx *gin.Context, req *textaudittaskproto. } return nil } + +// 处理批次号早于参数提供的批次号的审核任务,全部置为已失效 +func (p *TextAuditTask) OpHandleOverdue(ctx *gin.Context, task *dbstruct.TextAuditTask, batchId string) error { + result, err := p.store.UpdateOverdueTextAuditTasksStatus(ctx, task, batchId) + if err != nil { + logger.Error("UpdateOverdueTextAuditTasksStatus fail, err: %v", err) + return err + } + if result.ModifiedCount > 0 { + logger.Info("Set %v tasks overdued", result.ModifiedCount) + } + return nil +} diff --git a/library/contentaudit/imageaudit/client.go b/library/contentaudit/imageaudit/client.go index 07b1eb64..774806d7 100644 --- a/library/contentaudit/imageaudit/client.go +++ b/library/contentaudit/imageaudit/client.go @@ -35,6 +35,7 @@ type ImageAuditTaskService interface { OpList(ctx *gin.Context, req *imageaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error) OpUpdateByIds(ctx *gin.Context, req *imageaudittaskproto.OpUpdateByIdsReq) error OpUpdateByBatchId(ctx *gin.Context, batchId string, imageaudittask *dbstruct.ImageAuditTask) error + OpHandleOverdue(ctx *gin.Context, task *dbstruct.ImageAuditTask, batchId string) error } var defaultImageAuditClient *imageaudit.Client diff --git a/library/contentaudit/imageaudit/imageaudit.go b/library/contentaudit/imageaudit/imageaudit.go index e6a0ef20..320e4a94 100644 --- a/library/contentaudit/imageaudit/imageaudit.go +++ b/library/contentaudit/imageaudit/imageaudit.go @@ -73,6 +73,11 @@ func createScanImageAdvanceRequest(tasks []*ImageAuditTaskControlBlock, batchId // 写map记录 if actionMap[task.ActionId] == nil { // 写入actionMap actionMap[task.ActionId] = NewImageAuditAction() + // 将此前批次对该元素未成功,待处理的审核全部置为已失效 + if err := _DefaultImageAuditTask.OpHandleOverdue(ctx, task.ImageAuditTask, batchId); err != nil { + logger.Error("_DefaultImageAuditTask OpHandleOverdue fail :%v", err) + } + } actionMap[task.ActionId].Record(task) diff --git a/library/contentaudit/textaudit/client.go b/library/contentaudit/textaudit/client.go index c0e4c5fb..be714268 100644 --- a/library/contentaudit/textaudit/client.go +++ b/library/contentaudit/textaudit/client.go @@ -30,6 +30,7 @@ type TextAuditTaskService interface { OpList(ctx *gin.Context, req *textaudittaskproto.OpListReq) ([]*dbstruct.TextAuditTask, error) OpUpdateByIds(ctx *gin.Context, req *textaudittaskproto.OpUpdateByIdsReq) error OpUpdateByBatchId(ctx *gin.Context, batchId string, textaudittask *dbstruct.TextAuditTask) error + OpHandleOverdue(ctx *gin.Context, task *dbstruct.TextAuditTask, batchId string) error } var defaultTextAuditClient *textaudit.Client diff --git a/library/contentaudit/textaudit/textaudit.go b/library/contentaudit/textaudit/textaudit.go index ee96f9b1..e9f3afec 100644 --- a/library/contentaudit/textaudit/textaudit.go +++ b/library/contentaudit/textaudit/textaudit.go @@ -53,6 +53,8 @@ func executeTextAuditTasks(tasks []*TextAuditTaskControlBlock, batchId string) ( func createScanTextRequest(tasks []*TextAuditTaskControlBlock, batchId string) (request *textaudit.ScanTextRequest, actionMap map[string]*TextAuditAction, err error) { + ctx := &gin.Context{} + actionMap = make(map[string]*TextAuditAction) // 动作Id号-action的map // 1.打包文字,转成ScanTextRequest @@ -62,6 +64,10 @@ func createScanTextRequest(tasks []*TextAuditTaskControlBlock, batchId string) ( // 写map if actionMap[task.ActionId] == nil { // 写入actionMap actionMap[task.ActionId] = NewTextAuditAction() + // 将此前批次对该元素未成功,待处理的审核全部置为已失效 + if err := _DefaultTextAuditTask.OpHandleOverdue(ctx, task.TextAuditTask, batchId); err != nil { + logger.Error("_DefaultTextAuditTask OpHandleOverdue fail :%v", err) + } } actionMap[task.ActionId].Record(task)