diff --git a/api/proto/moment_audit_task/proto/moment_audit_task_vo.go b/api/proto/moment_audit_task/proto/moment_audit_task_vo.go index 26c15364..8ec5812f 100644 --- a/api/proto/moment_audit_task/proto/moment_audit_task_vo.go +++ b/api/proto/moment_audit_task/proto/moment_audit_task_vo.go @@ -2,6 +2,7 @@ package proto import ( imageaudittaskproto "service/api/proto/imageaudittask/proto" + streamerproto "service/api/proto/streamer/proto" textaudittaskproto "service/api/proto/textaudittask/proto" "service/dbstruct" ) @@ -10,4 +11,5 @@ type MomentAuditTaskVO struct { MomentAuditTask *dbstruct.MomentAuditTask `json:"moment_audit_task"` ImageAuditTaskVO *imageaudittaskproto.ImageAuditTaskVO `json:"image_audit_task_vo"` TextAuditTaskVO *textaudittaskproto.TextAuditTaskVO `json:"text_audit_task_vo"` + StreamerExt *streamerproto.OpListExtVO `json:"streamer_ext"` } diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 0de7b42d..0452949d 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -1542,7 +1542,7 @@ func (m *Mongo) GetDeletedMomentList(ctx *gin.Context, req *momentproto.OpListRe return list, err } -func (m *Mongo) GetMomentListByIds(ctx *gin.Context, req *momentproto.OpListByIdsReq) ([]*dbstruct.Moment, error) { +func (m *Mongo) GetPublicMomentListByIds(ctx *gin.Context, req *momentproto.OpListByIdsReq) ([]*dbstruct.Moment, error) { list := make([]*dbstruct.Moment, 0) col := m.getColMoment() query := qmgo.M{ @@ -1560,6 +1560,23 @@ func (m *Mongo) GetMomentListByIds(ctx *gin.Context, req *momentproto.OpListById return list, err } +func (m *Mongo) GetMomentListByIds(ctx *gin.Context, momentIds []int64) ([]*dbstruct.Moment, error) { + list := make([]*dbstruct.Moment, 0) + col := m.getColMoment() + query := qmgo.M{ + "_id": qmgo.M{ + "$in": momentIds, + }, + "del_flag": 0, + } + err := col.Find(ctx, query).Sort("_id").All(&list) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return list, err + } + return list, err +} + // 查私有动态接口 func (m *Mongo) GetMomentListByMid(ctx *gin.Context, req *momentproto.OpListByMidReq) ([]*dbstruct.Moment, error) { list := make([]*dbstruct.Moment, 0) diff --git a/app/mix/service/logic/moment.go b/app/mix/service/logic/moment.go index d4c614fb..38ac545a 100644 --- a/app/mix/service/logic/moment.go +++ b/app/mix/service/logic/moment.go @@ -1,11 +1,13 @@ package logic import ( + "fmt" "service/api/consts" momentproto "service/api/proto/moment/proto" "service/app/mix/dao" "service/dbstruct" "service/library/logger" + "strconv" "time" "github.com/gin-gonic/gin" @@ -83,9 +85,9 @@ func (p *Moment) OpListDeleted(ctx *gin.Context, req *momentproto.OpListReq) ([] } func (p *Moment) OpListByIds(ctx *gin.Context, req *momentproto.OpListByIdsReq) ([]*dbstruct.Moment, error) { - list, err := p.store.GetMomentListByIds(ctx, req) + list, err := p.store.GetPublicMomentListByIds(ctx, req) if err != nil { - logger.Error("GetMomentListByIds fail, err: %v", err) + logger.Error("GetPublicMomentListByIds fail, err: %v", err) return make([]*dbstruct.Moment, 0), err } return list, nil @@ -138,3 +140,29 @@ func (p *Moment) OpUpdateByIdsAndStatus(ctx *gin.Context, req *momentproto.OpUpd } return nil } + +func (p *Moment) GetMomentStringIdMapByIds(ctx *gin.Context, momentIdStrs []string) (map[string]*dbstruct.Moment, error) { + + momentIds := make([]int64, 0) + for _, momentIdStr := range momentIdStrs { + momentId, err := strconv.Atoi(momentIdStr) + if err != nil { + logger.Error("Assert fail, err: %v", err) + return make(map[string]*dbstruct.Moment), err + } + momentIds = append(momentIds, int64(momentId)) + } + + list, err := p.store.GetMomentListByIds(ctx, momentIds) + if err != nil { + logger.Error("GetMomentListByIds fail, err: %v", err) + return make(map[string]*dbstruct.Moment), err + } + + mp := make(map[string]*dbstruct.Moment) + for _, moment := range list { + mp[fmt.Sprint(moment.GetId())] = moment + } + + return mp, nil +} diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 7fa0805b..3a93eecf 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -2813,9 +2813,16 @@ func (s *Service) OpGetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_t // 收集图像和文字审核的id,分别查询出图像和文字审核的任务 imageAuditTaskIds := make([]string, 0) textAuditTaskIds := make([]string, 0) + momentIdSet := make(map[string]*dbstruct.Moment) + momentIds := make([]string, 0) for _, task := range list { imageAuditTaskIds = append(imageAuditTaskIds, util.DerefString(task.ImageAuditTaskId)) textAuditTaskIds = append(textAuditTaskIds, util.DerefString(task.TextAuditTaskId)) + momentId := task.GetAssociativeTableId() + if momentIdSet[momentId] == nil { + momentIdSet[momentId] = &dbstruct.Moment{} + momentIds = append(momentIds, momentId) + } } imageAuditTaskMap, err := _DefaultImageAuditTask.OpGetImageAuditTaskMapByIds(ctx, imageAuditTaskIds) if err != nil { @@ -2829,6 +2836,27 @@ func (s *Service) OpGetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_t ec = errcode.ErrCodeTextAuditTaskSrvFail return } + momentMp, err := _DefaultMoment.GetMomentStringIdMapByIds(ctx, momentIds) + if err != nil { + logger.Error("GetMomentStringIdMapByIds fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeMomentSrvFail + return + } + midSet := make(map[int64]*dbstruct.Moment) + mids := make([]int64, 0) + for _, v := range momentMp { + mid := v.GetMid() + if midSet[mid] == nil { + midSet[mid] = &dbstruct.Moment{} + mids = append(mids, mid) + } + } + streamerMp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Op) + if err != nil { + logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } for i, task := range list { imageAuditTaskId := imageAuditTaskIds[i] @@ -2849,10 +2877,13 @@ func (s *Service) OpGetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_t ec = errcode.ErrCodeTextAuditSrvFail return } + + streamerExt := streamerMp[momentMp[task.GetAssociativeTableId()].GetMid()].(*streamerproto.OpListExtVO) volist[i] = &moment_audit_taskproto.MomentAuditTaskVO{ MomentAuditTask: task, ImageAuditTaskVO: imageAuditTaskVO, TextAuditTaskVO: textAuditTaskVO, + StreamerExt: streamerExt, } } diff --git a/dbstruct/moment.go b/dbstruct/moment.go index 1ceedcab..5a04b086 100644 --- a/dbstruct/moment.go +++ b/dbstruct/moment.go @@ -31,3 +31,10 @@ func (p *Moment) GetMid() int64 { } return 0 } + +func (p *Moment) GetId() int64 { + if p != nil && p.Id != nil { + return util.DerefInt64(p.Id) + } + return 0 +} diff --git a/dbstruct/moment_audit_task.go b/dbstruct/moment_audit_task.go index 312b8595..699c4fd7 100644 --- a/dbstruct/moment_audit_task.go +++ b/dbstruct/moment_audit_task.go @@ -20,3 +20,10 @@ type MomentAuditTask struct { DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记 } + +func (p *MomentAuditTask) GetAssociativeTableId() string { + if p == nil || p.AssociativeTableId == nil { + return "" + } + return *p.AssociativeTableId +}