Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

72 lines
2.2 KiB
Go

package videoactivitymod
import (
"time"
"91porn-server/models/commod"
"91porn-server/models/v/vidmod"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options"
)
type LeaderboardType int
const (
Original LeaderboardType = iota // 原创榜
UP // UP主榜
)
type ListRequest struct {
ActivityID string `form:"activityId" json:"activityId"` // 当前活动ID
Type LeaderboardType `form:"type" json:"type"` // 榜单类型
commod.Page
}
type ListResponse struct {
ActivityID primitive.ObjectID `json:"activityId"` // 当前活动ID
ActivityBackgroundImage string `json:"activityBackgroundImage"` // 活动背景图
ActivityEndTime time.Time `json:"activityEndTime"` // 活动结束时间
ActivityDesc string `json:"activityDesc"` // 活动详情描述
WorkList []*vidmod.VideoInfo `json:"workList"` // 作品列表
HasNext bool `json:"hasNext"` // 是否有下一页
}
func (receiver *ListRequest) Filter() (primitive.M, error) {
activityId, err := primitive.ObjectIDFromHex(receiver.ActivityID)
if err != nil {
return nil, err
}
filter := bson.M{
"activityId": activityId,
"status": 1,
"newsType": vidmod.SP,
}
if receiver.Type == UP {
filter["isMadou"] = true
}
return filter, nil
}
func (receiver *ListRequest) Options() *options.FindOptions {
return options.Find().SetSkip(int64((receiver.PageNumber - 1) * receiver.PageSize)).SetLimit(int64(receiver.PageSize + 1)).SetSort(bson.M{"fakeLikeCount": -1})
}
type HistoryRecordRequest struct {
commod.Page
}
func (receiver *HistoryRecordRequest) Filter() primitive.M {
return bson.M{}
}
func (receiver *HistoryRecordRequest) Options() *options.FindOptions {
return options.Find().SetSkip(int64((receiver.PageNumber - 1) * receiver.PageSize)).SetLimit(int64(receiver.PageSize + 1)).SetSort(bson.M{"endTime": -1})
}
type HistoryRecordResponse struct {
HasNext bool `json:"hasNext"` // 是否有下一页
ActivityList []*VideoActivity `json:"activityList"` // 列表
}