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
+55
View File
@@ -0,0 +1,55 @@
package activityser
import (
"errors"
"91porn-server/common/stderr"
"91porn-server/models/v/activitymod"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func QueryAllRecord(in *activitymod.QueryAllRecordCond) (interface{}, stderr.Code) {
var data map[string]interface{} = map[string]interface{}{
"list": []interface{}{},
"count": 0,
}
count, err := activitymod.CountRecord(in.Query())
if err != nil {
return nil, stderr.ErrDbQueryError
}
if count == 0 {
return data, stderr.Success
}
list, err := activitymod.QueryAllRecord(in.Query(), in.Options())
if err != nil {
return nil, stderr.ErrDbQueryError
}
data["count"] = count
data["list"] = list
return data, stderr.Success
}
// 开启机器人抽奖
func OpenBotDraw(activityID primitive.ObjectID, status bool) error {
job.mutex.Lock()
defer job.mutex.Unlock()
if entryID, ok := job.cache[activityID]; ok {
if !status {
// 移除任务
job.cron.Remove(entryID)
delete(job.cache, activityID)
return nil
}
return errors.New("任务已开启")
}
if status {
// 加入任务(每小时执行一次)
entryID, err := job.cron.AddJob("@hourly", BotDraw{ActivityID: activityID})
if err != nil {
return err
}
job.cache[activityID] = entryID
}
return nil
}