feat-IRONFANS-163-Robin #615

Merged
chenhao merged 4 commits from feat-IRONFANS-163-Robin into test 2024-07-11 15:45:57 +08:00
5 changed files with 77 additions and 29 deletions

View File

@ -1818,18 +1818,23 @@ func (s *Service) ApiUpdateMoment(ctx *gin.Context, req *momentproto.ApiUpdateRe
textaudittasks := s.CreateMomentTextAudit(ctx, oldMoment, req.Moment) textaudittasks := s.CreateMomentTextAudit(ctx, oldMoment, req.Moment)
videomoderationtasks := s.CreateMomentVideoModeration(ctx, req.Moment) videomoderationtasks := s.CreateMomentVideoModeration(ctx, req.Moment)
if len(imageaudittasks) > 0 || len(textaudittasks) > 0 || len(videomoderationtasks) > 0 {
// 封装动态审核任务 // 封装动态审核任务
momentAuditTask := &dbstruct.MomentAuditTask{ momentAuditTask := &dbstruct.MomentAuditTask{
AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))),
ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting),
} }
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created)
if len(imageaudittasks) > 0 { if len(imageaudittasks) > 0 {
momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id
momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created)
} else if len(videomoderationtasks) > 0 { } else if len(videomoderationtasks) > 0 {
momentAuditTask.ImageAuditTaskId = videomoderationtasks[0].Id momentAuditTask.ImageAuditTaskId = videomoderationtasks[0].Id
momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created)
} else { // 媒体内容未更新,默认设置为通过
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed)
} }
if len(textaudittasks) > 0 { if len(textaudittasks) > 0 {
momentAuditTask.AuditedText = textaudittasks[0].AuditedText momentAuditTask.AuditedText = textaudittasks[0].AuditedText
@ -1845,6 +1850,7 @@ func (s *Service) ApiUpdateMoment(ctx *gin.Context, req *momentproto.ApiUpdateRe
ec = errcode.ErrCodeMomentAuditTaskSrvFail ec = errcode.ErrCodeMomentAuditTaskSrvFail
return return
} }
}
return return
} }

View File

@ -17,6 +17,9 @@ func (s *Service) CreateUpdateAccountImageAudit(ctx *gin.Context, oldAccount *db
if newAccount.Avatar == nil { if newAccount.Avatar == nil {
return nil return nil
} }
if util.IsInt64SliceEqualAsSet(oldAccount.Avatar.GetImageIds(), newAccount.Avatar.GetImageIds()) {
return nil
}
tasks = make([]*dbstruct.ImageAuditTask, 0) 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) { func (s *Service) CreateUpdateStreamerImageAudit(ctx *gin.Context, oldStreamer *dbstruct.Streamer, newStreamer *dbstruct.Streamer) (tasks []*dbstruct.ImageAuditTask) {
tasks = make([]*dbstruct.ImageAuditTask, 0) 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{ tasks = append(tasks, &dbstruct.ImageAuditTask{
RouteUrl: goproto.String(ctx.Request.URL.Path), RouteUrl: goproto.String(ctx.Request.URL.Path),
AssociativeDatabase: goproto.String("streamer"), 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{ tasks = append(tasks, &dbstruct.ImageAuditTask{
RouteUrl: goproto.String(ctx.Request.URL.Path), RouteUrl: goproto.String(ctx.Request.URL.Path),
AssociativeDatabase: goproto.String("streamer"), AssociativeDatabase: goproto.String("streamer"),

View File

@ -18,6 +18,9 @@ func (s *Service) CreateUpdateAccountTextAudit(ctx *gin.Context, oldAccount *dbs
if newAccount.Name == nil { if newAccount.Name == nil {
return return
} }
if oldAccount.GetName() == newAccount.GetName() {
return
}
tasks = append(tasks, &dbstruct.TextAuditTask{ tasks = append(tasks, &dbstruct.TextAuditTask{
RouteUrl: goproto.String(ctx.Request.URL.Path), 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) { func (s *Service) CreateUpdateStreamerTextAudit(ctx *gin.Context, oldStreamer *dbstruct.Streamer, newStreamer *dbstruct.Streamer) (tasks []*dbstruct.TextAuditTask) {
tasks = make([]*dbstruct.TextAuditTask, 0) tasks = make([]*dbstruct.TextAuditTask, 0)
if newStreamer.Bio != nil { if newStreamer.Bio != nil && oldStreamer.GetBio() != newStreamer.GetBio() {
tasks = append(tasks, &dbstruct.TextAuditTask{ tasks = append(tasks, &dbstruct.TextAuditTask{
RouteUrl: goproto.String(ctx.Request.URL.Path), 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{ tasks = append(tasks, &dbstruct.TextAuditTask{
RouteUrl: goproto.String(ctx.Request.URL.Path), RouteUrl: goproto.String(ctx.Request.URL.Path),

View File

@ -217,3 +217,25 @@ func SortParam(argList []*message.JsonParamEntry) string {
} }
return strings.Join(args, "&") 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
}

View File

@ -33,3 +33,17 @@ func (p *Streamer) GetMid() int64 {
} }
return *p.Mid 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
}