by Robin at 20240227; op moment audit task
This commit is contained in:
parent
4458e8228c
commit
4a45945c07
|
@ -1047,6 +1047,49 @@ func (s *Service) OpCreateMoment(ctx *gin.Context, req *momentproto.OpCreateReq)
|
|||
ec = errcode.ErrCodeMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
//读取默认动态文字配置
|
||||
defaultMomentText, err := apollo.GetStringValue(consts.DefaultMomentTextKey, apollo.ApolloOpts().SetNamespace("application"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
ec = errcode.ErrCodeApolloReadFail
|
||||
return
|
||||
}
|
||||
|
||||
oldMoment := &dbstruct.Moment{
|
||||
Text: goproto.String(defaultMomentText),
|
||||
}
|
||||
|
||||
// 添加审核任务
|
||||
imageaudittasks := s.CreateMomentImageAudit(ctx, req.Moment)
|
||||
textaudittasks := s.CreateMomentTextAudit(ctx, oldMoment, req.Moment)
|
||||
imageaudit.AddTasks(imageaudittasks)
|
||||
textaudit.AddTasks(textaudittasks)
|
||||
|
||||
// 封装动态审核任务
|
||||
momentAuditTask := &dbstruct.MomentAuditTask{
|
||||
AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))),
|
||||
AuditedMedia: req.Moment.MediaComp,
|
||||
AuditedText: req.Moment.Text,
|
||||
}
|
||||
if len(imageaudittasks) > 0 {
|
||||
momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id
|
||||
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created)
|
||||
} else {
|
||||
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed)
|
||||
}
|
||||
if len(textaudittasks) > 0 {
|
||||
momentAuditTask.TextAuditTaskId = textaudittasks[0].Id
|
||||
momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created)
|
||||
} else {
|
||||
momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed)
|
||||
}
|
||||
if err := _DefaultMomentAuditTask.OpCreate(ctx, &moment_audit_taskproto.OpCreateReq{
|
||||
MomentAuditTask: momentAuditTask,
|
||||
}); err != nil {
|
||||
ec = errcode.ErrCodeMomentAuditTaskSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1068,6 +1111,51 @@ func (s *Service) OpUpdateMoment(ctx *gin.Context, req *momentproto.OpUpdateReq)
|
|||
ec = errcode.ErrCodeMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
//读取默认动态文字配置
|
||||
defaultMomentText, err := apollo.GetStringValue(consts.DefaultMomentTextKey, apollo.ApolloOpts().SetNamespace("application"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
ec = errcode.ErrCodeApolloReadFail
|
||||
return
|
||||
}
|
||||
|
||||
oldMoment := &dbstruct.Moment{
|
||||
Text: goproto.String(defaultMomentText),
|
||||
}
|
||||
|
||||
// 添加审核任务
|
||||
imageaudittasks := s.CreateMomentImageAudit(ctx, req.Moment)
|
||||
textaudittasks := s.CreateMomentTextAudit(ctx, oldMoment, req.Moment)
|
||||
imageaudit.AddTasks(imageaudittasks)
|
||||
textaudit.AddTasks(textaudittasks)
|
||||
|
||||
// 封装动态审核任务
|
||||
momentAuditTask := &dbstruct.MomentAuditTask{
|
||||
AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))),
|
||||
//ImageAuditTaskStatus: goproto.Int64(consts.MomentAudit_Created),
|
||||
//TextAuditTaskStatus: goproto.Int64(consts.MomentAudit_Created),
|
||||
}
|
||||
if len(imageaudittasks) > 0 {
|
||||
momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia
|
||||
momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id
|
||||
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created)
|
||||
} else {
|
||||
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed)
|
||||
}
|
||||
if len(textaudittasks) > 0 {
|
||||
momentAuditTask.AuditedText = textaudittasks[0].AuditedText
|
||||
momentAuditTask.TextAuditTaskId = textaudittasks[0].Id
|
||||
momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created)
|
||||
} else {
|
||||
momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed)
|
||||
}
|
||||
if err := _DefaultMomentAuditTask.OpCreate(ctx, &moment_audit_taskproto.OpCreateReq{
|
||||
MomentAuditTask: momentAuditTask,
|
||||
}); err != nil {
|
||||
ec = errcode.ErrCodeMomentAuditTaskSrvFail
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue