by Robin at 20240911;
This commit is contained in:
parent
062f6473ac
commit
46130b15fc
|
@ -1688,6 +1688,33 @@ func (s *Service) utilGetZonePreviews(ctx *gin.Context, zid int64) (previews *db
|
|||
}
|
||||
}
|
||||
|
||||
if len(imageIds) == 0 {
|
||||
vzmlist := make([]*dbstruct.ZoneMoment, 0)
|
||||
vzmlist, err = _DefaultZoneMoment.OpListByZid(ctx, &zonemomentproto.OpListByZidReq{
|
||||
Zid: goproto.Int64(zid),
|
||||
MType: goproto.Int64(consts.MediaTypeVideo),
|
||||
CType: goproto.Int64(consts.ZoneMomentCType_Free),
|
||||
Status: goproto.Int64(consts.ZoneMoment_Public),
|
||||
Limit: 4,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("_DefaultZoneMoment OpListByZid fail, req: %v, err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
objectMediaNum := 1 // 单个空间服务总共5个媒体类
|
||||
mediaFillableList := make([]mediafiller.MediaFillable, len(vzmlist)*objectMediaNum)
|
||||
for i, vo := range vzmlist {
|
||||
mediaFillableList[objectMediaNum*i+0] = vo.MediaComp
|
||||
}
|
||||
|
||||
imageIds, err = mediafiller.GetCoverIds(ctx, mediaFillableList)
|
||||
if err != nil {
|
||||
logger.Error("GetCoverIds fail, req: %v, err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
previews = &dbstruct.MediaComponent{
|
||||
ImageIds: util.Int64Slice(imageIds),
|
||||
}
|
||||
|
|
|
@ -221,3 +221,22 @@ func FillListInternal(ctx *gin.Context, list []MediaFillable) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetCoverIds(ctx *gin.Context, list []MediaFillable) ([]int64, error) {
|
||||
coverIds := make([]int64, 0)
|
||||
videoIds := make([]int64, 0)
|
||||
for _, v := range list {
|
||||
videoIds = append(videoIds, v.GetVideoIds()...)
|
||||
}
|
||||
videoMap, err := getVideoMapByIds(ctx, videoIds)
|
||||
if err != nil {
|
||||
logger.Error("mediafiller component getVideoMapByIds failed : %v", err)
|
||||
return make([]int64, 0), err
|
||||
}
|
||||
|
||||
// 获取视频封面
|
||||
for _, v := range videoMap {
|
||||
coverIds = append(coverIds, v.CoverId)
|
||||
}
|
||||
return coverIds, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue