Initial commit

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-23 11:07:42 +08:00
co-authored by Claude Opus 5.5
commit 7974a42301
633 changed files with 120248 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
package srv_videotopic
import (
"time"
"videoweb/pub/models/videoinformationmod"
"videoweb/pub/models/videotopicmod"
"videoweb/pub/pubdef"
)
type VideoTopicReq struct {
VideoCategoryId *int64 `json:"videoCategoryId" bson:"videoCategoryId"`
pubdef.Page
}
type VideoTopicResp struct {
Total int64 `json:"total"`
List videotopicmod.VideoTopicModelList `json:"list"`
}
type VideoTopicUpdate struct {
Name *string `json:"name" bson:"name,omitempty"` // 名称
Title *string `json:"title" bson:"title,omitempty"` // APP显示
Desc *string `json:"desc" bson:"desc,omitempty"` // 描述
Rank *int64 `json:"rank" bson:"rank,omitempty"` //
SeoInfo *pubdef.SeoValue `json:"seoInfo" bson:"seoInfo,omitempty"` // Seo相关信息
Status *bool `json:"status" bson:"status,omitempty"` // 上架状态
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt,omitempty"`
IsReIndexNow *bool `json:"isReIndexNow" bson:"isReIndexNow,omitempty"` // 是否重新提交索引
IndexNow *int64 `bson:"indexNow,omitempty"`
Image *string `json:"image" bson:"image,omitempty"` // 背景
VideoCategoryId *int64 `json:"videoCategoryId" bson:"videoCategoryId,omitempty"` // 视频分类id
VideoTopicType *videoinformationmod.MediaType `json:"videoTopicType" bson:"videoTopicType"` // 视频类型
}
type VideoTopicUpdateReq struct {
Id int64 `json:"id" binding:"required"`
Param VideoTopicUpdate `json:"param" bson:"param"` // appId,唯一id
}
type VideoTopicDelReq struct {
Id int64 `json:"id" binding:"required"`
}
+90
View File
@@ -0,0 +1,90 @@
package srv_videotopic
import (
"context"
"time"
"videoweb/pub/common/srvdef"
"videoweb/pub/models/videotopicmod"
"videoweb/pub/mongos"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"
)
// GetVideoTopics 按照参数搜索视频分类
func GetVideoTopics(ctx context.Context, param *VideoTopicReq) (*VideoTopicResp, *srvdef.SrvErr) {
filter := bson.M{}
if param.VideoCategoryId != nil {
filter[videotopicmod.FN.VideoTopicModel.VideoCategoryId] = *param.VideoCategoryId
}
opt := &options.FindOptions{}
resp := &VideoTopicResp{}
opt.SetSort(bson.M{videotopicmod.FN.VideoTopicModel.Rank: -1})
opt.SetSkip((param.PageNum - 1) * param.PageSize).SetLimit(param.PageSize)
total, serr := videotopicmod.CountVideoTopicModels(ctx, filter)
if serr != nil {
return resp, serr
}
resp.Total = total
if total == 0 {
return resp, nil
}
ads, serr := videotopicmod.FindManyVideoTopicModels(ctx, filter, opt)
if serr != nil {
return resp, serr
}
resp.List = ads
return resp, nil
}
// AddVideoTopic 添加一个视频分类
func AddVideoTopic(ctx context.Context,
ac *videotopicmod.VideoTopicModel) *srvdef.SrvErr {
ac.Id = mongos.Lid.VideoTopic.Get()
now := time.Now()
ac.CreatedAt = now
ac.UpdatedAt = now
serr := videotopicmod.InsertOneVideoTopicModel(ctx, ac)
if serr != nil {
return serr
}
return nil
}
// DelVideoTopic 删除指定视频分类
func DelVideoTopic(ctx context.Context, id int64) *srvdef.SrvErr {
adFilter := bson.M{videotopicmod.FN.VideoTopicModel.Id: id}
//删除
count, serr := videotopicmod.DelOneVideoTopicModel(ctx, adFilter)
if serr != nil {
return serr
}
if count == 0 {
return srvdef.New(srvdef.ErrNoData, "", "")
}
return nil
}
// UpdateVideoTopic 更新指定视频分类
func UpdateVideoTopic(ctx context.Context, id int64, param VideoTopicUpdate) *srvdef.SrvErr {
now := time.Now()
param.UpdatedAt = now
adFilter := bson.M{videotopicmod.FN.VideoTopicModel.Id: id}
param.IndexNow = nil
if param.IsReIndexNow != nil && *param.IsReIndexNow {
indexNow := int64(0)
param.IndexNow = &indexNow
}
updateDoc := bson.M{"$set": param}
serr := videotopicmod.UpdateOneVideoTopicModel(ctx, adFilter, updateDoc)
if serr != nil {
return serr
}
return nil
}