diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 2bff4b54..e002b913 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -1818,32 +1818,38 @@ func (s *Service) ApiUpdateMoment(ctx *gin.Context, req *momentproto.ApiUpdateRe textaudittasks := s.CreateMomentTextAudit(ctx, oldMoment, req.Moment) videomoderationtasks := s.CreateMomentVideoModeration(ctx, req.Moment) - // 封装动态审核任务 - momentAuditTask := &dbstruct.MomentAuditTask{ - AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), - ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), - } - momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created) - if len(imageaudittasks) > 0 { - momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id - momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia - } else if len(videomoderationtasks) > 0 { - momentAuditTask.ImageAuditTaskId = videomoderationtasks[0].Id - momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia - } - 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 len(imageaudittasks) > 0 || len(textaudittasks) > 0 || len(videomoderationtasks) > 0 { + // 封装动态审核任务 + momentAuditTask := &dbstruct.MomentAuditTask{ + AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), + ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), + } - if err := _DefaultMomentAuditTask.OpCreate(ctx, &moment_audit_taskproto.OpCreateReq{ - MomentAuditTask: momentAuditTask, - }); err != nil { - ec = errcode.ErrCodeMomentAuditTaskSrvFail - return + if len(imageaudittasks) > 0 { + momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id + momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia + momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created) + } else if len(videomoderationtasks) > 0 { + momentAuditTask.ImageAuditTaskId = videomoderationtasks[0].Id + momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia + 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 diff --git a/app/mix/service/imageauditservice.go b/app/mix/service/imageauditservice.go index 0f4d69c0..9166bda6 100644 --- a/app/mix/service/imageauditservice.go +++ b/app/mix/service/imageauditservice.go @@ -17,6 +17,9 @@ func (s *Service) CreateUpdateAccountImageAudit(ctx *gin.Context, oldAccount *db if newAccount.Avatar == nil { return nil } + if util.IsInt64SliceEqualAsSet(oldAccount.Avatar.GetImageIds(), newAccount.Avatar.GetImageIds()) { + return nil + } tasks = make([]*dbstruct.ImageAuditTask, 0) @@ -38,7 +41,7 @@ func (s *Service) CreateUpdateAccountImageAudit(ctx *gin.Context, oldAccount *db func (s *Service) CreateUpdateStreamerImageAudit(ctx *gin.Context, oldStreamer *dbstruct.Streamer, newStreamer *dbstruct.Streamer) (tasks []*dbstruct.ImageAuditTask) { tasks = make([]*dbstruct.ImageAuditTask, 0) - if newStreamer.Cover != nil { + if newStreamer.Cover != nil && !util.IsInt64SliceEqualAsSet(oldStreamer.Cover.GetImageIds(), newStreamer.Cover.GetImageIds()) { tasks = append(tasks, &dbstruct.ImageAuditTask{ RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer"), @@ -50,7 +53,7 @@ func (s *Service) CreateUpdateStreamerImageAudit(ctx *gin.Context, oldStreamer * }) } - if newStreamer.Album != nil { + if newStreamer.Album != nil && !util.IsInt64SliceEqualAsSet(oldStreamer.Album.GetImageIds(), newStreamer.Album.GetImageIds()) { tasks = append(tasks, &dbstruct.ImageAuditTask{ RouteUrl: goproto.String(ctx.Request.URL.Path), AssociativeDatabase: goproto.String("streamer"), diff --git a/app/mix/service/textauditservice.go b/app/mix/service/textauditservice.go index 7bb9335b..c7b08cbb 100644 --- a/app/mix/service/textauditservice.go +++ b/app/mix/service/textauditservice.go @@ -18,6 +18,9 @@ func (s *Service) CreateUpdateAccountTextAudit(ctx *gin.Context, oldAccount *dbs if newAccount.Name == nil { return } + if oldAccount.GetName() == newAccount.GetName() { + return + } tasks = append(tasks, &dbstruct.TextAuditTask{ RouteUrl: goproto.String(ctx.Request.URL.Path), @@ -37,7 +40,7 @@ func (s *Service) CreateUpdateAccountTextAudit(ctx *gin.Context, oldAccount *dbs func (s *Service) CreateUpdateStreamerTextAudit(ctx *gin.Context, oldStreamer *dbstruct.Streamer, newStreamer *dbstruct.Streamer) (tasks []*dbstruct.TextAuditTask) { tasks = make([]*dbstruct.TextAuditTask, 0) - if newStreamer.Bio != nil { + if newStreamer.Bio != nil && oldStreamer.GetBio() != newStreamer.GetBio() { tasks = append(tasks, &dbstruct.TextAuditTask{ RouteUrl: goproto.String(ctx.Request.URL.Path), @@ -50,7 +53,7 @@ func (s *Service) CreateUpdateStreamerTextAudit(ctx *gin.Context, oldStreamer *d }) } - if newStreamer.AutoResponseMessage != nil { + if newStreamer.AutoResponseMessage != nil && oldStreamer.GetAutoResponseMessage() != newStreamer.GetAutoResponseMessage() { tasks = append(tasks, &dbstruct.TextAuditTask{ RouteUrl: goproto.String(ctx.Request.URL.Path), diff --git a/bizcommon/util/util.go b/bizcommon/util/util.go index e08f3b6b..099a7bec 100644 --- a/bizcommon/util/util.go +++ b/bizcommon/util/util.go @@ -217,3 +217,25 @@ func SortParam(argList []*message.JsonParamEntry) string { } return strings.Join(args, "&") } + +func TransferInt64SliceIntoValueCountMap(s []int64) map[int64]int { + mp := make(map[int64]int) + for _, integer := range s { + mp[integer] = mp[integer] + 1 + } + return mp +} + +func IsInt64SliceEqualAsSet(s1 []int64, s2 []int64) bool { + if len(s1) != len(s2) { + return false + } + mp1 := TransferInt64SliceIntoValueCountMap(s1) + mp2 := TransferInt64SliceIntoValueCountMap(s2) + for _, integer := range s1 { + if mp1[integer] != mp2[integer] { + return false + } + } + return true +} diff --git a/dbstruct/streamer.go b/dbstruct/streamer.go index 9d7dfcf9..41d61527 100644 --- a/dbstruct/streamer.go +++ b/dbstruct/streamer.go @@ -33,3 +33,17 @@ func (p *Streamer) GetMid() int64 { } return *p.Mid } + +func (p *Streamer) GetBio() string { + if p == nil || p.Bio == nil { + return "" + } + return *p.Bio +} + +func (p *Streamer) GetAutoResponseMessage() string { + if p == nil || p.AutoResponseMessage == nil { + return "" + } + return *p.AutoResponseMessage +}