Files
huangguo_server/models/v/vidmod/app.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

525 lines
22 KiB
Go

package vidmod
import (
"time"
"91porn-server/models/commod"
"91porn-server/models/v/locmod"
"91porn-server/models/v/usermod"
"github.com/shopspring/decimal"
"go.mongodb.org/mongo-driver/bson/primitive"
)
var TotalWatchCount uint64 = 5 //非vip用户每日总观看次数
const (
SubmitVideoPlayTimeLimit = 10 //上传视频最短播放时间为10秒
TodayRank = 0
WeekRank = 1
MonthRank = 2
TypeNewst = 0
TypeHotest = 1
TypeSameCity = 2
TypePay = 3
TypeVip = 4
CommonUp = 0
MadouUp = 1
Version string = "1.0.0" // 帖子兼容老版本
)
// BaseVid4Aws 上传到AWS的基础信息
type BaseVid4Aws struct {
ID string `json:"id"`
CheckSum string `json:"checkSum"`
Title string `json:"title"`
Actors []string `json:"actors"`
AddedTime string `json:"addedTime"`
PlayTime uint64 `json:"playTime"`
Tags []string `json:"tags"`
Size int `json:"size"`
Filename string `json:"filename"`
Desc string `json:"desc"`
Type string `json:"type"`
Director string `json:"director"`
Studio string `json:"studio"`
Bango string `json:"bango"`
Via string `json:"via"`
}
// CoverInfo4Aws 上传到AWS的基础信息
type CoverInfo4Aws struct {
Type string `json:"type"`
Title string `json:"title"`
Tags []string `json:"tags"`
CoverImg string `json:"coverImg"`
SeriesCover []string `json:"seriesCover"`
Status string `json:"status"`
MimeType string `json:"mimeType"`
Via string `json:"via"`
Topic []string `json:"topic"`
NewUpdateAt string `json:"newUpdateAt"`
Desc string `json:"desc"`
}
// LocVideoReq 同城视频请求
type LocVideoReq struct {
City string `form:"city" json:"city"`
commod.Page
}
// VideoReq 视频详情请求
type VideoReq struct {
VideoID string `form:"videoID" json:"videoID"`
SearchAccessToken string `form:"searchAccessToken" json:"searchAccessToken"`
}
// SubmitReq 视频发布请求
type SubmitReq struct {
UID uint64 `form:"uid" json:"uid"`
NewsType string `form:"newsType" json:"newsType"`
Title string `form:"title" json:"title"`
Content string `form:"content" json:"content"`
Tags []string `form:"tags" json:"tags" binding:"required"`
PlayTime uint `form:"playTime" json:"playTime"`
Cover string `form:"cover" json:"cover"`
CoverThumb string `form:"coverThumb" json:"coverThumb"`
SeriesCover []string `form:"seriesCover" json:"seriesCover"`
Via string `form:"via" json:"via"`
Coins int64 `form:"coins" json:"coins"`
Size int `form:"size" json:"size"`
Resolution string `form:"resolution" json:"resolution"`
Ratio float64 `json:"ratio" bson:"ratio"` //宽高比
MimeType string `form:"mimeType" json:"mimeType"`
Location locmod.Location `form:"location" json:"location"`
Actor string `form:"actor" json:"actor"`
SourceID string `form:"sourceID" json:"sourceID"`
SourceURL string `form:"sourceURL" json:"sourceURL"`
MD5 string `form:"md5" json:"md5"`
Filename string `form:"filename" json:"filename"`
FreeTime int `form:"freeTime" json:"freeTime"`
IsActivity bool `form:"isActivity" json:"isActivity"` // 是否是参赛作品
}
// PlayReq 播放请求
type PlayReq struct {
VideoID string `form:"videoID" json:"videoID"`
Longer int `form:"longer" json:"longer"`
Progress int `form:"progress" json:"progress"`
PlayWay int `form:"playWay" json:"playWay"`
Via int `form:"via" json:"via"`
TagID string `form:"tagID" json:"tagID"`
//作者
Publisher uint64 `form:"publisher" json:"publisher"`
}
// LocReq 地址位置请求参数
type LocReq struct {
ID string `form:"id" json:"id"`
}
// LocInfo 城市信息
type LocInfo struct {
ID primitive.ObjectID `json:"id"`
//城市
City string `json:"city"`
//封面
Cover string `json:"cover"`
//访问人数
Visit int `json:"visit"`
//创建时间
CreatedAt time.Time `json:"createdAt"`
}
// LocResp 地址位置应答参数
type LocResp struct {
LocInfo
}
// LocVideoResp 同城视频应答
type LocVideoResp struct {
List []*VideoInfo `json:"list"`
HasNext bool `json:"hasNext"`
}
// LocationResp 接受地理位置信息的结构
type LocationResp struct {
Code int `json:"code"`
CountryName string `json:"country_name"`
RegionName string `json:"region_name"`
CityName string `json:"city_name"`
IP string `json:"ip"`
}
// TagInfo 标签信息
type TagInfo struct {
ID primitive.ObjectID `json:"id" bson:"_id"` //标签id
Name string `json:"name" bson:"tagName"` //标签名字
CoverImg string `json:"coverImg" bson:"coverImg"` //封面图片
Description string `json:"description" bson:"description"` //文字说明
PlayCount int64 `json:"playCount" bson:"tPlayCount"` //播放量
HasCollected bool `json:"hasCollected" bson:"hasCollected"` //已收藏
}
// VideoStatus 视频状态
type VideoStatus struct {
//已支付
HasPaid bool `json:"hasPaid" bson:"hasPaid"`
//每日视频状态信息
TodayRank int `json:"todayRank" bson:"todayRank"`
//每日播放次数
TodayPlayCnt int `json:"todayPlayCnt" bson:"todayPlayCnt"`
//已点赞
HasLiked bool `json:"hasLiked" bson:"hasLiked"`
//已收藏
HasCollected bool `json:"hasCollected" bson:"hasCollected"`
}
// UInfo 别名
type UInfo = usermod.BaseInfoVip
// Publisher 发布者的信息
type Publisher struct {
UInfo
//是否关注
HasFollowed bool `json:"hasFollowed" bson:"hasFollowed"`
}
// VideoBase 返回视频的基本信息
type VideoBase struct {
//id
ID primitive.ObjectID `json:"id" bson:"_id"`
//帖子类型, SP,视频帖子,COVER
NewsType string `json:"newsType" bson:"newsType"`
//视频标题
Title string `json:"title" bson:"title"`
Content string `json:"content" bson:"content"` // 视频内容
//视频标签
Tags []TagInfo `json:"tags" bson:"tags"`
//视频资源地址Path
SourceURL string `json:"sourceURL" bson:"sourceURL"`
// H.265 视频资源地址
H265Url string `json:"h265Url" bson:"h265Url"`
// 预览视频资源地址(并非所有视频都有预览)
PreviewURL string `json:"previewURL" bson:"previewURL"`
//广告跳转连接 目前只有广告帖子有用
LinkUrl string `json:"linkUrl,omitempty" bson:"linkUrl,omitempty"`
//影片长度
PlayTime uint `json:"playTime" bson:"playTime"`
//封面大图
Cover string `json:"cover" bson:"cover"`
//封⾯小图
CoverThumb string `json:"coverThumb" bson:"coverThumb"`
//帖子套图
SeriesCover []string `json:"seriesCover" bson:"seriesCover"`
//总播放量
PlayCount int `json:"playCount" bson:"playCount"`
//视频购买人数
PurchaseCount int `json:"purchaseCount" bson:"purchaseCount"`
//点赞数
LikeCount int `json:"likeCount" bson:"likeCount"`
//评论数
CommentCount int `json:"commentCount" bson:"commentCount"`
//分享数
ShareCount int `json:"shareCount" bson:"shareCount"`
//折扣后视频金币数(如果有的话)
Coins int64 `json:"coins" bson:"coins"`
//文件大小 byte
Size int `json:"size" bson:"size"`
//分辨率
Resolution string `json:"resolution" bson:"resolution"`
//宽高比
Ratio float64 `json:"ratio" bson:"ratio"`
//状态,0 未审核 1通过 2审核失败 3视为免费 默认为0
Status int `json:"status" bson:"status"`
//视频未通过审核时的理由
Reason string `json:"reason" bson:"reason"`
//免费时长
FreeTime int `json:"freeTime" bson:"freeTime"`
//是否隐藏地址
IsHideLocation bool `json:"isHideLocation" bson:"isHideLocation"`
//免费专区
FreeArea bool `json:"freeArea" bson:"freeArea"`
//创建时间
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
//审核时间
ReviewAt time.Time `json:"reviewAt" bson:"reviewAt,omitempty"`
//是否置顶
IsTopping bool `json:"isTopping" bson:"isTopping"`
//力荐
IsRecommend bool `json:"isRecommend" bson:"isRecommend"`
//置精
IsChoosen bool `json:"isChoosen" bson:"isChoosen"`
//打赏金额
Rewarded decimal.Decimal `json:"rewarded" bson:"rewarded"`
//视频原金币数
OriginCoins int64 `json:"originCoins" bson:"originCoins"`
CollectCount int `json:"collectCount" bson:"collectCount"` // 收藏数
PageViewCount int64 `json:"pageViewCount" bson:"pageViewCount"` // 视频页面展示次数
SeedLinkUrl string `json:"seedLinkUrl" bson:"seedLinkUrl,omitempty"` //种子链接
SeedSize uint64 `json:"seedSize" bson:"seedSize,omitempty"` // 种子影片大小 byte
SeedPlayTime uint64 `json:"seedPlayTime" bson:"seedPlayTime,omitempty"` // 种子影片时长
PreviewStart int `json:"previewStart" bson:"previewStart"` // 预览时间起始点
RichText string `json:"richText" bson:"richText"` // 富文本内容
TimeNodeList []TimeNode `json:"timeNodeList" bson:"timeNodeList"` // 时间节点
DownloadAllow int `json:"downloadAllow" son:"downloadAllow"` // 允许下载的VIP级别,0表示不允许下载 1表示VIP 2表示免费
ShowType int `json:"showType" bson:"showType"` // 0-所有的人都可以看 1-奇数可看 2-偶数可看
LsjId string `json:"lsjId" bson:"lsjId"` // 老司机ID
SearchAccessToken string `json:"searchAccessToken,omitempty" bson:"-"`
ShowFreeTrialBadge bool `json:"showFreeTrialBadge" bson:"-"` // 是否展示免费试看角标
FreeTrialRemaining uint64 `json:"freeTrialRemaining" bson:"-"` // 用户剩余免费观看次数
CanUseFreeTrial bool `json:"canUseFreeTrial" bson:"-"` // 当前视频是否可使用免费观看次数
}
// CommentInfo 评论信息
type CommentInfo struct {
//用户id
UID uint64 `json:"uid"`
//姓名
Name string `json:"name"`
//头像
Portrait string `json:"portrait"`
//评论id
Cid string `json:"cid"`
//评论内容
Content string `json:"content"`
///喜欢次数
LikeCount int `json:"likeCount"`
//是否作者
IsAuthor bool `json:"isAuthor"`
//创建时间
CreatedAt time.Time `json:"createdAt"`
}
// WatchModel 观看模型
type WatchModel struct {
///观看次数
WatchCount uint64 `json:"watchCount"`
//可观看
IsWatch bool `json:"isWatch"`
//是否免费
IsFreeWatch bool `json:"isFreeWatch"`
}
// WatchCountResp 用户免费观看次数响应。
type WatchCountResp struct {
IsCan bool `json:"isCan"`
WatchCount uint64 `json:"watchCount"`
TotalWatchCount uint64 `json:"totalWatchCount"`
}
// WatchConsumeReq 消费免费观看视频次数请求。Vid用于兼容旧字段名。
type WatchConsumeReq struct {
VideoID string `json:"videoId"`
Vid string `json:"vid"`
}
func (r WatchConsumeReq) GetVideoID() string {
if r.VideoID != "" {
return r.VideoID
}
return r.Vid
}
// WatchConsumeResp 消费免费观看视频次数响应。
type WatchConsumeResp struct {
IsCan bool `json:"isCan"`
WatchCount uint64 `json:"watchCount"`
TotalWatchCount uint64 `json:"totalWatchCount"`
Consumed bool `json:"consumed"`
}
// VideoInfo 返回的视频列表
type VideoInfo struct {
VideoBase
UInfo Publisher `json:"publisher,omitempty"`
Location LocInfo `json:"location,omitempty"`
VidStatus VideoStatus `json:"vidStatus,omitempty"`
Comment CommentInfo `json:"comment,omitempty"`
Watch WatchModel `json:"watch,omitempty"`
SortCode int `json:"-"` // 对专题内视频排序
HappinessPlazaTop int32 `json:"happinessPlazaTop"` //是否是幸福广场置顶
DiscountAreaPrice int64 `json:"discountAreaPrice"` //折扣专区展示价格
VideoTypeId string `json:"videoTypeId"` //视频分类ID
VideoTypeName string `json:"videoTypeName"` //视频分类名称
}
// VideoInfoResp 返回的视频列表
type VideoInfoResp struct {
ID primitive.ObjectID `json:"id" bson:"_id"` // ID
NewsType string `json:"newsType" bson:"newsType"` // 帖子类型, SP,视频帖子,COVER
Title string `json:"title" bson:"title"` // 视频标题
SourceURL string `json:"sourceURL" bson:"sourceURL"` // 视频资源地址Path
H265Url string `json:"h265Url" bson:"h265Url"` // H.265 视频资源地址
LinkUrl string `json:"linkUrl,omitempty" bson:"linkUrl,omitempty"` // 广告跳转连接 目前只有广告帖子有用
PlayTime uint `json:"playTime" bson:"playTime"` // 影片长度
Cover string `json:"cover" bson:"cover"` // 封面大图
SeriesCover []string `json:"seriesCover" bson:"seriesCover"` // 帖子套图
PlayCount int `json:"playCount" bson:"playCount"` // 总播放量
LikeCount int `json:"likeCount" bson:"likeCount"` // 点赞数
PageViewCount int64 `json:"pageViewCount" bson:"pageViewCount"` // 视频页面展示次数
CommentCount int `json:"commentCount" bson:"commentCount"` // 评论数
Coins int64 `json:"coins" bson:"coins"` // 折扣后视频金币数(如果有的话)
Size int `json:"size" bson:"size"` // 文件大小 byte
Resolution string `json:"resolution" bson:"resolution"` // 分辨率
Ratio float64 `json:"ratio" bson:"ratio"` // 宽高比
Status int `json:"status" bson:"status"` // 状态,0 未审核 1通过 2审核失败 3视为免费 默认为0
Reason string `json:"reason" bson:"reason"` // 视频未通过审核时的理由
FreeTime int `json:"freeTime" bson:"freeTime"` // 免费时长
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建时间
ReviewAt time.Time `json:"reviewAt" bson:"reviewAt,omitempty"` // 审核时间
IsTopping bool `json:"isTopping" bson:"isTopping"` // 是否置顶
IsPopping bool `json:"isPopping" bson:"isPopping"` // 是否推广
IsRecommend bool `json:"isRecommend" bson:"isRecommend"` // 力荐
IsChoosen bool `json:"isChoosen" bson:"isChoosen"` // 置精
Rewarded decimal.Decimal `json:"rewarded" bson:"rewarded"` // 打赏金额
OriginCoins int64 `json:"originCoins" bson:"originCoins"` // 视频原金币数
TotalWorks int64 `json:"totalWorks" bson:"totalWorks"` // 总作品数
Chosen bool `json:"chosen" bson:"chosen"` // 是否精选
UInfo AppPublisherResp `json:"publisher,omitempty"` // 用户信息
VidStatus VideoStatus `json:"vidStatus,omitempty"` // 视频状态
Watch WatchModel `json:"watch,omitempty"` // 是否观看
DownloadAllow int `json:"downloadAllow"` // 允许下载的VIP级别,0表示不允许下载 1表示VIP 2表示免费
ShowType int `json:"showType"` // 0-所有的人都可以看 1-奇数可看 2-偶数可看
FreeArea bool `json:"freeArea" bson:"freeArea"` // 免费专区
SearchAccessToken string `json:"searchAccessToken,omitempty" bson:"-"`
ShowFreeTrialBadge bool `json:"showFreeTrialBadge" bson:"-"` // 是否展示免费试看角标
FreeTrialRemaining uint64 `json:"freeTrialRemaining" bson:"-"` // 用户剩余免费观看次数
CanUseFreeTrial bool `json:"canUseFreeTrial" bson:"-"` // 当前视频是否可使用免费观看次数
//视频标签
Tags []TagInfo `json:"tags" bson:"tags"`
}
// AppPublisherResp 发布者的信息
type AppPublisherResp struct {
UID uint64 `json:"uid" bson:"uid"` // 用户id
Name string `json:"name" bson:"name"` // 姓名
Portrait string `json:"portrait" bson:"portrait"` // 头像
HasFollowed bool `json:"hasFollowed" bson:"hasFollowed"` // 是否关
VipLevel int `json:"vipLevel" bson:"vipLevel"` // VIP等级
VipExpireDate time.Time `json:"vipExpireDate,omitempty" bson:"vipExpireDate"` // VIP过期时间
VipName string `json:"vipName" bson:"vipName"` // 用户VIP名称
}
// RemoveVideoReq 删除自己的视频
type RemoveVideoReq struct {
IDs []string `json:"ids"`
}
// NewsListReq 帖子请求
type NewsListReq struct {
Type int `form:"type" json:"type"` //请求类型,默认0,最新帖子;1,最热帖子;2,同城; 3,付费视频
SubType int `form:"subType" json:"subType"` // type为0时, 0 默认; 1 只返回短视频 type为1时 1只返回麻豆
Version string `form:"version" json:"version"` // 原创新版识别标志
City string `form:"city" json:"city"` //城市
ReqTime string `form:"reqDate" json:"reqDate"` //请求时间
commod.Page
}
// NewsListResp 帖子应答
type NewsListResp struct {
List []*VideoInfo `json:"list"`
HasNext bool `json:"hasNext"`
}
type OriginalInfo struct {
List [][]*VideoInfo `json:"list"`
HasNext bool `json:"hasNext"`
Version string `json:"version"`
}
// UnlikeReq 不感兴趣
type UnlikeReq struct {
VideoID string `json:"videoID"`
}
// ListType 帖子类型
type ListType int
const (
Video ListType = iota // 视频帖子 默认为全部视频
LongVideo // 长视频
ShortVideo // 短视频
Image // 图片帖子
)
// ModelEnum 模块枚举
type ModelEnum int
const (
LatestZone ModelEnum = iota + 1 // 最新专区/最新上架
HottestZone // 最火专区/热门推荐
OriginalZone // 原创专区
GoldZone // 金币专区
HappinessPlaza // 幸福广场
MostLiked // 最多点赞
MostPlay // 最多播放
MYLickImage // 点赞图片作品
MyImage // 我的---图片作品
)
type PaymentEnum int
const (
PaymentDefault PaymentEnum = iota // 默认为全部帖子
PaymentVIP // 会员帖子
PaymentGold // 金币帖子
)
// AppListReq 帖子列表请求
type AppListReq struct {
Type ListType `json:"type" form:"type"` // 帖子类型
Model ModelEnum `json:"model" form:"model"` // 模块
Time time.Time `json:"time" form:"time"` // [最新专区、幸福广场]必传 值为第一次请求时间
Tag string `json:"tag" form:"tag"` // 标签
PaymentType PaymentEnum `json:"paymentType" form:"paymentType"` // 付费类型
UID uint64 `json:"uid" form:"uid"` // 用户ID
City string `form:"city" json:"city"`
FilterType uint `form:"filterType" json:"filterType"` //过滤类型 1-推荐 2-最新
commod.Page
}
// WorkCount 用户视频次数
type WorkCount struct {
Uid uint64 `json:"_id" bson:"_id"` // 用户ID
Count int64 `json:"count" bson:"count"` // 作品次数
}
type LibraryReq struct {
Canvas SortKey `json:"canvas" bson:"canvas"` // 视频分类
OrderBy SortKey `json:"orderBy" bson:"orderBy"` // 视频排序
Tags Tag `json:"tags" bson:"tags"` // 全部标签
PaymentType SortKey `json:"paymentType" bson:"paymentType"` // 付费分类
TimeType SortKey `json:"timeType" bson:"timeType"` // 时间排序
}
type LibraryData struct {
Canvas []SortKey `json:"canvas" bson:"canvas"` // 视频分类
OrderBy []SortKey `json:"orderBy" bson:"orderBy"` // 视频排序
VidTags []Tag `json:"vidTags" bson:"vidTags"` // 全部视频标签
ACGTags []Tag `json:"acgTags" bson:"acgTags"` // 全部ACG标签
PaymentType []SortKey `json:"paymentType" bson:"paymentType"` // 付费分类
TimeType []SortKey `json:"timeType" bson:"timeType"` // 时间排序
}
type SortKey struct {
Key string `json:"key" bson:"key"` // 健值
Name string `json:"name" bson:"name"` // 健名称
}
type Tag struct {
ID string `json:"id" bson:"id"` // 标签ID
Name string `json:"name" bson:"name"` // 标签名称
}
type ChangeVideoSectionReq struct {
SectionID string `uri:"sectionID" binding:"required"` // 专题ID
}
type HomeMostNewModuleVideoListReq struct {
commod.Page
SortType int `form:"sortType"` // 列表排序 1:最新 2:本周热门 4:本月最热 5:年度最热
}