Files
web_hgtv_server/app/api/proto/video.go
T
rootandClaude Opus 5.5 7974a42301 Initial commit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-23 11:07:42 +08:00

266 lines
9.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package proto
import (
"time"
"videoweb/pub/common/netutil"
"videoweb/pub/common/utils"
"videoweb/pub/models/videoinformationmod"
"videoweb/pub/pubdef"
)
type TagsInfoData struct {
Id int64 `json:"id" `
Name string `json:"name"` // 帖子标题
SeoInfo pubdef.SeoValue `json:"seoInfo" bson:"seoInfo"` // Seo相关信息
Works int64 `json:"works" bson:"works,omitempty"` // 作品数量
Images string `json:"images" bson:"images,omitempty"` // 背景
}
type CollectionInfoData struct {
Id int64 `json:"id" `
Name string `json:"name"` // 帖子标题
}
type VideoType int64
const (
VideoTypeVideo VideoType = 0 // 视频(帖子)
VideoTypeCollection VideoType = 1 // 合集
VideoTypeAdvitise VideoType = 2 // 广告
VideoTypeVideoV2 VideoType = 3 // 视频
)
type VideoInfoData struct {
Id int64 `json:"id"`
Type VideoType `json:"type"` // 类型
Title string `json:"title"` // 帖子标题
Keyworld []string `json:"keyworld"` // 关键字
AddedTime time.Time `json:"addedTime"` // 帖子上架时间
CreatorId int64 `json:"creatorId"` // 作者Id
CreatorName string `json:"creatorName"` // 作者名称
CoverImg string `json:"coverImg"` // 封面
Nodes []videoinformationmod.Node `json:"nodes"` // 节点
Video videoinformationmod.VideoInfo `json:"video"` // 视频
Tags []TagsInfoData `json:"tags"` // 标签
IsHot bool `json:"isHot"` // 是否热门
AdvitiseId string `json:"advitiseId"` // 广告Id
Link string `json:"link"` // 跳转链接
Location int64 `json:"location" bson:"location"` // 位置id
CategoryIds []int64 `json:"categoryIds"` // 分类信息
Categorys []VideoCategoryInfo `json:"categorys"` // 分类信息
TopicIds []int64 `json:"topicIds"` // 专题信息
Topics []VideoTopicInfo `json:"topics"` // 专题信息
WatchTimes int64 `json:"watchTimes" bson:"watchTimes"` // 观看次数
ShowTimes int64 `json:"showTimes" bson:"showTimes"` // 展示次数
UpdatedAt time.Time `json:"updatedAt"` //更新时间
Desc string `bson:"desc,omitempty" json:"desc"` // 详细描述
Content string `json:"content"` // 富文本
ImgCdn string `json:"imgCdn" bson:"imgCdn"` // 图片CDN
PreviewVtt string `json:"previewVtt,omitempty"` // 雪碧图 vtt
}
type VideoHistoryInfo struct {
Id int64 `json:"id"`
Title string `json:"title"` // 帖子标题
AddedTime time.Time `json:"addedTime"` // 上架时间
}
type VideoCategoryInfo struct {
Id int64 `json:"id" `
Name string `json:"name"`
ContentType int64 `json:"contentType" bson:"contentType"` // 内容:0: 默认 1:首页 2:今日
SortType int64 `json:"sortType" bson:"sortType"` // 排序方式 0:上线时间 1:观看次数 2排序
SeoInfo pubdef.SeoValue `json:"seoInfo" bson:"seoInfo"` // Seo相关信息
Title string `json:"title" bson:"title"` // APP显示
Desc string `json:"desc" bson:"desc"` // 描述
}
// 面包屑
type BreadcrumbItem struct {
Name string `json:"name"` // 名称
Url string `json:"url"` // 跳转链接
}
// 详情页导航
type DetailNavItem struct {
Name string `json:"name"` // 导航名称
Url string `json:"url"` // 导航链接
}
type VideoPlayReq struct {
VideoId int64 `json:"videoId" form:"videoId"` // 视频ID
}
type VideoPlayResp struct {
AuthKey string `json:"authKey"`
}
type VideoCreaterInfo struct {
Id int64 `json:"id" `
Name string `json:"name"`
SeoInfo pubdef.SeoValue `json:"seoInfo" bson:"seoInfo"` // Seo相关信息
}
func VideoInfoToData(videoInfo *videoinformationmod.VideoInformation, imgCdn string) VideoInfoData {
t := VideoTypeVideo
switch videoInfo.MediaType {
case videoinformationmod.MediaType_Video:
t = VideoTypeVideo
case videoinformationmod.MediaType_Collection:
t = VideoTypeCollection
case videoinformationmod.MediaType_Advitise:
t = VideoTypeAdvitise
case videoinformationmod.MediaType_VideoV2:
t = VideoTypeVideoV2
}
videotemp := VideoInfoData{
Id: videoInfo.Id,
Type: t,
Title: videoInfo.Title,
Keyworld: videoInfo.Keyworld,
AddedTime: videoInfo.AddedTime,
Desc: videoInfo.Desc,
UpdatedAt: videoInfo.PageUpdatedAt,
CreatorId: videoInfo.CreatorId,
TopicIds: videoInfo.TopicIds,
Topics: make([]VideoTopicInfo, 0),
CreatorName: videoInfo.CreatorName,
CoverImg: netutil.MergeURL(imgCdn, videoInfo.CoverImg),
Nodes: make([]videoinformationmod.Node, 0),
Video: videoInfo.Video,
IsHot: videoInfo.IsHot,
CategoryIds: videoInfo.CategoryIds,
Categorys: make([]VideoCategoryInfo, 0),
Tags: make([]TagsInfoData, 0),
ShowTimes: videoInfo.Real.ShowTimes,
WatchTimes: videoInfo.Real.WatchTimes,
Content: videoInfo.Content,
ImgCdn: imgCdn,
PreviewVtt: videoInfo.PreviewVtt,
}
ti := time.Date(2020, 1, 1, 0, 0, 0, 0, utils.LocBJ)
if videotemp.UpdatedAt.Before(ti) {
videotemp.UpdatedAt = videoInfo.UpdatedAt
}
for _, nodeInfo := range videoInfo.Nodes {
nodeTmp := videoinformationmod.Node{
Images: make([]string, 0),
Url: nodeInfo.Url,
Text: nodeInfo.Text,
Videos: nodeInfo.Videos,
Title: nodeInfo.Title,
}
for _, image := range nodeInfo.Images {
nodeTmp.Images = append(nodeTmp.Images, netutil.MergeURL(imgCdn, image))
}
videotemp.Nodes = append(videotemp.Nodes, nodeTmp)
}
return videotemp
}
// StripH265Url 清空主视频与 nodes 内视频的 H265 地址。
func StripH265Url(data *VideoInfoData) {
if data == nil {
return
}
data.Video.H265Url = ""
for i := range data.Nodes {
for j := range data.Nodes[i].Videos {
data.Nodes[i].Videos[j].H265Url = ""
}
}
}
// VideoReq 普通分页查询视频请求
type VideoReq struct {
// 普通分页参数,pageNum默认1,pageSize默认10、最大100
pubdef.Page
}
// VideoItemResp 查询视频列表项
type VideoItemResp struct {
// id
Id int64 `json:"id"`
// 标题
Title string `json:"title"`
// 上架时间
AddedTime time.Time `json:"addedTime"`
// 作者Id
CreatorId int64 `json:"creatorId"`
// 作者名称
CreatorName string `json:"creatorName"`
// 封面
CoverImg string `json:"coverImg"`
// 关键字
Keyworld []string `json:"keyworld"`
// 标签
Tags []int64 `json:"tags"`
// 观看数(真假之和)
WatchTimes int64 `json:"watchTimes"`
// 影片长度
VideoTime int32 `json:"videoTime"`
}
// VideoResp 普通分页查询视频响应
type VideoResp struct {
// 总共数量
TotalCount int64 `json:"totalCount"`
// 每页数
PageSize int `json:"pageSize"`
// 页数
PageNum int `json:"pageNum"`
// 视频列表
List []*VideoItemResp `json:"list"`
}
// VideoInfoReq 查询视频详情请求
type VideoInfoReq struct {
// 视频的id必填
Id int64 `json:"id" form:"id" binding:"required"`
}
// VideoInfoResp 查询视频详情响应
type VideoInfoResp struct {
// id
Id int64 `json:"id"`
// 标题
Title string `json:"title"`
// 封面
CoverImg string `json:"coverImg"`
// 关键字
Keyworld []string `json:"keyworld"`
// 标签
Tags []int64 `json:"tags"`
// 标签名称
TagsName []string `json:"tagsName"`
// 观看数(真假之和)
WatchTimes int64 `json:"watchTimes"`
// 视频
Video VideoData `json:"video"`
// 相关推荐,按当前视频标签匹配并按上架时间倒序返回最多20条
RecommendVideos []*VideoItemResp `json:"recommendVideos"`
// 广告
Advitise AdvitiseData `json:"advitise"`
// 页面SEO信息
SeoInfo *SeoInfo `json:"seoInfo,omitempty"`
}
type VideoData struct {
// 视频ID(视频才会存在)
TaskId string `json:"taskId"`
// 媒资库ID
FileId string `json:"fileId"`
// 视频URl
Url string `json:"url"`
// 视频封面
Cover string `json:"cover"`
// 分辨率高(视频才会存在)
Height int64 `json:"height"`
// 分辨率宽(视频才会存在)
Width int64 `json:"width"`
// 影片长度
VideoTime int32 `json:"videoTime"`
// 预览MP4文件
PreMp4FileNameFs string `json:"preMp4FileNameFs"`
// 不加密的预览MP4
UnencryptedPreMp4 string `json:"unencryptedPreMp4"`
}