Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
package actvser
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"91porn-server/models/v/actmod"
)
var dateMax = time.Date(2999, 12, 31, 0, 0, 0, 0, time.Local)
func GetActivities(req GetActitiesRequest) ([]actmod.Activity, bool, error) {
skip := uint64((req.PageNumber - 1) * req.PageSize)
limit := uint64(req.PageSize + 1)
actvs, err := actmod.GetActivitiesValid(skip, limit)
if err != nil {
return nil, false, err
}
hasNext := false
if uint64(len(actvs)) > req.PageSize {
hasNext = true
actvs = actvs[:req.PageSize]
}
now := time.Now()
for i := range actvs {
if actvs[i].ExpiredIn.IsZero() {
actvs[i].ExpiredIn = dateMax
continue
}
if actvs[i].ExpiredIn.Before(now) {
actvs[i].Status = 2 // 状态设置为已过期
}
}
return actvs, hasNext, nil
}
func GetActiveByID(id primitive.ObjectID) (*actmod.Activity, error) {
actv, err := actmod.GetActivityByActivityID(id)
if err != nil {
return nil, err
}
if actv.ExpiredIn.IsZero() {
actv.ExpiredIn = dateMax
return actv, nil
}
if actv.Status == 1 && actv.ExpiredIn.Before(time.Now()) {
actv.Status = 2
}
return actv, nil
}
+11
View File
@@ -0,0 +1,11 @@
package actvser
import "91porn-server/models/commod"
type GetActitiesRequest struct {
commod.Page
}
type GetActiveByIDRequest struct {
ID string `form:"id" json:"id" binding:"required"`
}