This commit is contained in:
lwl0608 2024-07-13 13:12:34 +08:00
parent 07dd2bcff2
commit 7c36b8c16f
2 changed files with 12 additions and 2 deletions

View File

@ -77,6 +77,16 @@ type Video struct {
Fmt string `json:"fmt" bson:"fmt"`
}
func (i *Video) SelectMinSizeOssId() string {
if i == nil {
return ""
}
if i.Status == VideoStatusResizeDone && len(i.SrcId720) > 0 && i.Size720 < i.SizeSrc {
return i.SrcId720
}
return i.SrcId
}
type ToCVideo struct {
Id int64 `json:"id"` // 视频id
Dur int64 `json:"dur"` // 视频时

View File

@ -68,7 +68,7 @@ func transToCVideo(video *dbstruct.Video, coverImg *dbstruct.Image) *dbstruct.To
Id: video.Id,
Dur: video.Dur,
CoverUrls: []string{},
Urls: []string{defaultMediaFiller.GetFileServerDomain() + video.SrcId},
Urls: []string{defaultMediaFiller.GetFileServerDomain() + video.SelectMinSizeOssId()},
}
if coverImg != nil {
ret.CoverW = coverImg.W
@ -107,7 +107,7 @@ func transToCVideoInternal(video *dbstruct.Video, coverImg *dbstruct.Image) *dbs
Id: video.Id,
Dur: video.Dur,
CoverUrls: []string{},
Urls: []string{defaultMediaFiller.GetInternalFileServerDomain() + video.SrcId},
Urls: []string{defaultMediaFiller.GetInternalFileServerDomain() + video.SelectMinSizeOssId()},
}
if coverImg != nil {
ret.CoverW = coverImg.W