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
}
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(),

View File

@ -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的人审

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) {
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 {

View File

@ -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)

View File

@ -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
}

View File

@ -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)
}
}
}