This commit is contained in:
parent
5d8fda536a
commit
090667063e
|
@ -1386,6 +1386,7 @@ func (v *Vas) H5DirectUnlockWechat(ctx *gin.Context, req *vasproto.H5DirectUnloc
|
||||||
ProductId: dbstruct.ProductIdH5ContactWechat,
|
ProductId: dbstruct.ProductIdH5ContactWechat,
|
||||||
PayType: req.PayType,
|
PayType: req.PayType,
|
||||||
From: dbstruct.VasCoinOrderFromH5,
|
From: dbstruct.VasCoinOrderFromH5,
|
||||||
|
CustomCoins: uVas.GetH5WechatCoinPrice(),
|
||||||
CalcPrice: uVas.GetH5WechatCoinPrice() * 10,
|
CalcPrice: uVas.GetH5WechatCoinPrice() * 10,
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
Oid1: fmt.Sprintf("%d", uid),
|
Oid1: fmt.Sprintf("%d", uid),
|
||||||
|
|
|
@ -35,21 +35,24 @@ func SetFileServerDomainName(fileServerDomainName string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func FillEntity(ctx *gin.Context, entity MediaFillable) error {
|
func FillEntity(ctx *gin.Context, entity MediaFillable) error {
|
||||||
|
|
||||||
imageIds := entity.GetImageIds()
|
|
||||||
videoIds := entity.GetVideoIds()
|
videoIds := entity.GetVideoIds()
|
||||||
|
|
||||||
imageMap, err := getImageMapByIds(ctx, imageIds)
|
|
||||||
if err != nil {
|
|
||||||
logger.Error("mediafiller component getImageMapByIds failed : %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
videoMap, err := getVideoMapByIds(ctx, videoIds)
|
videoMap, err := getVideoMapByIds(ctx, videoIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("mediafiller component getVideoMapByIds failed : %v", err)
|
logger.Error("mediafiller component getVideoMapByIds failed : %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imageIds := entity.GetImageIds()
|
||||||
|
// 获取视频封面
|
||||||
|
for _, v := range videoMap {
|
||||||
|
imageIds = append(imageIds, v.CoverId)
|
||||||
|
}
|
||||||
|
imageMap, err := getImageMapByIds(ctx, imageIds)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("mediafiller component getImageMapByIds failed : %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
images := make([]*dbstruct.ToCImage, 0)
|
images := make([]*dbstruct.ToCImage, 0)
|
||||||
videos := make([]*dbstruct.ToCVideo, 0)
|
videos := make([]*dbstruct.ToCVideo, 0)
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ func FillEntity(ctx *gin.Context, entity MediaFillable) error {
|
||||||
}
|
}
|
||||||
for _, videoId := range videoIds {
|
for _, videoId := range videoIds {
|
||||||
if video, ok := videoMap[videoId]; ok {
|
if video, ok := videoMap[videoId]; ok {
|
||||||
videos = append(videos, transToCVideo(video))
|
videos = append(videos, transToCVideo(video, imageMap[video.CoverId]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entity.SetImages(images)
|
entity.SetImages(images)
|
||||||
|
@ -71,7 +74,6 @@ func FillEntity(ctx *gin.Context, entity MediaFillable) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func FillList(ctx *gin.Context, list []MediaFillable) error {
|
func FillList(ctx *gin.Context, list []MediaFillable) error {
|
||||||
|
|
||||||
imageIds := make([]int64, 0)
|
imageIds := make([]int64, 0)
|
||||||
videoIds := make([]int64, 0)
|
videoIds := make([]int64, 0)
|
||||||
|
|
||||||
|
@ -80,17 +82,22 @@ func FillList(ctx *gin.Context, list []MediaFillable) error {
|
||||||
videoIds = append(videoIds, v.GetVideoIds()...)
|
videoIds = append(videoIds, v.GetVideoIds()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
imageMap, err := getImageMapByIds(ctx, imageIds)
|
|
||||||
if err != nil {
|
|
||||||
logger.Error("mediafiller component getImageMapByIds failed : %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
videoMap, err := getVideoMapByIds(ctx, videoIds)
|
videoMap, err := getVideoMapByIds(ctx, videoIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("mediafiller component getVideoMapByIds failed : %v", err)
|
logger.Error("mediafiller component getVideoMapByIds failed : %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取视频封面
|
||||||
|
for _, v := range videoMap {
|
||||||
|
imageIds = append(imageIds, v.CoverId)
|
||||||
|
}
|
||||||
|
imageMap, err := getImageMapByIds(ctx, imageIds)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("mediafiller component getImageMapByIds failed : %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
|
|
||||||
images := make([]*dbstruct.ToCImage, 0)
|
images := make([]*dbstruct.ToCImage, 0)
|
||||||
|
@ -102,7 +109,7 @@ func FillList(ctx *gin.Context, list []MediaFillable) error {
|
||||||
}
|
}
|
||||||
for _, videoId := range v.GetVideoIds() {
|
for _, videoId := range v.GetVideoIds() {
|
||||||
if video, ok := videoMap[videoId]; ok {
|
if video, ok := videoMap[videoId]; ok {
|
||||||
videos = append(videos, transToCVideo(video))
|
videos = append(videos, transToCVideo(video, imageMap[video.CoverId]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v.SetImages(images)
|
v.SetImages(images)
|
||||||
|
|
|
@ -56,14 +56,18 @@ func transToCImage(image *dbstruct.Image) *dbstruct.ToCImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
func transToCVideo(video *dbstruct.Video) *dbstruct.ToCVideo {
|
func transToCVideo(video *dbstruct.Video, coverImg *dbstruct.Image) *dbstruct.ToCVideo {
|
||||||
if video == nil {
|
if video == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &dbstruct.ToCVideo{
|
ret := &dbstruct.ToCVideo{
|
||||||
Id: video.Id,
|
Id: video.Id,
|
||||||
Dur: video.Dur,
|
Dur: video.Dur,
|
||||||
CoverUrls: []string{"todo"},
|
CoverUrls: []string{},
|
||||||
Urls: []string{defaultMediaFiller.fileServerDomainName + video.SrcId},
|
Urls: []string{defaultMediaFiller.fileServerDomainName + video.SrcId},
|
||||||
}
|
}
|
||||||
|
if coverImg != nil {
|
||||||
|
ret.CoverUrls = []string{defaultMediaFiller.fileServerDomainName + coverImg.SrcId}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue