Merge branch 'feat-IRONFANS-245-Robin' into conf-245

This commit is contained in:
Robin 2024-11-22 14:41:42 +08:00
commit a169791939
6 changed files with 52 additions and 91 deletions

View File

@ -4167,7 +4167,7 @@ func (m *Mongo) UpdateMomentAuditTaskByMomentIdsAndStatus(ctx *gin.Context, mome
return err 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() col := m.getColMomentAuditTask()
filter := qmgo.M{ filter := qmgo.M{
"image_audit_task_id": task.GetId(), "image_audit_task_id": task.GetId(),

View File

@ -129,23 +129,36 @@ func (handler *ImageAuditTaskResultHandler) generateMomentMediaComponentUpdateFu
// 20240703同步动态审核表触发人审的逻辑改到handler实现 // 20240703同步动态审核表触发人审的逻辑改到handler实现
// moment_audit_task有image_audit_task_id的索引以该索引作为更新依据 // moment_audit_task有image_audit_task_id的索引以该索引作为更新依据
// image_audit_task有associative_table_id的内容以该id去触发moment的更新 // image_audit_task有associative_table_id的内容以该id去触发moment的更新
// 通过逻辑只做恢复,不包含任何触发人审的操作
//20240403更新: 增加成功后处理的切面 //20240403更新: 增加成功后处理的切面
//20241122更新: 将广场动态机审逻辑完全改为空间动态机审逻辑
if option == consts.ImageAuditTaskUpdate_Success { if option == consts.ImageAuditTaskUpdate_Success {
return tryToFinishImageAuditTaskOfMoment(ctx, task) return tryToFinishImageAuditTaskOfMoment(ctx, task)
} }
if option == consts.ImageAuditTaskUpdate_Pass { imageAuditOpinion := &strings.Builder{}
return passMomentImageAuditTask(ctx, task) if task.GetStatus() == consts.ImageAudit_ServiceFailed {
imageAuditOpinion.WriteString("机审失败")
} else { } else {
if err := rollbackMomentImageAuditTask(ctx, task); err != nil { // 写入具体原因
for i, pass := range task.AuditedMediaResults {
if !pass {
imageaudit := task.ImageAudits[i]
imageAuditOpinion.WriteString(fmt.Sprintf("图片%d%s ", i+1, strings.Join(imageaudit.NotPassScenes, ",")))
}
}
}
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 err
} }
return tryToFinishImageAuditTaskOfMoment(ctx, task) 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 { func tryToFinishImageAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.ImageAuditTask) error {
// 机审通过尝试触发moment_audit_task的人审 // 机审通过尝试触发moment_audit_task的人审

View File

@ -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) { 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 { if err != nil {
logger.Error("TryToFinishyImageAuditTaskOfMoment fail, err: %v", err) logger.Error("TryToFinishImageAuditTaskOfMoment fail, err: %v", err)
return false, err return false, err
} }
if instance == nil { if instance == nil {

View File

@ -1509,15 +1509,12 @@ func (s *Service) OpReviewMoment(ctx *gin.Context, req *momentproto.OpReviewReq)
return return
} }
// 更新请求,如果是通过,则恢复删除标志 // 更新请求
updateReq := &momentproto.OpUpdateReq{ updateReq := &momentproto.OpUpdateReq{
Moment: &dbstruct.Moment{ Moment: &dbstruct.Moment{
Status: goproto.Int64(finalMomentStatus), 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) err = _DefaultMoment.OpUpdateByIdsAndStatus(ctx, updateReq, req.MomentIds, consts.Moment_ManuallyReviewing)

View File

@ -153,31 +153,23 @@ func (handler *TextAuditTaskResultHandler) generateMomentTextUpdateFunc() {
// 20240703同步动态审核表触发人审的逻辑改到handler实现 // 20240703同步动态审核表触发人审的逻辑改到handler实现
// moment_audit_task有text_audit_task_id的索引以该索引作为更新依据 // moment_audit_task有text_audit_task_id的索引以该索引作为更新依据
// text_audit_task有associative_table_id的内容以该id去触发moment的更新 // text_audit_task有associative_table_id的内容以该id去触发moment的更新
// 通过逻辑只做恢复,不包含任何触发人审的操作
//20240403更新: 增加成功后处理的切面 //20240403更新: 增加成功后处理的切面
if option == consts.TextAuditTaskUpdate_Success { if option == consts.TextAuditTaskUpdate_Success {
return tryToFinishTextAuditTaskOfMoment(ctx, task) return tryToFinishTextAuditTaskOfMoment(ctx, task)
} }
momentId := task.AssociativeTableId var textAuditOpinion string
var text *string if task.GetStatus() == consts.TextAudit_ServiceFailed {
if option == consts.TextAuditTaskUpdate_Pass { textAuditOpinion = "机审失败"
text = task.AuditedText
} else { } else {
text = task.OldText textAuditOpinion = fmt.Sprintf("%s", strings.Join(task.TextAudit.NotPassScenes, ","))
} }
if err := _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{ err := _DefaultMomentAuditTask.OpUpdateByMomentIdsAndStatus(ctx, &dbstruct.MomentAuditTask{
Moment: &dbstruct.Moment{ TextAuditTaskStatus: task.Status,
Id: momentId, TextAuditOpinion: goproto.String(textAuditOpinion),
Text: text, }, []string{fmt.Sprint(task.GetAssociativeTableId())}, consts.MomentManuallyReview_Waiting)
}, if err != nil {
}); err != nil {
return err
}
if err := _DefaultMomentAuditTask.OpUpdateByTextAuditTaskIds(ctx, &dbstruct.MomentAuditTask{
FinalText: text,
}, []string{util.DerefString(task.Id)}); err != nil {
return err return err
} }

View File

@ -82,15 +82,30 @@ func (handler *VideoModerationTaskResultHandler) generateMomentMediaComponentUpd
return tryToFinishVideoModerationTaskOfMoment(ctx, task) return tryToFinishVideoModerationTaskOfMoment(ctx, task)
} }
if option == consts.ImageAuditTaskUpdate_Pass { videoModerationOpinion := &strings.Builder{}
//return passMomentVideoModerationTask(ctx, task) if task.GetStatus() == consts.VideoModeration_ServiceFailed {
return nil videoModerationOpinion.WriteString("机审失败")
} else { } 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)
}
}
} }
// 私密动态表->图像内容,若不通过,则写入不通过的原因 // 私密动态表->图像内容,若不通过,则写入不通过的原因