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"` // 帖子标题 Slug string `json:"slug"` // slug 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"` // 帖子标题 Slug string `json:"slug"` // slug 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"` Slug string `json:"slug"` // slug 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"` Slug string `json:"slug"` // slug 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, Slug: videoInfo.Slug, 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 } // VideoAllListReq 视频分页列表请求 type VideoAllListReq struct { pubdef.Page MediaType int64 `form:"mediaType" json:"mediaType"` // 类型 0-全部 1-影集 2-动画 TopicId int64 `form:"topicId" json:"topicId"` // 题材ID,对应video_topic TopicSlug string `form:"topicSlug" json:"topicSlug"` // 题材slug,非空时优先按slug解析题材ID SortType int64 `form:"sortType" json:"sortType"` // 排序 1-最新 2-最热 3-收藏最多 } // VideoItemResp 查询视频列表项 type VideoItemResp struct { // id Id int64 `json:"id"` // slug Slug string `json:"slug"` // 标题 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"` } // VideoLikeSetReq 视频点赞设置请求 type VideoLikeSetReq struct { Id int64 `json:"id" binding:"required"` // 视频ID IsLike *bool `json:"isLike" binding:"required"` // 是否点赞,true-点赞,false-取消点赞 } // VideoLikeSetResp 视频点赞设置响应 type VideoLikeSetResp struct { Id int64 `json:"id"` // 视频ID IsLike int64 `json:"isLike"` // 点赞状态 1-已点赞 2-未点赞 CountLike int64 `json:"countLike"` // 视频点赞数 } // VideoCollectSetReq 视频收藏设置请求 type VideoCollectSetReq struct { Id int64 `json:"id" binding:"required"` // 视频ID IsCollect *bool `json:"isCollect" binding:"required"` // 是否收藏,true-收藏,false-取消收藏 } // VideoCollectSetResp 视频收藏设置响应 type VideoCollectSetResp struct { Id int64 `json:"id"` // 视频ID IsCollect int64 `json:"isCollect"` // 收藏状态 1-已收藏 2-未收藏 CountCollect int64 `json:"countCollect"` // 视频收藏数 } // VideoHistoryListReq 视频观看历史列表请求 type VideoHistoryListReq struct { // 普通分页参数,pageNum默认1,pageSize默认10、最大100 pubdef.Page } // VideoHistoryData 视频观看历史列表项 type VideoHistoryData struct { Id int64 `json:"id"` // 视频ID Slug string `json:"slug"` // slug Title string `json:"title"` // 标题 CoverImg string `json:"coverImg"` // 封面 Keyworld []string `json:"keyworld"` // 关键字 Tags []int64 `json:"tags"` // 标签 WatchTimes int64 `json:"watchTimes"` // 观看数 VideoTime int32 `json:"videoTime"` // 影片长度 CountLike int64 `json:"countLike"` // 点赞数 CountCollect int64 `json:"countCollect"` // 收藏数 CountComment int64 `json:"countComment"` // 评论数 IsCollect int64 `json:"isCollect"` // 收藏状态 1-已收藏 2-未收藏 HistoryAt time.Time `json:"historyAt"` // 最近观看时间 } // VideoHistoryListResp 视频观看历史列表响应 type VideoHistoryListResp struct { TotalCount int64 `json:"totalCount"` // 总历史数量 PageSize int `json:"pageSize"` // 每页数 PageNum int `json:"pageNum"` // 页数 List []VideoHistoryData `json:"list"` // 观看历史集合 } // VideoHistoryDeleteReq 删除单条视频观看历史请求 type VideoHistoryDeleteReq struct { VideoId int64 `json:"videoId" binding:"required"` // 视频ID } // VideoHistoryDeleteResp 删除单条视频观看历史响应 type VideoHistoryDeleteResp struct { DeletedCount int64 `json:"deletedCount"` // 删除记录数量 } // VideoHistoryClearResp 清空视频观看历史响应 type VideoHistoryClearResp struct { DeletedCount int64 `json:"deletedCount"` // 删除记录数量 } // VideoCollectListReq 视频收藏列表请求 type VideoCollectListReq struct { // 普通分页参数,pageNum默认1,pageSize默认10、最大100 pubdef.Page } // VideoCollectData 视频收藏列表项 type VideoCollectData struct { Id int64 `json:"id"` // 视频ID Slug string `json:"slug"` // slug Title string `json:"title"` // 标题 CoverImg string `json:"coverImg"` // 封面 Keyworld []string `json:"keyworld"` // 关键字 Tags []int64 `json:"tags"` // 标签 WatchTimes int64 `json:"watchTimes"` // 观看数 VideoTime int32 `json:"videoTime"` // 影片长度 CountLike int64 `json:"countLike"` // 点赞数 CountCollect int64 `json:"countCollect"` // 收藏数 CountComment int64 `json:"countComment"` // 评论数 IsCollect int64 `json:"isCollect"` // 收藏状态,收藏列表固定返回1-已收藏 CollectedAt time.Time `json:"collectedAt"` // 收藏时间 } // VideoCollectListResp 视频收藏列表响应 type VideoCollectListResp struct { TotalCount int64 `json:"totalCount"` // 总收藏数量 PageSize int `json:"pageSize"` // 每页数 PageNum int `json:"pageNum"` // 页数 List []VideoCollectData `json:"list"` // 收藏视频集合 } // VideoAllListItemResp 视频分页列表项 type VideoAllListItemResp struct { Id int64 `json:"id"` // id Slug string `json:"slug"` // slug Title string `json:"title"` // 标题 MediaType int64 `json:"mediaType"` // 类型 1-影集 2-动画 AddedTime time.Time `json:"addedTime"` // 上架时间 CreatorId int64 `json:"creatorId"` // 作者Id CreatorName string `json:"creatorName"` // 作者名称 CoverImg string `json:"coverImg"` // 封面 Keyworld []string `json:"keyworld"` // 关键字 Tags []int64 `json:"tags"` // 标签 TopicIds []int64 `json:"topicIds"` // 题材ID集合 TopicNames []string `json:"topicNames"` // 题材名称集合 Topics []VideoTopicInfo `json:"topics"` // 题材集合 WatchTimes int64 `json:"watchTimes"` // 观看数 VideoTime int32 `json:"videoTime"` // 影片长度 VideoCount int64 `json:"videoCount"` // 视频数量 } // VideoResp 普通分页查询视频响应 type VideoResp struct { // 总共数量 TotalCount int64 `json:"totalCount"` // 每页数 PageSize int `json:"pageSize"` // 页数 PageNum int `json:"pageNum"` // 视频列表 List []*VideoItemResp `json:"list"` } // VideoAllListResp 视频分页列表响应 type VideoAllListResp struct { TotalCount int64 `json:"totalCount"` // 总共数量 PageSize int `json:"pageSize"` // 每页数 PageNum int `json:"pageNum"` // 页数 List []*VideoAllListItemResp `json:"list"` // 视频集合 Advitise AdvitiseData `json:"advitise"` // 广告 SeoInfo *SeoInfo `json:"seoInfo,omitempty"` // 页面SEO信息 } // VideoInfoReq 查询视频详情请求 type VideoInfoReq struct { Id int64 `json:"id" form:"id"` // 视频id Slug string `json:"slug" form:"slug"` // 视频slug,非空时优先按slug解析视频ID } // VideoInfoResp 查询视频详情响应 type VideoInfoResp struct { // id Id int64 `json:"id"` // slug Slug string `json:"slug"` // 标题 Title string `json:"title"` // 封面 CoverImg string `json:"coverImg"` // 关键字 Keyworld []string `json:"keyworld"` // 标签 Tags []int64 `json:"tags"` // 标签名称 TagsName []string `json:"tagsName"` // 题材ID集合 TopicIds []int64 `json:"topicIds"` // 题材集合 Topics []VideoTopicInfo `json:"topics"` // 观看数(真假之和) WatchTimes int64 `json:"watchTimes"` // 点赞数 CountLike int64 `json:"countLike"` // 收藏数 CountCollect int64 `json:"countCollect"` // 评论数 CountComment int64 `json:"countComment"` // 当前用户点赞状态 1-已点赞 2-未点赞 IsLike int64 `json:"isLike"` // 当前用户收藏状态 1-已收藏 2-未收藏 IsCollect int64 `json:"isCollect"` // 视频 Video VideoData `json:"video"` // 广告 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"` }