Initial commit: web_hghl_server
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package videoinformationmod
|
||||
|
||||
import (
|
||||
"context"
|
||||
"videoweb/pub/common/srvdef"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
const CategoryRankField = "_categoryRank"
|
||||
|
||||
// VideoCategoryRank 视频在指定分类下的排序
|
||||
type VideoCategoryRank struct {
|
||||
Id int64 `json:"id" bson:"id"` // 分类ID
|
||||
Rank int64 `json:"rank" bson:"rank"` // 排序值,越大越靠前
|
||||
}
|
||||
|
||||
// CategoryRankAddFields 提取当前分类的排序值,未配置时为0
|
||||
func CategoryRankAddFields(categoryId int64) bson.M {
|
||||
return bson.M{CategoryRankField: bson.M{"$let": bson.M{
|
||||
"vars": bson.M{"hit": bson.M{"$first": bson.M{"$filter": bson.M{
|
||||
"input": bson.M{"$ifNull": bson.A{"$categoryRanks", bson.A{}}},
|
||||
"as": "b",
|
||||
"cond": bson.M{"$eq": bson.A{"$$b.id", categoryId}},
|
||||
}}}},
|
||||
"in": bson.M{"$ifNull": bson.A{"$$hit.rank", 0}},
|
||||
}}}
|
||||
}
|
||||
|
||||
// CategoryRankSort 按当前分类排序后使用上架时间和ID稳定分页
|
||||
func CategoryRankSort() bson.D {
|
||||
return bson.D{{Key: CategoryRankField, Value: -1}, {Key: FN.VideoInformation.AddedTime, Value: -1}, {Key: FN.VideoInformation.Id, Value: -1}}
|
||||
}
|
||||
|
||||
// FindManyVideoByCategoryRank 按指定分类排序分页查询视频
|
||||
func FindManyVideoByCategoryRank(ctx context.Context, filter bson.M, categoryId, skip, limit int64, projection bson.M) (VideoInformationList, *srvdef.SrvErr) {
|
||||
pipeline := []bson.M{
|
||||
{"$match": filter},
|
||||
{"$addFields": CategoryRankAddFields(categoryId)},
|
||||
{"$sort": CategoryRankSort()},
|
||||
{"$skip": skip},
|
||||
{"$limit": limit},
|
||||
{"$unset": CategoryRankField},
|
||||
}
|
||||
if len(projection) > 0 {
|
||||
pipeline = append(pipeline, bson.M{"$project": projection})
|
||||
}
|
||||
list := make(VideoInformationList, 0)
|
||||
if err := AggregateVideoInformations(ctx, &list, pipeline); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package videoinformationmod
|
||||
|
||||
import (
|
||||
"context"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/mongos"
|
||||
|
||||
"fmt"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
// 表名
|
||||
var db *mongos.Collection
|
||||
|
||||
func Init(ctx context.Context) {
|
||||
// 获取数据库表
|
||||
db = mongos.Shop.Coll(TN.VideoInformation)
|
||||
// 获取数据库表
|
||||
indexes := []mongo.IndexModel{
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Tags, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.CreatorId, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.IndexNow, Value: 1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.CreatedAt, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.UpdatedAt, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Video.FileId, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: "nodes.nodeId", Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Id, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.HeatValue, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.IsRecommend, Value: 1},
|
||||
{Key: FN.VideoInformation.Sort, Value: -1},
|
||||
{Key: FN.VideoInformation.Real.WeekWatchs, Value: -1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.CategoryId, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.IsRecommend, Value: 1},
|
||||
{Key: FN.VideoInformation.Sort, Value: -1},
|
||||
{Key: FN.VideoInformation.Real.WeekWatchs, Value: -1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.CategoryId, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.UpdatedAt, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.CategoryId, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: -1},
|
||||
{Key: FN.VideoInformation.Fake.WatchTimes, Value: -1},
|
||||
{Key: FN.VideoInformation.UpdatedAt, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.MediaType, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.MediaType, Value: 1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Tags, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.IsRecommend, Value: 1},
|
||||
{Key: FN.VideoInformation.Sort, Value: -1},
|
||||
{Key: FN.VideoInformation.Real.WeekWatchs, Value: -1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Tags, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Tags, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.CreatorId, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Sort, Value: -1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.AddedTime, Value: 1},
|
||||
{Key: FN.VideoInformation.Sort, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.MonthWatchs, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.IsTop, Value: 1},
|
||||
{Key: FN.VideoInformation.Sort, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.ActressIds, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Sort, Value: -1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.ActressIds, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.ActressIds, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.ActressIds, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.ActressIds, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.VideoCount, Value: -1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.ActressIds, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.Likes, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.ActressIds, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.Likes, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.CategoryId, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.Likes, Value: -1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: -1},
|
||||
{Key: FN.VideoInformation.Fake.WatchTimes, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.Likes, Value: -1},
|
||||
{Key: FN.VideoInformation.Fake.Likes, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Sort, Value: -1},
|
||||
{Key: FN.VideoInformation.Real.WeekWatchs, Value: -1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.UpdatedAt, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.AddedTime, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: 1},
|
||||
{Key: FN.VideoInformation.Fake.WatchTimes, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.Likes, Value: 1},
|
||||
{Key: FN.VideoInformation.Fake.Likes, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.HevcStatus, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.Real.WatchTimes, Value: -1},
|
||||
{Key: FN.VideoInformation.Fake.WatchTimes, Value: -1},
|
||||
{Key: FN.VideoInformation.UpdatedAt, Value: -1},
|
||||
{Key: FN.VideoInformation.Id, Value: -1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.VideoInformation.HevcStatus, Value: 1},
|
||||
{Key: FN.VideoInformation.Status, Value: 1},
|
||||
{Key: FN.VideoInformation.UpdatedAt, Value: -1},
|
||||
},
|
||||
},
|
||||
}
|
||||
if _, err := db.CreateIndex(ctx, indexes); err != nil {
|
||||
panic(fmt.Sprintf("(channelmod:initVideoInformationIndex) Create VideoInformation Index failed! err:%+v:", err))
|
||||
}
|
||||
}
|
||||
|
||||
// InsertOneVideoInformation 插入一个渠道统计
|
||||
func InsertOneVideoInformation(ctx context.Context, qa *VideoInformation) *srvdef.SrvErr {
|
||||
if _, err := db.InsertOne(ctx, qa); err != nil {
|
||||
// log.Warn("VideoInformationmod:InsertOneVideoInformation db.InsertOne failed", log.E(err))
|
||||
return srvdef.New(srvdef.ErrDbInsertError, "", "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func InsertManyVideoInformation(ctx context.Context, qa []*VideoInformation) *srvdef.SrvErr {
|
||||
if _, err := db.InsertMany(ctx, &qa); err != nil {
|
||||
return srvdef.New(srvdef.ErrDbInsertError, "", "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DelOneVideoInformation 删除一个渠道统计
|
||||
func DelOneVideoInformation(ctx context.Context, filter bson.M) (
|
||||
int64, *srvdef.SrvErr) {
|
||||
count, err := db.DeleteOne(ctx, filter)
|
||||
if err != nil {
|
||||
log.Warn("VideoInformationmod:DelOneVideoInformation db.DeleteOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return 0, srvdef.New(srvdef.ErrDbDeleteError, "", "")
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// FindOneVideoInformation 查找一个渠道统计
|
||||
func FindOneVideoInformation(ctx context.Context, filter bson.M, opts ...*options.FindOneOptions) (
|
||||
*VideoInformation, *srvdef.SrvErr) {
|
||||
var VideoInformation VideoInformation
|
||||
if err := db.FindOneEx(ctx, &VideoInformation, filter, opts...); err != nil {
|
||||
if err != mongo.ErrNoDocuments {
|
||||
log.Warn("VideoInformationmod:FindOneVideoInformation db.FindOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return nil, srvdef.New(srvdef.ErrDbQueryError, "", "")
|
||||
}
|
||||
return nil, srvdef.New(srvdef.ErrNoData, "", "")
|
||||
}
|
||||
return &VideoInformation, nil
|
||||
}
|
||||
|
||||
func FindManyVideoInformations(ctx context.Context, filter bson.M, opts ...*options.FindOptions) (VideoInformationList, *srvdef.SrvErr) {
|
||||
data := make(VideoInformationList, 0)
|
||||
if err := db.Find(ctx, &data, filter, opts...); nil != err {
|
||||
log.Warn("faq:FindManyVideoInformations", log.E(err), log.Any("filter", filter))
|
||||
return nil, srvdef.New(srvdef.ErrDbQuery.Code, "", "")
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// CountVideoInformations 统计渠道统计数量
|
||||
func CountVideoInformations(ctx context.Context, filter bson.M) (
|
||||
int64, *srvdef.SrvErr) {
|
||||
count, err := db.Count(ctx, filter)
|
||||
if err != nil {
|
||||
log.Warn("faqmod:CountVideoInformations db.Count failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return 0, srvdef.New(srvdef.ErrDbQueryError, "", "")
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// UpdateOneVideoInformation 更新一个渠道统计
|
||||
func UpdateOneVideoInformation(ctx context.Context, filter bson.M, update bson.M) *srvdef.SrvErr {
|
||||
result, err := db.UpdateOne(ctx, filter, update)
|
||||
if err != nil {
|
||||
log.Warn("post:UpdateOneVideoInformation db.UpdateOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return srvdef.New(srvdef.ErrDbUpdateError, "", "")
|
||||
}
|
||||
if result.MatchedCount != 1 {
|
||||
log.Warn("post:UpdateOneVideoInformation db.UpdateOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return srvdef.New(srvdef.ErrNoData, "", "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateManyVideoInformation(ctx context.Context, filter bson.M, update bson.M) *srvdef.SrvErr {
|
||||
result, err := db.UpdateMany(ctx, filter, update)
|
||||
if err != nil {
|
||||
log.Warn("post:UpdateManyVideoInformation db.UpdateOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return srvdef.New(srvdef.ErrDbUpdateError, "", "")
|
||||
}
|
||||
if result.MatchedCount < 1 {
|
||||
log.Warn("post:UpdateManyVideoInfomation db.UpdateOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return srvdef.New(srvdef.ErrNoData, "", "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func BulkWriteVideoInformation(ctx context.Context, docs []mongo.WriteModel,
|
||||
opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, *srvdef.SrvErr) {
|
||||
result, err := db.BulkWrite(ctx, docs, opts...)
|
||||
if err != nil {
|
||||
log.Warn("post:BulkWriteVideoInformation db.BulkWrite failed", log.E(err))
|
||||
return nil, srvdef.New(srvdef.ErrDbUpdateError, "", "")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AggregateVideoInformations 聚合查询视频信息
|
||||
func AggregateVideoInformations(ctx context.Context,
|
||||
bind interface{}, pipeline []bson.M) *srvdef.SrvErr {
|
||||
if err := db.Aggregate(ctx, bind, pipeline); err != nil {
|
||||
log.Warn("VideoInformation:AggregateVideoInformations db.Aggregate failed",
|
||||
log.E(err), log.Any("pipeline", pipeline))
|
||||
return srvdef.New(srvdef.ErrDbQueryError, "", "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Executable
+156
@@ -0,0 +1,156 @@
|
||||
package videoinformationmod
|
||||
|
||||
type TagVideoInformation struct {
|
||||
ActressIds string
|
||||
AddedTime string
|
||||
CategoryId string
|
||||
CategoryRanks string
|
||||
CoverImg string
|
||||
CreatedAt string
|
||||
CreatorId string
|
||||
CreatorName string
|
||||
Desc string
|
||||
FirstTag string
|
||||
Id string
|
||||
IndexNow string
|
||||
IsHot string
|
||||
IsTop string
|
||||
IssuedAt string
|
||||
Keyworld string
|
||||
MediaType string
|
||||
Nodes string
|
||||
Fake struct {
|
||||
Likes string
|
||||
WatchTimes string
|
||||
}
|
||||
Real struct {
|
||||
Comments string
|
||||
Likes string
|
||||
MonthWatchs string
|
||||
ShowTimes string
|
||||
TodayWatchs string
|
||||
WatchTimes string
|
||||
WeekWatchs string
|
||||
YearWatchs string
|
||||
WeekLikes string
|
||||
MonthLikes string
|
||||
YearLikes string
|
||||
}
|
||||
Remark string
|
||||
SecondTags string
|
||||
Sort string
|
||||
HeatValue string
|
||||
Status string
|
||||
Tags string
|
||||
Title string
|
||||
Slug string
|
||||
IsRecommend string
|
||||
UpdatedAt string
|
||||
PageUpdatedAt string
|
||||
Video struct {
|
||||
Cover string
|
||||
FileId string
|
||||
Height string
|
||||
H265Url string
|
||||
PreMp4FileNameFs string
|
||||
TaskId string
|
||||
Url string
|
||||
VideoTime string
|
||||
Width string
|
||||
UnencryptedPreMp4 string
|
||||
}
|
||||
VideoCount string
|
||||
IssuedBrand string
|
||||
Bango string
|
||||
RealUpdateAt string
|
||||
UploadUserName string
|
||||
OptionAccount string
|
||||
UnencryptedImage string
|
||||
SecondUpdatedAt string
|
||||
SyncId string
|
||||
HevcStatus string
|
||||
HevcFailCount string
|
||||
PreviewVtt string
|
||||
AudioFile string
|
||||
SmartCover string
|
||||
HevcMetaInfo string
|
||||
}
|
||||
|
||||
var FN struct {
|
||||
VideoInformation TagVideoInformation
|
||||
}
|
||||
|
||||
var TN struct {
|
||||
VideoInformation string
|
||||
}
|
||||
|
||||
func init() {
|
||||
FN.VideoInformation.ActressIds = "actressIds"
|
||||
FN.VideoInformation.AddedTime = "addedTime"
|
||||
FN.VideoInformation.CategoryId = "categoryId"
|
||||
FN.VideoInformation.CategoryRanks = "categoryRanks"
|
||||
FN.VideoInformation.CoverImg = "coverImg"
|
||||
FN.VideoInformation.CreatedAt = "createdAt"
|
||||
FN.VideoInformation.CreatorId = "creatorId"
|
||||
FN.VideoInformation.CreatorName = "creatorName"
|
||||
FN.VideoInformation.Desc = "desc"
|
||||
FN.VideoInformation.FirstTag = "firstTag"
|
||||
FN.VideoInformation.Id = "_id"
|
||||
FN.VideoInformation.IndexNow = "indexNow"
|
||||
FN.VideoInformation.IsHot = "isHot"
|
||||
FN.VideoInformation.IsTop = "isTop"
|
||||
FN.VideoInformation.IssuedAt = "issuedAt"
|
||||
FN.VideoInformation.Keyworld = "keyworld"
|
||||
FN.VideoInformation.MediaType = "mediaType"
|
||||
FN.VideoInformation.Nodes = "nodes"
|
||||
FN.VideoInformation.Fake.Likes = "fake.likes"
|
||||
FN.VideoInformation.Fake.WatchTimes = "fake.watchTimes"
|
||||
FN.VideoInformation.Real.Comments = "real.comments"
|
||||
FN.VideoInformation.Real.Likes = "real.likes"
|
||||
FN.VideoInformation.Real.MonthWatchs = "real.monthWatchs"
|
||||
FN.VideoInformation.Real.ShowTimes = "real.showTimes"
|
||||
FN.VideoInformation.Real.TodayWatchs = "real.todayWatchs"
|
||||
FN.VideoInformation.Real.WatchTimes = "real.watchTimes"
|
||||
FN.VideoInformation.Real.WeekWatchs = "real.weekWatchs"
|
||||
FN.VideoInformation.Real.YearWatchs = "real.yearWatchs"
|
||||
FN.VideoInformation.Real.WeekLikes = "real.weekLikes"
|
||||
FN.VideoInformation.Real.MonthLikes = "real.monthLikes"
|
||||
FN.VideoInformation.Real.YearLikes = "real.yearLikes"
|
||||
FN.VideoInformation.Remark = "remark"
|
||||
FN.VideoInformation.SecondTags = "secondTags"
|
||||
FN.VideoInformation.Sort = "sort"
|
||||
FN.VideoInformation.HeatValue = "heatValue"
|
||||
FN.VideoInformation.Status = "status"
|
||||
FN.VideoInformation.Tags = "tags"
|
||||
FN.VideoInformation.Title = "title"
|
||||
FN.VideoInformation.Slug = "slug"
|
||||
FN.VideoInformation.IsRecommend = "isRecommend"
|
||||
FN.VideoInformation.UpdatedAt = "updatedAt"
|
||||
FN.VideoInformation.PageUpdatedAt = "pageUpdatedAt"
|
||||
FN.VideoInformation.Video.Cover = "video.cover"
|
||||
FN.VideoInformation.Video.FileId = "video.fileId"
|
||||
FN.VideoInformation.Video.Height = "video.height"
|
||||
FN.VideoInformation.Video.H265Url = "video.h265Url"
|
||||
FN.VideoInformation.Video.PreMp4FileNameFs = "video.preMp4FileNameFs"
|
||||
FN.VideoInformation.Video.TaskId = "video.taskId"
|
||||
FN.VideoInformation.Video.Url = "video.url"
|
||||
FN.VideoInformation.Video.VideoTime = "video.videoTime"
|
||||
FN.VideoInformation.Video.Width = "video.width"
|
||||
FN.VideoInformation.Video.UnencryptedPreMp4 = "video.unencryptedPreMp4"
|
||||
FN.VideoInformation.VideoCount = "videoCount"
|
||||
FN.VideoInformation.IssuedBrand = "issuedBrand"
|
||||
FN.VideoInformation.RealUpdateAt = "realUpdateAt"
|
||||
FN.VideoInformation.Bango = "bango"
|
||||
FN.VideoInformation.UploadUserName = "uploadUserName"
|
||||
FN.VideoInformation.OptionAccount = "optionAccount"
|
||||
FN.VideoInformation.UnencryptedImage = "unencryptedImage"
|
||||
FN.VideoInformation.SyncId = "syncId"
|
||||
FN.VideoInformation.SecondUpdatedAt = "secondUpdatedAt"
|
||||
FN.VideoInformation.HevcStatus = "hevcStatus"
|
||||
FN.VideoInformation.HevcFailCount = "hevcFailCount"
|
||||
FN.VideoInformation.PreviewVtt = "previewVtt"
|
||||
FN.VideoInformation.AudioFile = "audioFile"
|
||||
FN.VideoInformation.SmartCover = "smartCover"
|
||||
FN.VideoInformation.HevcMetaInfo = "hevcMetaInfo"
|
||||
TN.VideoInformation = "video_information"
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package videoinformationmod
|
||||
|
||||
import (
|
||||
"time"
|
||||
"videoweb/pub/pubdef"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
// VideoInformation 视频信息集合
|
||||
// @table:video_information
|
||||
type VideoInformation struct {
|
||||
Id int64 `json:"id" bson:"_id,omitempty"`
|
||||
Title string `json:"title" bson:"title"` // 标题
|
||||
Slug string `json:"slug" bson:"slug"` // slug
|
||||
Bango string `bson:"bango,omitempty" json:"bango"` // 番号,唯一
|
||||
MediaType MediaType `json:"mediaType" bson:"mediaType"` // 资源类型
|
||||
AddedTime time.Time `json:"addedTime" bson:"addedTime"` // 上架时间
|
||||
ActressIds []int64 `json:"actressIds" bson:"actressIds"` // 女优ID
|
||||
CreatorId int64 `json:"creatorId" bson:"creatorId"` // 作者Id
|
||||
CreatorName string `json:"creatorName" bson:"creatorName"` // 作者名称
|
||||
Keyworld []string `json:"keyworld,omitempty" bson:"keyworld"` // 关键字
|
||||
CategoryId int64 `json:"categoryId,omitempty" bson:"categoryId"` // 分类ID
|
||||
CategoryRanks []VideoCategoryRank `json:"categoryRanks" bson:"categoryRanks"` // 各分类下的排序
|
||||
FirstTag string `bson:"firstTag,omitempty" json:"firstTag"` // 一级标签
|
||||
SecondTags []string `bson:"secondTags,omitempty" json:"secondTags"` // 二级标签标签
|
||||
CoverImg string `bson:"coverImg,omitempty" json:"coverImg"` // 封面
|
||||
UnencryptedImage string `bson:"unencryptedImage,omitempty" json:"unencryptedImage"` // 不加密封面
|
||||
Desc string `bson:"desc,omitempty" json:"desc"` // 详细描述
|
||||
Remark string `bson:"remark,omitempty" json:"remark"` // 备注
|
||||
Nodes []Node `json:"nodes" bson:"nodes"` // 节点
|
||||
Status pubdef.InformationStatus `json:"status" bson:"status"` // 帖子上架状态
|
||||
Video VideoInfo `json:"video" bson:"video"` // 视频
|
||||
Tags []int64 `json:"tags" bson:"tags"` // 标签
|
||||
IsHot bool `json:"isHot" bson:"isHot"` // 是否热门
|
||||
IsRecommend bool `json:"isRecommend" bson:"isRecommend"` // 是否推荐 true-推荐 false-不推荐
|
||||
Sort int64 `json:"sort" bson:"sort"` // 排序
|
||||
HeatValue int64 `json:"heatValue" bson:"heatValue"` // 后台热度值
|
||||
Real pubdef.Flow `json:"real" bson:"real"` // 真实流量
|
||||
Fake pubdef.FakeFlow `json:"fake" bson:"fake"` // 伪造流量
|
||||
VideoCount int64 `json:"videoCount" bson:"videoCount"` // 合集视频数量
|
||||
IndexNow int64 `json:"indexNow" bson:"indexNow"` // 是否需要提交 0:代表提交 1:表示已提交 运营通过接口可以修改
|
||||
IssuedAt time.Time `json:"issuedAt" bson:"issuedAt"` // 发行时间
|
||||
IssuedBrand string `json:"issuedBrand" bson:"issuedBrand"` // 发行商
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` // 更新时间
|
||||
PageUpdatedAt time.Time `json:"pageUpdatedAt" bson:"pageUpdatedAt"` // 页面展示更新时间
|
||||
RealUpdateAt time.Time `json:"realUpdateAt" bson:"realUpdateAt"` // 播放相关数据更新时间
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建时间
|
||||
IsTop bool `json:"isTop" bson:"isTop"` // 是否置顶
|
||||
UploadUserName string `bson:"uploadUserName" json:"uploadUserName,omitempty"` // 上传用户名
|
||||
OptionAccount string `bson:"optionAccount,omitempty" json:"optionAccount"` // 最后操作人
|
||||
SyncId string `json:"syncId" bson:"syncId"` // 同步ID
|
||||
SecondUpdatedAt time.Time `json:"secondUpdatedAt" bson:"secondUpdatedAt"` // 二次修改时间
|
||||
HevcStatus HevcStatus `json:"hevcStatus" bson:"hevcStatus"` // 主视频 H265 转码状态
|
||||
HevcFailCount int `json:"hevcFailCount" bson:"hevcFailCount"` // 主视频转码累计失败次数
|
||||
PreviewVtt string `json:"previewVtt" bson:"previewVtt,omitempty"` // 雪碧图 vtt
|
||||
AudioFile string `json:"audioFile" bson:"audioFile,omitempty"` // 音频文件路径
|
||||
SmartCover string `json:"smartCover" bson:"smartCover,omitempty"` // 智能封面
|
||||
HevcMetaInfo *VideoMetaInfo `json:"hevcMetaInfo" bson:"hevcMetaInfo,omitempty"` // H265 视频元信息
|
||||
}
|
||||
type VideoInformationList []*VideoInformation
|
||||
|
||||
// HevcStatus H265 转码状态(主视频 video.url)。
|
||||
type HevcStatus int
|
||||
|
||||
const (
|
||||
HevcStatusNone HevcStatus = 0 // 未提交转码
|
||||
HevcStatusPending HevcStatus = 1 // 转码中
|
||||
HevcStatusSuccess HevcStatus = 2 // 转码成功
|
||||
HevcStatusFailed HevcStatus = -1 // 转码失败
|
||||
)
|
||||
|
||||
// VideoMetaInfo H265 转码视频元信息(对应老司机 hevc_meta_info)。
|
||||
type VideoMetaInfo struct {
|
||||
M3u8URL string `json:"m3u8Url" bson:"m3u8Url,omitempty"`
|
||||
Codec string `json:"codec" bson:"codec,omitempty"`
|
||||
Profile string `json:"profile" bson:"profile,omitempty"`
|
||||
Width int `json:"width" bson:"width,omitempty"`
|
||||
Height int `json:"height" bson:"height,omitempty"`
|
||||
Fps float64 `json:"fps" bson:"fps,omitempty"`
|
||||
VideoBitrate int `json:"videoBitrate" bson:"videoBitrate,omitempty"`
|
||||
PixFmt string `json:"pixFmt" bson:"pixFmt,omitempty"`
|
||||
AudioCodec string `json:"audioCodec" bson:"audioCodec,omitempty"`
|
||||
AudioBitrate int `json:"audioBitrate" bson:"audioBitrate,omitempty"`
|
||||
AudioSampleRate int `json:"audioSampleRate" bson:"audioSampleRate,omitempty"`
|
||||
AudioChannels int `json:"audioChannels" bson:"audioChannels,omitempty"`
|
||||
Bitrate int `json:"bitrate" bson:"bitrate,omitempty"`
|
||||
Size int64 `json:"size" bson:"size,omitempty"`
|
||||
Duration float64 `json:"duration" bson:"duration,omitempty"`
|
||||
}
|
||||
|
||||
type Node struct {
|
||||
NodeId string `json:"nodeId" bson:"nodeId"` // 节点ID
|
||||
Title string `bson:"title" json:"title"` // 节点标题
|
||||
Videos []VideoInfo `json:"videos" bson:"videos"` // 视频信息列表
|
||||
Images []string `json:"images" bson:"images"` // 图片
|
||||
Url string `json:"url" bson:"url"` // 链接
|
||||
Text string `json:"text" bson:"text"` // 文本
|
||||
}
|
||||
|
||||
type VideoInfo struct {
|
||||
TaskId string `json:"taskId" bson:"taskId"` // 视频ID(视频才会存在)
|
||||
FileId string `json:"fileId" bson:"fileId"` // 媒资库ID
|
||||
Url string `json:"url" bson:"url"` // H.264 m3u8 播放地址(始终存在)
|
||||
H265Url string `json:"h265Url" bson:"h265Url"` // H.265 m3u8 播放地址,空字符串表示暂无该编码源
|
||||
Cover string `json:"cover" bson:"cover"` // 视频封面
|
||||
Height int64 `json:"height" bson:"height"` // 分辨率高(视频才会存在)
|
||||
Width int64 `json:"width" bson:"width"` // 分辨率宽(视频才会存在)
|
||||
VideoTime int32 `bson:"videoTime" json:"videoTime"` // 影片长度
|
||||
PreMp4FileNameFs string `bson:"preMp4FileNameFs,omitempty" json:"preMp4FileNameFs"` // 预览MP4文件
|
||||
UnencryptedPreMp4 string `bson:"unencryptedPreMp4,omitempty" json:"unencryptedPreMp4"` // 不加密的预览MP4
|
||||
}
|
||||
|
||||
type VideoSortItem struct {
|
||||
Key VideoSortType `json:"key" form:"key"` // 传递值
|
||||
Value string `json:"value" form:"value"` // 显示名字
|
||||
}
|
||||
|
||||
type MediaType int64
|
||||
|
||||
const (
|
||||
MediaType_Video MediaType = 0 // 视频
|
||||
MediaType_Collection MediaType = 1 // 合集
|
||||
MediaType_Advitise MediaType = 2 // 广告
|
||||
MediaType_AV MediaType = 3 // AV视频
|
||||
)
|
||||
|
||||
// VideoSortType 排序条件
|
||||
type VideoSortType int64
|
||||
|
||||
const (
|
||||
VideoSortType_Recommend VideoSortType = 1 // 最近最佳
|
||||
VideoSortType_Hot VideoSortType = 2 // 最多观看
|
||||
VideoSortType_New VideoSortType = 3 // 最新更新
|
||||
)
|
||||
|
||||
var VideoSortTypeName = map[VideoSortType]string{
|
||||
VideoSortType_Recommend: "最近最佳",
|
||||
VideoSortType_New: "最新更新",
|
||||
VideoSortType_Hot: "最多观看",
|
||||
}
|
||||
var VideoSortItems = []VideoSortItem{
|
||||
{Key: VideoSortType_Recommend, Value: "最近最佳"},
|
||||
{Key: VideoSortType_New, Value: "最新更新"},
|
||||
{Key: VideoSortType_Hot, Value: "最多观看"},
|
||||
}
|
||||
|
||||
func (s VideoSortType) GetSortBson() bson.D {
|
||||
switch s {
|
||||
case VideoSortType_Recommend:
|
||||
return bson.D{{FN.VideoInformation.Sort, -1}, {FN.VideoInformation.Real.WeekWatchs, -1}}
|
||||
case VideoSortType_Hot:
|
||||
return bson.D{{FN.VideoInformation.Real.WatchTimes, -1}}
|
||||
case VideoSortType_New:
|
||||
return bson.D{{FN.VideoInformation.AddedTime, -1}}
|
||||
default:
|
||||
return bson.D{{FN.VideoInformation.AddedTime, -1}}
|
||||
}
|
||||
}
|
||||
|
||||
func (s VideoSortType) GetSortItem() VideoSortItem {
|
||||
switch s {
|
||||
case VideoSortType_Recommend:
|
||||
return VideoSortItems[0]
|
||||
case VideoSortType_Hot:
|
||||
return VideoSortItems[2]
|
||||
case VideoSortType_New:
|
||||
return VideoSortItems[1]
|
||||
default:
|
||||
return VideoSortItems[0]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user