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
+127
View File
@@ -0,0 +1,127 @@
package moduleser
import (
"91porn-server/app/appg"
"91porn-server/common"
"91porn-server/common/constant/redisconst"
"91porn-server/common/log"
"91porn-server/models/v/marqueemod"
"91porn-server/models/v/moduleconfmod"
"91porn-server/models/v/modulesectionmod"
"91porn-server/models/v/tagmod"
"91porn-server/models/v/usermod"
"encoding/json"
"errors"
"fmt"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type AnnouncementResp struct {
//跑马灯
Announcement []string `json:"announcement"`
}
const (
repeat = 5
usualAnnouncements = `首充任意金额即送7天视频VIP,限时充值返利,最高返利10%,累计充值送大礼,最高赠送1688元,添加游戏专属土豆福利群@pfqipai,不定时发放惊喜大礼`
activityAnnouncements = `限时抢购虎虎生威永久卡,金币视频五折折扣,免费赠送50张观影券 `
)
// GetModuleAnnouncements 获取模块下的跑马灯
func GetModuleAnnouncements() (AnnouncementResp, error) {
marq, err := marqueemod.Get()
if err != nil {
return AnnouncementResp{}, err
}
res := AnnouncementResp{Announcement: make([]string, repeat)}
for i := 0; i < repeat; i++ {
res.Announcement[i] = marq.Content
}
return res, nil
}
func GetPublishTag(uid uint64) (data *tagmod.TagInfoRes, err error) {
user, err := usermod.FindUserByUID(uid)
if err != nil {
return nil, err
}
if user == nil || user.ID.IsZero() || user.HasLocked || user.HasBanned {
return nil, errors.New("user is null")
}
str, err := appg.Redis.Get(redisconst.PublishTagInfoCache)
if err != nil {
log.Warn(fmt.Sprintf("用户ID:%d;缓存获取广告列表信息异常:%v", uid, err))
}
data = &tagmod.TagInfoRes{}
if str != nil {
if err = json.Unmarshal([]byte(*str), &data); err == nil {
return
}
log.Warn(fmt.Sprintf("用户ID:%d;解析缓存数据异常:%v", uid, err))
}
// 获取模块
moduleConfs, err := moduleconfmod.GetModuleConfByType(moduleconfmod.Community)
if err != nil {
return
}
var sId []primitive.ObjectID
var tagIds []primitive.ObjectID
for _, i := range moduleConfs {
sId = append(sId, i.ID)
}
sections, err := modulesectionmod.GetBySectionBySids(sId)
if err != nil {
return
}
if len(sections) <= 0 {
return
}
for _, s := range sections {
if s.TagIds != nil && len(*s.TagIds) > 0 {
tagIds = append(tagIds, *s.TagIds...)
}
}
if len(tagIds) <= 0 {
return
}
tags, err := tagmod.FindOneTagByIds(tagIds)
if err != nil {
return
}
for _, t := range tags {
info := tagmod.TagInfo{
ID: t.ID,
Description: t.Description,
FollowCount: t.CollCount,
Name: t.TagName,
VidCount: t.VideoCount,
PlayCount: t.TPlayCount,
CoverImg: t.CoverImg,
}
data.List = append(data.List, info)
}
common.Go(func() {
if data != nil {
d, err := json.Marshal(data)
if err != nil {
return
}
if err = appg.Redis.Set(redisconst.PublishTagInfoCache, d, 15*time.Minute); err != nil {
log.Warn(fmt.Sprintf("用户ID:%d;保存缓存数据异常:%v", uid, err))
}
}
})
return
}