diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index d867c4f9..cc4a935c 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -4167,7 +4167,7 @@ func (m *Mongo) UpdateMomentAuditTaskByMomentIdsAndStatus(ctx *gin.Context, mome return err } -func (m *Mongo) TryToFinishyImageAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.ImageAuditTask, opinion string) (*dbstruct.MomentAuditTask, error) { +func (m *Mongo) TryToFinishImageAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.ImageAuditTask, opinion string) (*dbstruct.MomentAuditTask, error) { col := m.getColMomentAuditTask() filter := qmgo.M{ "image_audit_task_id": task.GetId(), diff --git a/app/mix/service/imageaudittask_result_handler.go b/app/mix/service/imageaudittask_result_handler.go index 4185ccfa..790b96d4 100644 --- a/app/mix/service/imageaudittask_result_handler.go +++ b/app/mix/service/imageaudittask_result_handler.go @@ -129,21 +129,34 @@ func (handler *ImageAuditTaskResultHandler) generateMomentMediaComponentUpdateFu // 20240703:同步动态审核表触发人审的逻辑改到handler实现 // moment_audit_task有image_audit_task_id的索引,以该索引作为更新依据 // image_audit_task有associative_table_id的内容,以该id去触发moment的更新 - // 通过逻辑只做恢复,不包含任何触发人审的操作 //20240403更新: 增加成功后处理的切面 + //20241122更新: 将广场动态机审逻辑完全改为空间动态机审逻辑 if option == consts.ImageAuditTaskUpdate_Success { return tryToFinishImageAuditTaskOfMoment(ctx, task) } - if option == consts.ImageAuditTaskUpdate_Pass { - return passMomentImageAuditTask(ctx, task) + imageAuditOpinion := &strings.Builder{} + if task.GetStatus() == consts.ImageAudit_ServiceFailed { + imageAuditOpinion.WriteString("机审失败") } else { - if err := rollbackMomentImageAuditTask(ctx, task); err != nil { - return err + // 写入具体原因 + for i, pass := range task.AuditedMediaResults { + if !pass { + imageaudit := task.ImageAudits[i] + imageAuditOpinion.WriteString(fmt.Sprintf("图片%d:%s; ", i+1, strings.Join(imageaudit.NotPassScenes, ","))) + } } - return tryToFinishImageAuditTaskOfMoment(ctx, task) } + + err := _DefaultMomentAuditTask.OpUpdateByMomentIdsAndStatus(ctx, &dbstruct.MomentAuditTask{ + ImageAuditTaskStatus: task.Status, + ImageAuditOpinion: goproto.String(imageAuditOpinion.String()), + }, []string{fmt.Sprint(task.GetAssociativeTableId())}, consts.MomentManuallyReview_Waiting) + if err != nil { + return err + } + return tryToFinishImageAuditTaskOfMoment(ctx, task) } } } @@ -300,62 +313,6 @@ func (handler *ImageAuditTaskResultHandler) generateStreamerAuthApprovalDetailsA } } -// 通过动态表图像 -func passMomentImageAuditTask(ctx *gin.Context, task *dbstruct.ImageAuditTask) (err error) { - if err := _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{ - Moment: &dbstruct.Moment{ - Id: task.AssociativeTableId, - MediaComp: task.AuditedMedia, - DelFlag: goproto.Int64(consts.Exist), - }, - }); err != nil { - return err - } - - if err := _DefaultMomentAuditTask.OpUpdateByImageAuditTaskIds(ctx, &dbstruct.MomentAuditTask{ - FinalMedia: task.AuditedMedia, - }, []string{task.GetId()}); err != nil { - return err - } - return nil -} - -// 回退动态表图像 -func rollbackMomentImageAuditTask(ctx *gin.Context, task *dbstruct.ImageAuditTask) (err error) { - auditedImageIds := util.DerefInt64Slice(task.AuditedMedia.ImageIds) - imageIds := make([]int64, 0) - for i, pass := range task.AuditedMediaResults { - if pass { - imageIds = append(imageIds, auditedImageIds[i]) - } - } - if len(imageIds) != 0 { - mediaComp := &dbstruct.MediaComponent{ - ImageIds: &imageIds, - } - - if err := _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{ - Moment: &dbstruct.Moment{ - Id: task.AssociativeTableId, - MediaComp: mediaComp, - Status: goproto.Int64(consts.Moment_AuditRejected), - }, - }); err != nil { - return err - } - - if err := _DefaultMomentAuditTask.OpUpdateByImageAuditTaskIds(ctx, &dbstruct.MomentAuditTask{ - FinalMedia: mediaComp, - }, []string{task.GetId()}); err != nil { - return err - } - - return nil - } else { - return _DefaultMoment.OpDelete(ctx, util.DerefInt64(task.AssociativeTableId)) - } -} - // 尝试完成审核 func tryToFinishImageAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.ImageAuditTask) error { // 机审通过,尝试触发moment_audit_task的人审 diff --git a/app/mix/service/logic/moment_audit_task.go b/app/mix/service/logic/moment_audit_task.go index da8addda..8fd02cb7 100644 --- a/app/mix/service/logic/moment_audit_task.go +++ b/app/mix/service/logic/moment_audit_task.go @@ -92,9 +92,9 @@ func (p *MomentAuditTask) OpUpdateByMomentIdsAndStatus(ctx *gin.Context, moment_ } func (p *MomentAuditTask) TryToFinishImageAuditTask(ctx *gin.Context, task *dbstruct.ImageAuditTask, opinion string) (isFinished bool, err error) { - instance, err := p.store.TryToFinishyImageAuditTaskOfMoment(ctx, task, opinion) + instance, err := p.store.TryToFinishImageAuditTaskOfMoment(ctx, task, opinion) if err != nil { - logger.Error("TryToFinishyImageAuditTaskOfMoment fail, err: %v", err) + logger.Error("TryToFinishImageAuditTaskOfMoment fail, err: %v", err) return false, err } if instance == nil { diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 60d54b18..cd91baec 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -1509,15 +1509,12 @@ func (s *Service) OpReviewMoment(ctx *gin.Context, req *momentproto.OpReviewReq) return } - // 更新请求,如果是通过,则恢复删除标志 + // 更新请求 updateReq := &momentproto.OpUpdateReq{ Moment: &dbstruct.Moment{ Status: goproto.Int64(finalMomentStatus), }, } - if req.OpType == consts.MomentManuallyReview_Pass { - updateReq.Moment.DelFlag = goproto.Int64(consts.Exist) - } // 更新动态的状态 err = _DefaultMoment.OpUpdateByIdsAndStatus(ctx, updateReq, req.MomentIds, consts.Moment_ManuallyReviewing) diff --git a/app/mix/service/textaudittask_result_handler.go b/app/mix/service/textaudittask_result_handler.go index 19c69bdb..b34bc7dc 100644 --- a/app/mix/service/textaudittask_result_handler.go +++ b/app/mix/service/textaudittask_result_handler.go @@ -153,31 +153,23 @@ func (handler *TextAuditTaskResultHandler) generateMomentTextUpdateFunc() { // 20240703:同步动态审核表触发人审的逻辑改到handler实现 // moment_audit_task有text_audit_task_id的索引,以该索引作为更新依据 // text_audit_task有associative_table_id的内容,以该id去触发moment的更新 - // 通过逻辑只做恢复,不包含任何触发人审的操作 //20240403更新: 增加成功后处理的切面 if option == consts.TextAuditTaskUpdate_Success { return tryToFinishTextAuditTaskOfMoment(ctx, task) } - momentId := task.AssociativeTableId - var text *string - if option == consts.TextAuditTaskUpdate_Pass { - text = task.AuditedText + var textAuditOpinion string + if task.GetStatus() == consts.TextAudit_ServiceFailed { + textAuditOpinion = "机审失败" } else { - text = task.OldText + textAuditOpinion = fmt.Sprintf("%s;", strings.Join(task.TextAudit.NotPassScenes, ",")) } - if err := _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{ - Moment: &dbstruct.Moment{ - Id: momentId, - Text: text, - }, - }); err != nil { - return err - } - if err := _DefaultMomentAuditTask.OpUpdateByTextAuditTaskIds(ctx, &dbstruct.MomentAuditTask{ - FinalText: text, - }, []string{util.DerefString(task.Id)}); err != nil { + err := _DefaultMomentAuditTask.OpUpdateByMomentIdsAndStatus(ctx, &dbstruct.MomentAuditTask{ + TextAuditTaskStatus: task.Status, + TextAuditOpinion: goproto.String(textAuditOpinion), + }, []string{fmt.Sprint(task.GetAssociativeTableId())}, consts.MomentManuallyReview_Waiting) + if err != nil { return err } diff --git a/app/mix/service/video_moderation_result_handler.go b/app/mix/service/video_moderation_result_handler.go index a6b8fc7f..a3569d1c 100644 --- a/app/mix/service/video_moderation_result_handler.go +++ b/app/mix/service/video_moderation_result_handler.go @@ -82,13 +82,28 @@ func (handler *VideoModerationTaskResultHandler) generateMomentMediaComponentUpd return tryToFinishVideoModerationTaskOfMoment(ctx, task) } - if option == consts.ImageAuditTaskUpdate_Pass { - //return passMomentVideoModerationTask(ctx, task) - return nil - + videoModerationOpinion := &strings.Builder{} + if task.GetStatus() == consts.VideoModeration_ServiceFailed { + videoModerationOpinion.WriteString("机审失败") } else { - return tryToFinishVideoModerationTaskOfMoment(ctx, task) + // 写入具体原因 + for i, pass := range task.AuditedMediaResults { + if !pass { + videoModerationOpinion.WriteString(fmt.Sprintf("视频%d:%s ", i+1, task.Description[i])) + } + } } + task.BusinessOpinion = goproto.String(videoModerationOpinion.String()) + + err := _DefaultMomentAuditTask.OpUpdateByMomentIdsAndStatus(ctx, &dbstruct.MomentAuditTask{ + ImageAuditTaskStatus: task.Status, + ImageAuditOpinion: goproto.String(videoModerationOpinion.String()), + }, []string{fmt.Sprint(task.GetAssociativeTableId())}, consts.MomentManuallyReview_Waiting) + if err != nil { + return err + } + + return tryToFinishVideoModerationTaskOfMoment(ctx, task) } } }