Initial commit: web_hghl_server
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
package srv_app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/models/contenttagmod"
|
||||
"videoweb/pub/models/videocategorymod"
|
||||
"videoweb/pub/models/videocollectionmediamod"
|
||||
"videoweb/pub/models/videocreatermod"
|
||||
"videoweb/pub/models/videoinformationmod"
|
||||
)
|
||||
|
||||
func AppVideoInfoSync(ctx context.Context, req *AppVideoInfoSyncReq) ([]*videoinformationmod.VideoInformation, *srvdef.SrvErr) {
|
||||
filter := bson.M{
|
||||
videoinformationmod.FN.VideoInformation.UpdatedAt: bson.M{
|
||||
"$gt": req.LastSyncTime},
|
||||
}
|
||||
opts := &options.FindOptions{}
|
||||
opts.SetSort(bson.M{videoinformationmod.FN.VideoInformation.UpdatedAt: 1})
|
||||
opts.SetLimit(req.PageSize)
|
||||
list, err := videoinformationmod.FindManyVideoInformations(ctx, filter, opts)
|
||||
if err != nil {
|
||||
log.Error("FindManyVideoInformations Failed", log.Any("err", err))
|
||||
return nil, err
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
func AppVideoCollectionSync(ctx context.Context, req *AppVideoCollectionSyncReq) ([]*AppVideoCollectionSyncInfo, *srvdef.SrvErr) {
|
||||
filter := bson.M{
|
||||
videocollectionmediamod.FN.VideoCollectionMediaModel.CollectionID: bson.M{"$in": req.CollectionId},
|
||||
}
|
||||
list, err := videocollectionmediamod.FindManyVideoCollectionMediaModels(ctx, filter)
|
||||
if err != nil {
|
||||
log.Error("FindManyVideoCollectionMediaModels Failed", log.Any("err", err))
|
||||
return nil, err
|
||||
}
|
||||
rsl := make([]*AppVideoCollectionSyncInfo, 0)
|
||||
for _, v := range list {
|
||||
rsl = append(rsl, &AppVideoCollectionSyncInfo{
|
||||
CollectionID: v.CollectionID,
|
||||
VideoId: v.VideoId,
|
||||
Rank: v.Rank,
|
||||
})
|
||||
}
|
||||
return rsl, nil
|
||||
}
|
||||
|
||||
func AppCategoryList(ctx context.Context) ([]AppCategoryInfo, *srvdef.SrvErr) {
|
||||
filter := bson.M{
|
||||
videocategorymod.FN.VideoCategory.Status: true,
|
||||
}
|
||||
opts := &options.FindOptions{}
|
||||
opts.SetSort(bson.M{videocategorymod.FN.VideoCategory.Rank: -1})
|
||||
list, err := videocategorymod.FindManyVideoCategorys(ctx, filter, opts)
|
||||
if err != nil {
|
||||
log.Error("FindManyVideoCategorys Failed", log.Any("err", err))
|
||||
return nil, err
|
||||
}
|
||||
resp := make([]AppCategoryInfo, 0)
|
||||
for _, v := range list {
|
||||
resp = append(resp, AppCategoryInfo{
|
||||
Id: v.Id,
|
||||
Name: v.Name,
|
||||
Title: v.Title,
|
||||
Desc: v.Desc,
|
||||
Rank: v.Rank,
|
||||
})
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func AppCreatorList(ctx context.Context) ([]AppCreatorInfo, *srvdef.SrvErr) {
|
||||
filter := bson.M{
|
||||
videocreatermod.FN.VideoCreaterInfo.Status: true,
|
||||
}
|
||||
opts := &options.FindOptions{}
|
||||
opts.SetSort(bson.M{
|
||||
videocreatermod.FN.VideoCreaterInfo.Sort: -1,
|
||||
})
|
||||
list, err := videocreatermod.FindManyVideoCreaterInfos(ctx, filter, opts)
|
||||
if err != nil {
|
||||
log.Error("FindManyVideoCreaterInfos Failed", log.Any("err", err))
|
||||
return nil, err
|
||||
}
|
||||
resp := make([]AppCreatorInfo, 0)
|
||||
for _, v := range list {
|
||||
resp = append(resp, AppCreatorInfo{
|
||||
Id: v.Id,
|
||||
Name: v.Name,
|
||||
Sort: v.Sort,
|
||||
})
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func AppTagList(ctx context.Context) ([]AppTagInfo, *srvdef.SrvErr) {
|
||||
filter := bson.M{
|
||||
contenttagmod.FN.ContentTag.Status: true,
|
||||
contenttagmod.FN.ContentTag.Types: contenttagmod.ContentTagTypeVideo,
|
||||
}
|
||||
opts := &options.FindOptions{}
|
||||
opts.SetSort(bson.D{
|
||||
{Key: contenttagmod.FN.ContentTag.Rank, Value: -1},
|
||||
{Key: contenttagmod.FN.ContentTag.Id, Value: -1},
|
||||
})
|
||||
list, err := contenttagmod.FindManyContentTag(ctx, filter, opts)
|
||||
if err != nil {
|
||||
log.Error("FindManyContentTag Failed", log.Any("err", err))
|
||||
return nil, err
|
||||
}
|
||||
resp := make([]AppTagInfo, 0)
|
||||
for _, v := range list {
|
||||
resp = append(resp, AppTagInfo{
|
||||
Id: v.Id,
|
||||
Title: v.Name,
|
||||
Sort: v.Rank,
|
||||
})
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
Reference in New Issue
Block a user