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
+3
View File
@@ -0,0 +1,3 @@
package cacheconst
const LocalCdnCacheKey = "cdn:cache" //本地缓存cdn域名列表
+375
View File
@@ -0,0 +1,375 @@
package constant
import "strings"
const (
//DevRunmod 开发环境
DevRunmod = "dev"
//TestRunmod 测试环境
TestRunmod = "test"
//RelRunmod 生产环境
ReleaseRunmod = "prod"
//ChannelTypeFile 渠道日志导出
ChannelLogTypeFile = 1
//ChannelNumTypeFile 渠道号导出
ChannelNumTypeFile = 2
//UserList 用户列表导出
UserList = 3
Ver1_6_4 = "1.6.4"
Ver2_1_0 = "2.1.0"
Ver3_0_7 = "3.0.7"
Ver3_1_0 = "3.1.0"
Ver3_6_0 = "3.6.0" //更换了加密方式, 增加了注册 devID 签名校验, 修正了x-api-key的问题
)
const DefaultBloggerVideoIncomeTaxLevel int64 = 4
type NewsType = string
type AcgNewsType = string
type KeywordType = string
// 全局统一类型
const (
SP NewsType = "SP" // 长视频
SHORT NewsType = "SHORT" // 短视频
COVER NewsType = "COVER" // 图文帖子
PIC NewsType = "PIC" // 图集帖子
AD_COVER NewsType = "AD_COVER" // 图片广告
AD_SP NewsType = "AD_SP" // 视频广告
SEED_LINK NewsType = "SEED_LINK" // 种子/黄油帖子
AiPlaza string = "AiPlaza" // ai广场
KeywordTag KeywordType = "TAG" // 标签关键词
KeywordUser KeywordType = "USER" // 用户关键词
KeywordComment KeywordType = "COMMENT" // 评论关键词
Cartoon AcgNewsType = "video" // 动漫
Comics AcgNewsType = "image" // 漫画
Text AcgNewsType = "text" // 小说
Drama AcgNewsType = "drama" // 短剧
)
type RealmType = string
const (
SearchSP RealmType = SP
SearchShort RealmType = SHORT
SearchCover RealmType = COVER
SearchPic RealmType = PIC
SearchTag RealmType = KeywordTag
SearchUser RealmType = KeywordUser
// 单个功能特殊自定义
//SearchAll = RealmType("ALL") // 搜索全部
SearchComplex = RealmType("COMPLEX")
// Deprecated
FictionRealmType RealmType = "fiction"
// Deprecated
AudioBookRealmType RealmType = "audiobook"
)
// 收藏类型
type CollectType = string
const (
CollectTypeSP CollectType = SP // 影视
CollectTypeShort CollectType = SHORT // 短视频
CollectTypeCover CollectType = COVER // 图文
CollectTypePIC CollectType = PIC // 图集帖子
CollectTypeSEED_LINK CollectType = SEED_LINK // 黄油/种子帖子
CollectTypeAiPlaza CollectType = AiPlaza // ai广场帖子
CollectTypeTag CollectType = KeywordTag // 话题
// Deprecated
CollectTypeLocation = "location"
)
// 点赞类型
type LikeType = string
const (
LikeTypeSP LikeType = SP // 长视频
LikeTypeShort LikeType = SHORT // 短视频
LikeTypeCover LikeType = COVER // 图文
LikeTypePic LikeType = PIC // 图集
LikeTypeSEED_LINK LikeType = SEED_LINK // 黄油种子帖
LikeTypeAiPlaza LikeType = AiPlaza // ai广场帖子
// ACG "video":视频,"image":图片,"text":小说
LikeTypeCartoon LikeType = Cartoon // 动漫
LikeTypeComics LikeType = Comics // 漫画
LikeTypeText LikeType = Text // 小说
LikeTypeDrama LikeType = Drama // 短剧
LikeTypeComment LikeType = KeywordComment // 评论
)
// 评论状态
const (
CommentSTSAccessed = 1 // 通过审核
CommentSTSDeleted = 2 // 已删除
CommentSTSAutoFiltered = 3 // 被自动过滤
)
// 设备
const (
DeviceTypeIOS = "ios"
DeviceTypeAndroid = "android"
DeviceTypeH5 = "h5"
)
const AdGroupClientVersion = "1.12.2" // 这里得改成自己上线的这个ab测安卓版本号
// 机型
const (
SysTypeIOS = "ios"
SysTypeAndroid = "android"
SysTypeH5 = "h5"
)
// gin中ctx使用的key
const (
CtxUserID = "USER_ID"
CtxAdminAct = "ADMIN_ACT"
CtxDistrictName = "DISTRICT_USER_ID"
CtxUA = "UA"
CtxIP = "IP"
CtxJuShangCID = "JU_SHANG_CID"
CtxAdminRole = "ADMIN_ROLE"
CtxNudeChatMerchant = "Nude_Chat_Merchant"
)
const (
CaptchaLen = 6
)
const (
ProdEnv = "prod"
)
// 推广码链接参数
const (
PromotionField = "?pc="
DiscField = "?dc="
)
// web操作栏目
const (
Administrator = "系统管理员"
AuthorManager = "权限管理"
UserManageList = "用户列表"
VideoManageCheck = "视频审核"
VideoManageList = "视频列表"
VideoDiscountArea = "折扣专区"
VideoDiscountAreaVideo = "折扣专区视频"
VideoManageTag = "标签管理"
VideoManageCity = "城市列表"
VideoManageHotCity = "热门城市"
VideoManageComment = "评论管理"
VideoManageSource = "资源管理"
VideoManageTone = "音色最热"
ProductManageVIP = "vip商品列表"
ProductManageCoin = "金币列表"
ProductManagePage = "推广落地页配置"
ProductManagePayType = "支付方式"
TradeManageRechargeOrder = "充值订单管理"
TradeManageWithdrawOrder = "提现订单列表"
FinancialTransferOrder = "财务转账列表"
TradeManageWithdrawType = "提现方式配置"
TradeManageWithdrawBank = "提现银行配置"
TradeManageWithdrawRefund = "提现人工退款"
RejectTemplate = "审核拒绝模板"
AdsManageAdsList = "广告列表"
AdsManageAnnousList = "公告管理"
AdsManageAnnounceList = "会员中心跑马灯管理"
SystemManageVersion = "版本管理"
ActiveManageList = "活动列表"
IPBlockList = "IP限制列表"
IPWhiteList = "IP白名单列表"
IPWhiteRedisKey = "white_ip_"
SwitchList = "开关量列表"
AutoAccount = "自助结算审核"
ExchangeCode = "兑换码管理"
MerchantAdmin = "代充商人管理"
Disc = "商区"
GoldConfig = "支付优惠配置"
FreeVidConfig = "免费观看配置"
RoleConfig = "角色配置"
JuShangManageList = "聚商管理"
NewsModel = "嫩模活动"
RewardList = "获奖列表"
Loufeng = "楼风"
VerifyReport = "验证报告"
Fiction = "电子书小说"
Audiobook = "有声小说"
VIPConfig = "VIP配置"
AiUndressList = "AI脱衣列表"
IntegralConfig = "积分配置列表"
IntegralExchange = "积分兑换列表"
OfficialConfig = "官方配置"
AiChangefaceVidMod = "AI换脸视频模版"
AiChangeface = "AI视频换脸"
AiChangeFaceImgList = "AI图片换脸列表"
Section = "专题列表"
VideoGoldCoinList = "金币视频列表"
AdvanceConfig = "预售配置列表"
OfficialWebsiteConfig = "官网配置"
)
// web操作方式
const (
Add = "新增"
Delete = "删除"
Modify = "修改"
)
// 推荐维度
const (
ChosenVideo = "chosenVideo"
TagVideo = "tagVideo"
SameCityVideo = "sameCityVideo"
NewVideo = "newVideo"
UnPopularVideo = "unPopularVideo"
ForcePushSP = "forcePushSP" //强推视频纬度
ChargeVideo = "chargeVideo"
)
// IpBlock 类型
const (
BlockComment = "comment"
FrequencyComment = "frequencyComment" // 评论频率
Register = "login" //限制用户注册
GlobalBlock = "global" //全局限制该IP用户访问
)
// switch 落地页按钮类型
type SwitchAct string
const (
SwitchIosEnterprise SwitchAct = "iosEnterprise"
SwitchIosStore SwitchAct = "iosStore" //商店包(TF包)
SwitchAndroid SwitchAct = "android"
)
// switch 落地页按钮样式
type SwitchStyle string
const (
SwitchStress SwitchStyle = "switchStress" //突出的开关风格
SwitchSimple SwitchStyle = "switchSimple" //简单的开关风格
)
// 机器人的uid最大值
const (
RobotUIDLimit = 111999
)
// DeleteUID
const (
DeleteUID uint64 = 100008
)
const (
UserLowestTrueScore int64 = 10
)
type DomainNameStatus int64
const (
Normal DomainNameStatus = iota
WxBlock
)
const (
RCHG_Mode_SDK = "sdk"
RCHG_Mode_URL = "url"
RechargeAmtTolerance = 500
)
const (
MongoRandomSpareLen int = 5
)
const (
Media_Del = 1 //"媒体删除"
Media_Edit_Status = 2 //"媒体更新状态"
Media_Edit_Price = 3 //"媒体更新价格"
Media_Edit_Content = 4 //"媒体更新标题内容"
Media_Edit_Remark = 5 //"媒体更新备注"
User_INCoin = 6 //"用户追加金币"
User_Edit_VIP_Type = 7 //"用户更新VIP类型"
User_Edit_VIP_PromoteEnd = 8 //"用户更新VIP新推广赠送免费到期时间"
User_Edit_VIP_Expire = 9 //"用户更新VIP过期时间"
User_Edit_VIP_RechargeLevel = 10 //"用户更新VIP充值等级"
User_INFruitCoin = 11 //"用户追加果币"
User_ReduceAmount = 12 //"回收用户金币"
User_ReduceIncome = 13 //"回收用户收益"
User_INAiMateBalance = 14 // 用户追加ai伴侣币
User_INIntegral = 15 //"用户追加积分"
)
const (
FakeMobilePrefix string = "+86122"
)
const (
MediaSourceSP string = "sp"
MediaSourceSPPrefixPath string = "/sp"
MediaSourcePMS string = "pms"
MediaSourcePMSPrefixPath string = "/pms"
ImageSourceIMS string = "ims"
ImageSourceIMSPrefixPath string = "/ims"
MediaSourceJH1B string = "jh1b" // 嘉华1部
MediaSourceLaoSiJi string = "laosiji" // 老司机
MediaSourceAuthKey string = "fT5xSg4hltHpzVy6aV9rVECDJ1J1pN"
)
// DefaultTsAuthKeyVersion 未配置密钥版本时的默认版本标识,随 TS URL 以 v={keyVersion} 下发。
const DefaultTsAuthKeyVersion = "default"
// TsAuthKeyConfig 媒体分片(TS)鉴权签名密钥配置。
type TsAuthKeyConfig struct {
KeyVersion string `json:"keyVersion"` // 密钥版本,随 TS URL 以 v={keyVersion} 下发
Key string `json:"key"` // 签名密钥
}
// Resolve 返回生效的密钥版本与签名密钥:
// 仅当未配置 Key(空或纯空白)时,才回退到内置默认——版本 DefaultTsAuthKeyVersion、密钥 MediaSourceAuthKey
// 配置了 Key 时,版本与密钥均按配置原样返回(版本可为空)。
func (c TsAuthKeyConfig) Resolve() (keyVersion, key string) {
if strings.TrimSpace(c.Key) == "" {
return DefaultTsAuthKeyVersion, MediaSourceAuthKey
}
return strings.TrimSpace(c.KeyVersion), c.Key
}
type Terminal = string //终端型号
const (
TerminalAndroid Terminal = "0"
TerminalH5 Terminal = "1"
TerminalWeb Terminal = "2"
)
// UIThemeEnum UI主题枚举
type UIThemeEnum int
const (
ThemeDefault UIThemeEnum = 0 // 默认主题
ThemeNewYear UIThemeEnum = 1 // 新春主题
)
@@ -0,0 +1,136 @@
package imnotifyconst
import "fmt"
//im 通知 模块
// Action 消息行为
type Action string
// Message 消息结构体
type Message struct {
Title string `json:"title"` //消息标题
MsgType Action `json:"msgType"` //消息类型
Data string `json:"data"` //内容
}
// 消息类型
const (
AccountCharge Action = "CHARGE" //充值消息
VIPCharge Action = "VIP-CHARGE" //VIP充值消息
BuyModel Action = "BUY—MODEL" //购买嫩模
AccountWithDraw Action = "WITHDRAW" //提现消息
VideoCheck Action = "VIDCHECK" //视频审核
BlockUser Action = "BLOCK" //用户禁止登陆
BannedUser Action = "BANNED" //用户禁言
UnBannedUser Action = "UNBANNED" //解除禁言
ForbidUpload Action = "FORBIDUPLOAD" //禁止上传文件
UnForbidUpload Action = "UNFORBIDUPLOAD" //解除禁止上传文件
SysOpUserCoins Action = "SysOpUserCoins" //系统操作用户金币
OfficialRecharge Action = "OfficialRecharge" //官方充值
OfficialSeekScore Action = "OfficialSeekScore" //官方追分
MeetingCard Action = "MeetingCard" //购买约会卡
UserReward Action = "UserReward" //玩家打赏通知
OtherCard Action = "OtherCard" //购买其他卡
UserFeedBackReply Action = "UserFeedBackReply" //用户反馈回复
LoufengFeedBackReply Action = "LoufengFeedBackReply" //楼凤举报回复
VerifyReport Action = "VerifyReport" //验证报告回复
UnBlockUser Action = "UNBLOCK" //解除用户禁止登陆
WithDrawRefuse Action = "WithDrawRefuse" //提现拒绝消息
WithDrawUnknownErr Action = "WithDrawUnknownErr" //提现未知错误
GrandPrize Action = "GrandPrize" //大奖通知
ConsumerFeedbackGame Action = "ConsumerFeedbackGame" //充值有礼(游戏)
ConsumerFeedback Action = "ConsumerFeedback" //消费回馈(楼凤)
NudeChatFeedBackReply Action = "NudeChatFeedBackReply" //裸聊举报回复
SysOpUserFruitCoin Action = "SysOpUserFruitCoin" //系统操作用户果币
)
var imNotifyTitle = map[Action]string{
VIPCharge: "VIP购买",
BuyModel: "购买嫩模",
AccountCharge: "充值到账",
AccountWithDraw: "提现到账",
VideoCheck: "视频审核",
BlockUser: "禁止登陆",
BannedUser: "禁言通知",
UnBannedUser: "解除用户禁言",
ForbidUpload: "禁止上传帖子",
UnForbidUpload: "解除禁止上传帖子",
SysOpUserCoins: "系统金币管理",
OfficialRecharge: "官方充值",
OfficialSeekScore: "官方追分",
MeetingCard: "购买约会卡",
UserReward: "玩家打赏",
UserFeedBackReply: "官方回复",
OtherCard: "购买其他卡",
LoufengFeedBackReply: "楼凤举报",
VerifyReport: "验证报告",
UnBlockUser: "解除封禁",
WithDrawRefuse: "提现拒绝",
WithDrawUnknownErr: "提现未知错误",
GrandPrize: "中奖通知",
ConsumerFeedbackGame: "充值有礼",
ConsumerFeedback: "消费回馈",
NudeChatFeedBackReply: "裸聊举报",
}
var imNotifyContent = map[Action]string{
VIPCharge: "官人,恭喜您购买%s成功,小娘子在此等候您的光临哦!",
BuyModel: "官人,恭喜您%s,小娘子在此等候您的光临哦!",
AccountCharge: "充值成功到账%s金币,请查收!",
AccountWithDraw: "提现成功到账%s金币,请查收!",
VideoCheck: "您的视频%s因%s审核未通过!",
BlockUser: "尊敬的用户,您因:%s,现做出封禁处理,如需要解除封禁,请联系客服咨询,谢谢!",
BannedUser: "尊敬的用户,您因:%s,受到系统禁言处理,如需要解除禁言,请联系客服咨询,谢谢!",
UnBannedUser: "尊敬的用户,恭喜您解除禁言,现在您可以畅所欲言啦!",
ForbidUpload: "尊敬的用户,您因:%s,系统作出禁止上传文件处理,如需要解除限制,请联系客服咨询,谢谢!",
UnForbidUpload: "尊敬的用户,恭喜您解除禁止上传帖子,现在您可以上传帖子,痛快的赚取收益啦!",
SysOpUserCoins: "尊敬的用户,系统%s您%s金币,请注意查看,谢谢!",
OfficialRecharge: "尊敬的用户,您已经通过官方充值到账%s金币,请注意查看,谢谢!",
OfficialSeekScore: "尊敬的用户,官方追分%s金币,如有疑惑,请联系客服!",
MeetingCard: "官人,恭喜您购买%s成功,小娘子在此等候您的光临哦!",
UserReward: "玩家%s打赏%s金币,请查收!",
OtherCard: "官人,恭喜您购买%s成功,小娘子在此等候您的光临哦!",
UserFeedBackReply: "尊敬的用户!针对您的问题:%s,官方在此作出认真解答:%s,如果您还有疑惑,请联系客服或继续反馈,谢谢您对我们的支持!",
LoufengFeedBackReply: "尊敬的用户!针对你举报的楼凤信息,官方已作出相应处理:%s,给您造成的不便,深感抱歉!",
VerifyReport: "尊敬的用户!您提交的关于%s验证报告因%s审核未通过!",
UnBlockUser: "尊敬的用户,恭喜您解除封禁.%s",
WithDrawRefuse: "尊敬的用户,你的提现申请因-s%已失败,金币已返还.",
WithDrawUnknownErr: "尊敬的用户,你的提现申请因网络异常原因发生异常,请联系客服确认金币是否返还",
GrandPrize: "官人,恭喜您%s,小娘子在此等候您的光临哦!",
ConsumerFeedbackGame: "恭喜您昨日游戏累计楼充值%s元,已满足游戏充值有礼领取条件,快点击本消息领取吧~",
ConsumerFeedback: "恭喜您今日累计楼凤消费%s金币,已满足消费回馈领取条件,快点击本消息领取吧~",
NudeChatFeedBackReply: "尊敬的用户!针对你举报的裸聊信息,官方已作出相应处理:%s,给您造成的不便,深感抱歉!",
SysOpUserFruitCoin: "尊敬的用户,系统%s您%s果币币,请注意查看,谢谢!",
}
func (a Action) Title() string {
if v, ok := imNotifyTitle[a]; ok {
return v
}
return ""
}
// 适用于无字符串字符的fmt模版
func (a Action) Desc() string {
if v, ok := imNotifyContent[a]; ok {
return v
}
return ""
}
// 适用于单个字符串字符的fmt模版
func (a Action) SingleStringParamData(amount string) string {
if v, ok := imNotifyContent[a]; ok {
return fmt.Sprintf(v, amount)
}
return ""
}
// 适用于双个字符串字符的fmt模版
func (a Action) DoubleStringParamData(p1 string, p2 string) string {
if v, ok := imNotifyContent[a]; ok {
return fmt.Sprintf(v, p1, p2)
}
return ""
}
@@ -0,0 +1,10 @@
package redisconst
import "testing"
func TestMostNewModuleVideoListKeyKeepsOriginalFormat(t *testing.T) {
got := GetMostNewModuleVideoListKey(1, 1, 10)
if want := "mostNewModuleVideoList:1:1:10"; got != want {
t.Fatalf("cache key = %q, want %q", got, want)
}
}
+688
View File
@@ -0,0 +1,688 @@
package redisconst
import (
"91porn-server/common/crypt"
"91porn-server/common/timeutil"
"91porn-server/common/timeutil/timerange"
"91porn-server/models/s/statrecordmod"
"encoding/json"
"fmt"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
const (
Db0ExpiredChannel = "__keyevent@0__:expired"
userTokenFmt = "token:user:%d"
UserTokenExpire = time.Hour
imSDKUserTokenFmt = "im:sdk:userToken:%d" // IM SDK 用户 token 缓存(按 imUserID
IMSDKUserTokenExpire = 12 * time.Hour
imSDKEnsureLockFmt = "im:sdk:ensure:lock:%d" // EnsureSDKUser 按 uid 加锁,防并发重复注册
IMSDKAppTokenKey = "im:sdk:appToken" // IM SDK appToken 缓存(内存 L1 + redis L2
MobileCaptchaMaxCountInMinute = 1 // 1分钟内同一手机号只能发送一次验证码
MobileCaptchaMaxCountInHour = 5 // 1小时内同一手机号只能发送五次验证码
MobileCaptchaMaxCountInDay = 10 // 1天内同一手机号只能发送十次验证码
mobileCaptchaFmt = "captcha:mobile:%s"
MobileCaptchaExpire = 5 * time.Minute
smsCaptchaIPFmt = "sms:captcha:ip:%s"
smsCaptchaUIDFmt = "sms:captcha:uid:%d"
smsCaptchaPhoneNumberFmt = "sms:captcha:number:%s" // sms:captcha:number:mobile:xxx 用于统计手机号发送验证码的次数
smsCaptchaUIDCooldownFmt = "sms:captcha:uid:cd:%d"
SMSCaptchaUIDCooldown = 1 * time.Minute
emailCaptchaFmt = "captcha:email:%s"
EmailCaptchaExpire = 5 * time.Minute
traderChatCacheFmt = "trader:cache:%d:%d"
TraderChatCacheExpire = 2 * time.Minute
withdrawCfgFmt = "withdraw:cache:cfg"
WithdrawCfgExpire = 8 * time.Hour
withdrawTariffFmt = "withdraw:tariff"
WithdrawTariffExpire = 8 * time.Hour
webTokenFmt = "token:%s:%s" //token:admin:xxx, token:channel:xxx
WebTokenExpire = 10 * time.Hour
visitLogsFmt = "visitlogs:%s" //visitlog:20301020
visitFmt = "visitFmt:%s" //统计访问频率
VisitExpireMax = 1 * time.Hour
registFmt = "registFmt:%s" //用户注册频率
RegistExpireMax = 1 * time.Hour
rankFmt = "rankFmt:%s"
RankExpireMax = 20 * time.Minute
toneFmt = "toneFmt"
ToneExpireMax = 20 * time.Minute
ipLocationFmt = "ip:city:%s" //ip:city:124.168.1.0.248 缓存ip
IPLocationExpireMax = 24 * time.Hour
ipBlockFmt = "ip:block:%s" // ip:block:comment 用于存放限制发表评论的ip
IPBlockExpire = 7 * 24 * time.Hour
ipAutoBlockFmt = "ip:auto:%s:%s" // ip:block:comment 用于自动限制基于IP的接口访问
autoBlockFmt = "auto:%s:%d" // ip:block:comment 用于自动限制基于次数的接口访问
dataCachFmt = "data:%s:%s" //visitlog:20301020:uid
DataCachExpire = time.Minute * 2
m3u8CacheFmt = "video:m3u8:%s" //video:m3u8:b0ac9b27eec64abebfc4c65cc4b89d03 m3u8键 //用于缓存添加相对的路径的m3u8文件
m3u8PureCacheFmt = "video:m3u8:pure:%s" //video:m3u8:b0ac9b27eec64abebfc4c65cc4b89d03 m3u8键 //用于缓存原生的m3u8文件
m3u8H5CacheFmt = "video:m3u8:h5:%s" //video:m3u8:b0ac9b27eec64abebfc4c65cc4b89d03 m3u8键 //用于缓存原生的m3u8文件
M3u8CacheExpire = 1 * time.Hour
m3u8HourlyCountFmt = "m3u8:hourly:count:%d" // 每用户每小时 m3u8 请求次数
M3u8HourlyCountExpire = 1 * time.Hour
// M3u8H5RefererSet H5 m3u8 请求来源计数(Redis ZSet)member=来源 scheme://host(Referer 缺省回退 Origin)
// score=累计请求次数。ZScore 查单个来源总数,ZRevRangeWithScores 看 Top 来源;每天凌晨 5 点(Asia/Shanghai)
// 过期清零、从零重新累计(刷回时 EXPIREAT 到下一个 5 点,见 updownctrl.FlushM3u8RefererStats)。
M3u8H5RefererSet = "m3u8:h5:referer"
CdnCacheKey = "cdn:cache:url" //cdn域名缓存
CdnCacheExpire = 2 * time.Minute
NewRegisterBehaFmt = "user:new:register:%d" //用户行为记录
NewRegisterBehaCountFmt = "user:new:register:%d:%s" //用户行为次数记录
NotifyKeyFmt = "notify:user:new:register:%d" //过期键通知
NotifyKeyExpire = 20 * time.Minute //专门设置的通知键
NewRegisterBehaExpire = 30 * time.Minute //用户
NewRegisterBehaCountExpire = 30 * time.Minute //用户
replayNonceFmt = "replay:nonce:%s" //接口调用sign值
tagGroup = "taggroup"
TagGroupExpireMax = time.Minute
DailyConsumeReward = "dailyConsumeReward:"
PayableAgentsKey = "payableAgents"
PayableAgentsExpire = 5 * time.Minute
MarqueeKey = "marquee"
playLeaderboardKey = "leaderboard:play:%s:%d"
playLeaderboardKeyExpire = 24 * time.Hour
NameSource = "name:source" //姓名池
NameSourceExpire = 2 * 24 * time.Hour
AdNewsListKeyFmt = "video:news:ad:%d" //广告ID列表
AdNewsListKeyExpire = time.Hour
LandDomainCacheKey = "domain:land" //落地页/推广域名 Key
LandDomainCacheExpire = 2 * time.Hour
userInfo = "user:info:%d"
userInfoExpire = 20 * time.Minute
tagInfo = "tag:info:%s"
tagInfoExpire = 20 * time.Minute
videoInfo = "video:info:%s"
videoInfoExpire = 30 * time.Minute
newestNews = "newest:news:%s"
newestNewsExpire = 5 * time.Minute
userRechargeLimit = "userRechargeLimit:%d" //token:admin:xxx, token:channel:xxx
userRechargeLimitExpire = 6 * time.Second
userReqLimit = "userRechargeLimit:%d:%s" //token:admin:xxx, token:channel:xxx
userReqLimitExpire = 1 * time.Second
userWithdrawLimit = "userWithdrawimit:%d" //userWithdrawimit:xxx
userWithdrawLimitExpire = 60 * time.Second
promotionCodeSetKey = "promotion_code_set" //推广码set key值
userLikeRateLimitKey = "userLike:%d"
userLikeRateLimitExpire = 6 * time.Second
userBuyVidRateLimitKey = "userBuyVid:%d"
userBuyVidRateLimitExpire = 6 * time.Second
initialPopKey = "vid:initialPopularity"
tagSortVidKey = "tagSortVid:%s:%v:%v:%d:%d"
tagSortVidExpire = 30 * time.Minute
userCollectionKey = "vid:userCollection:%d:%d:%d:%s:%d"
userCollectionExpire = 5 * time.Minute
vidPageViewListKey = "vidPageViewList:%d"
vidPageViewListExpire = 30 * time.Minute
waliPlayerMacSet = "waliPlayerMacSet:%s"
waliPlayerMacExpire = 24 * 7 * time.Hour
waliPlayerGlobalID = "waliPlayerGlobalIDSet:%s"
waliPlayerGlobalIDExpire = 24 * 7 * time.Hour
waliPlayerIP = "waliPlayerIPSet:%s"
waliPlayerIPExpire = 24 * time.Hour
WithdrawOrderKey = "withdraw:order:processing" // 提现处于审核中的用户
WithdrawOrderDuration = 15 * time.Minute // 过滤用户窗口时间
RedsyncUserKey = "redsync:user:%d" // 用户维度分布式锁
AiMateLoginLockKey = "redsync:ai-mate-login:%d"
AiFundLockKey = "redsync:ai-fund:%d"
RedsyncUserExpiration = 10 * time.Second // 用户维度分布式锁过期时间
ContentUpdateMarkersCache = "content:update-markers:v1"
ContentUpdateMarkersCacheExpire = 30 * time.Second
CenterAdvertiseCache = "centerAdvertiseCache" // 数据中心广告缓存
CenterVersionCache = "centerVersionCache:%s:%s:%s:%s" // 数据中心版本缓存
VidAdKey = "video:ad" //广告ID列表
VidAdKeyExpire = time.Minute * 2
active2023RedisKey = "active_2023:%d"
active2023Expired = time.Minute
// 幸福广场缓存
ImageTopKey = "imageTop:filter:%d"
ImageTopExpire = time.Minute * 5
userDailyTaskRewardLockKey = "userDailyTask:%d:%s"
userDailyTaskRewardLockExpire = time.Minute
// 缓存用户每日完成数量. 比如点击了x次广告
userDailyTaskCountKey = "userDailyTaskCount:%d:%d:%s"
// 缓存用户每日领取奖励次数.
userDailyTaskRewardTimeKey = "userDailyTaskRewardTime:%d:%d:%s"
// 缓存用户一次性任务完成情况
userOnceTaskCompleteKey = "userOnceTaskComplete:%d:%d"
userOnceTaskCompleteExpire = time.Hour * 24
ModulesCache = "modulesCache" // 模块缓存
dailyTaskCacheFmt = "dailyTask:%v:%v:%v" // 每日任务缓存
InviteCache = "inviteCache:uid:%v" // 推广数据缓存
PublishTagInfoCache = "publishTagInfoCache" // 发布标签缓存
ModuleVideoInfoCache = "moduleVideoInfoCache:mid:%v:%v:%v:%v:%v:%v" // 视频模块缓存
SectionVideoInfoCache = "sectionVideoInfoCache:mid:%v:sortType:%v:pageSize:%v:pageNumber:%v" // 视频模块缓存
AIModCache = "aiModCache" // AI模版缓存
GetAwVipInfo = "getAwVipInfo" // AWVip信息缓存
checkApiKeyFmt = "checkApi:ip:%s:api:%s:s:%v" // 接口调用
SensitiveWordsCache = "sensitiveWordsCache" // 敏感词库缓存
GameAdvanceCache = "gameAdvanceCache:%v" // 游戏预售缓存
AdvanceCache = "hj_advanceCache:%v" // 预售缓卡存
CheckApiKeyExpire = 1 * time.Minute
RecommendVip = "RecommendVip" // VIP推荐展示
RecommendVipExpire = 2 * time.Minute
DiscountArea = "DiscountArea" // 折扣专区列表缓存
DiscountAreaExpire = 2 * time.Minute
shortVideoListCache = "shortDiscoverList:types:%d:tagId:%s:page:%v_%v" // 短视频发现模块数据换粗
ShortVideoListCacheExpire = time.Minute * 10 // 短视频发现模块数据换粗
mediaTagInfoExpire = 20 * time.Minute
mediaTagInfo = "mediaTag:info:%s" // 动漫标签缓存
acgBrowseCountListKey = "acgBrowseCountList:%d"
MediaLibraryInfo = "mediaLibraryInfo:info" // 动漫片库缓存
ShortVideosKey = "short-videos-all-ids-list" // ShortVideosKey 短视频ID列表 - 用于推荐
VideoLibraryCache = "videoLibraryCache" // 片库缓存
ShortVideosRecoCacheKey = "shortVideosRecoCache" // 短视频-推荐 ID列表 - 用于短视频推荐
followUpUsersAndSHORTKey = "follow:%d:SHORT:%d_%d"
mostNewModuleVideoListKey = "mostNewModuleVideoList:%v:%v:%v" // 91porn 首页最新视频列表缓存key
MostNewModuleVideoListExpire = time.Minute * 10
MonitorCacheKey = "rs_monitorCache" // 监控缓存
MonitorExpired = time.Minute * 4
OfficialWebsiteBasicDataCacheKey = "officialWebsiteBasicDataCache" // 官方网站基础数据缓存
OfficialWebsiteBasicDataCacheExpire = time.Minute * 10
OfficialWebsiteAlbumListCacheKey = "officialWebsiteAlbumListCache:%d:%d" // 官方网站专辑列表缓存
OfficialWebsiteAlbumListCacheExpire = time.Minute * 10
OfficialWebsiteHeroListCacheKey = "officialWebsiteHeroListCache:%d:%d:%d" // 官方网站演员列表缓存
OfficialWebsiteHeroListCacheExpire = time.Minute * 10
OfficialWebsiteVideoListCacheKey = "officialWebsiteVideoListCache:%d:%s:%d:%d:%d" // 官方网站视频列表缓存
OfficialWebsiteVideoListCacheExpire = time.Minute * 10
OfficialWebsiteNewsListCacheKey = "officialWebsiteNewsListCache:%d:%d" // 官方网站资讯列表缓存
OfficialWebsiteNewsListCacheExpire = time.Minute * 10
OfficialWebsitePartnerListCacheKey = "officialWebsitePartnerListCache" // 官方网站合作伙伴列表缓存
OfficialWebsitePartnerListCacheExpire = time.Minute * 10
)
const (
NavigateRecreationCache = "navigateRecreationCache" // 导航站娱乐广告缓存
UserPaymentStatusPopupCache = "UserPaymentStatusPopup" // 用户分层弹窗配置缓存
)
const (
aiFreeUndressTodayUseTimes = "aiFreeUndressTodayUseTimes:%v"
)
const (
JanGangQuCacheKey = "jingangqu"
JanGangQuCacheExpire = 10 * time.Minute
)
const (
rankingListCacheKey = "ranking:%v:%v:%d:%d"
hotRankingListCacheKey = "hotRanking:%v:%v:%v"
RankingListCacheExpire = 10 * time.Minute
)
// 渠道订阅的 消息体
type RecommedPayload struct {
UID uint64 `json:"uid"`
City string `json:"city"`
Page int `json:"page"`
}
func GetFollowUpUsersAndSHORTKey(uid uint64, pageSize, pageNumber uint64) (string, time.Duration) {
return fmt.Sprintf(followUpUsersAndSHORTKey, uid, pageSize, pageNumber), time.Minute * 10
}
func GetMonitorCacheExpired() time.Duration {
return MonitorExpired
}
func AcgBrowseCountListKey(timestamp int64) string {
return fmt.Sprintf(acgBrowseCountListKey, timestamp)
}
func MediaTagInfoExpire() time.Duration {
return mediaTagInfoExpire
}
func MediaTagInfoKey(tid string) string {
return fmt.Sprintf(mediaTagInfo, tid)
}
func AiFreeUndressTodayUseTimesKey(uid uint64) string {
return fmt.Sprintf(aiFreeUndressTodayUseTimes, uid)
}
func UserTokenKey(uid uint64) string {
return fmt.Sprintf(userTokenFmt, uid)
}
// IMSDKUserTokenKey IM SDK 用户 token 缓存 key(按 imUserID
func IMSDKUserTokenKey(imUserID int64) string {
return fmt.Sprintf(imSDKUserTokenFmt, imUserID)
}
// IMSDKEnsureLockKey EnsureSDKUser 并发注册锁 key(按 uid
func IMSDKEnsureLockKey(uid uint64) string {
return fmt.Sprintf(imSDKEnsureLockFmt, uid)
}
func GameAdvanceKey(uid uint64) string {
return fmt.Sprintf(GameAdvanceCache, uid)
}
func AdvanceKey(uid uint64) string {
return fmt.Sprintf(AdvanceCache, uid)
}
// InviteCacheKey 推广数据
func InviteCacheKey(uid uint64) string {
return fmt.Sprintf(InviteCache, uid)
}
func CheckApiKey(ip, apiPath string, second time.Time) string {
return fmt.Sprintf(checkApiKeyFmt, ip, apiPath, second)
}
// SectionVideoInfoCacheKey 模块视频Key
func SectionVideoInfoCacheKey(sid string, sortType string, pageSize, pageNumber int64) string {
return fmt.Sprintf(SectionVideoInfoCache, sid, sortType, pageSize, pageNumber)
}
func DailyTaskCacheKey(uid uint64, taskType any, today time.Time) string {
return fmt.Sprintf(dailyTaskCacheFmt, taskType, uid, today)
}
func MobileCaptchaKey(mobile string) string {
return fmt.Sprintf(mobileCaptchaFmt, mobile)
}
func SMSCaptchaIPKey(ip string) string {
return fmt.Sprintf(smsCaptchaIPFmt, ip)
}
func SMSCaptchaIPExpire() time.Duration {
year, month, day := time.Now().Date()
return time.Until(time.Date(year, month, day+1, 0, 0, 0, 0, time.Local))
}
func SMSCaptchaUIDKey(uid uint64) string {
return fmt.Sprintf(smsCaptchaUIDFmt, uid)
}
func SMSCaptchaUIDCooldownKey(uid uint64) string {
return fmt.Sprintf(smsCaptchaUIDCooldownFmt, uid)
}
func SMSCaptchaPhoneNumberKey(mobile string) string {
return fmt.Sprintf(smsCaptchaPhoneNumberFmt, mobile)
}
func WebTokenKey(typ string, act string) string {
return fmt.Sprintf(webTokenFmt, typ, act)
}
func UserAdNewsListKey(uid uint64) string {
return fmt.Sprintf(AdNewsListKeyFmt, uid)
}
func VisitKey(t time.Time) string {
recentMinute := timerange.RecentMinute(t, statrecordmod.FiveMinuteScale) //对齐本次统计时间 Minute % frequency == 0
return fmt.Sprintf(visitFmt, recentMinute.Format("200601021504"))
}
func RegistKey(t time.Time) string {
recentMinute := timerange.RecentMinute(t, statrecordmod.FiveMinuteScale) //对齐本次统计时间 Minute % frequency == 0
return fmt.Sprintf(registFmt, recentMinute.Format("200601021504"))
}
func NotifyKey(uid uint64) string {
return fmt.Sprintf(NotifyKeyFmt, uid)
}
func RegistBehaviorKey(uid uint64) string {
return fmt.Sprintf(NewRegisterBehaFmt, uid)
}
func RegistBehaviorCountKey(uid uint64, req string) string {
return fmt.Sprintf(NewRegisterBehaCountFmt, uid, req)
}
func RankKey(rankType string) string {
return fmt.Sprintf(rankFmt, rankType)
}
func ToneKey() string {
return toneFmt
}
func UserVisitLogsKey(t time.Time) string {
return fmt.Sprintf(visitLogsFmt, t.Format("20060102"))
}
func UserVisitLogExpire(now time.Time) time.Duration {
return timeutil.BeginningOfTomorrow(now).Sub(now) + 5*time.Minute
}
func IpLocationFmt(ip string) string {
return fmt.Sprintf(ipLocationFmt, ip)
}
func M3u8CacheFmt(m3u8 string) string {
return fmt.Sprintf(m3u8CacheFmt, m3u8)
}
func M3u8PureCacheFmt(m3u8 string) string {
return fmt.Sprintf(m3u8PureCacheFmt, m3u8)
}
func M3u8H5CacheFmt(m3u8 string) string {
return fmt.Sprintf(m3u8H5CacheFmt, m3u8)
}
func M3u8HourlyCountKey(uid uint64) string {
return fmt.Sprintf(m3u8HourlyCountFmt, uid)
}
func UserInfoKey() string {
return userInfo
}
func TagInfoKey() string {
return tagInfo
}
func VideoInfoKey() string {
return videoInfo
}
func UserInfoExpire() time.Duration {
return userInfoExpire
}
func TagInfoExpire() time.Duration {
return tagInfoExpire
}
func VideoInfoExpire() time.Duration {
return videoInfoExpire
}
func DataCachKey(db string, m string) string {
return fmt.Sprintf(dataCachFmt, db, m)
}
func IPBlockKey(blockType string) string {
return fmt.Sprintf(ipBlockFmt, blockType)
}
func IPAutoBlockKey(blockType, ip string) string {
return fmt.Sprintf(ipAutoBlockFmt, blockType, ip)
}
func AutoBlockKey(blockType string, uid uint64) string {
return fmt.Sprintf(autoBlockFmt, blockType, uid)
}
func ReplayNonceKey(nonce string) string {
return fmt.Sprintf(replayNonceFmt, nonce)
}
func TagGroup() string {
return tagGroup
}
func TraderChatCacheKey(uid uint64, proT int) string {
return fmt.Sprintf(traderChatCacheFmt, uid, proT)
}
func WithdrawCfgCacheKey() string {
return withdrawCfgFmt
}
func WithdrawTariffCacheKey() string {
return withdrawTariffFmt
}
func NewestNewsKey(t time.Time) string {
return fmt.Sprintf(newestNews, t.String())
}
func NewestNewsKey_old() string {
return "newest:news"
}
func NewestShortVideoKey() string {
return "newest:shortvideo"
}
func NewestNewsExpire() time.Duration {
return newestNewsExpire
}
func RechargeLimtKey(uid uint64) string {
return fmt.Sprintf(userRechargeLimit, uid)
}
func RechargeLimtKeyExpire() time.Duration {
return userRechargeLimitExpire
}
func WithdrawLimtKey() string {
return userWithdrawLimit
}
func WithdrawLimtKeyExpire() time.Duration {
return userWithdrawLimitExpire
}
func PromotionCodeKey() string {
return promotionCodeSetKey
}
func WaLiIPSetKey(ip string) string {
return fmt.Sprintf(waliPlayerIP, ip)
}
func WaLiIPSetExpire() time.Duration {
return waliPlayerIPExpire
}
func WaLiMacSetKey(mac string) string {
return fmt.Sprintf(waliPlayerMacSet, mac)
}
func WaLiMacSetExpire() time.Duration {
return waliPlayerMacExpire
}
func WaLiDevSetKey(dev string) string {
return fmt.Sprintf(waliPlayerGlobalID, dev)
}
func WaLiDevSetExpire() time.Duration {
return waliPlayerGlobalIDExpire
}
func GetRedsyncUserKey(uid uint64) string {
return fmt.Sprintf(RedsyncUserKey, uid)
}
func GetAiMateLoginLockKey(uid uint64) string {
return fmt.Sprintf(AiMateLoginLockKey, uid)
}
func GetAiFundLockKey(uid uint64) string {
return fmt.Sprintf(AiFundLockKey, uid)
}
func GetUserLikeRateLimitKey() string {
return userLikeRateLimitKey
}
func GetUserLikeRateLimitExpire() time.Duration {
return userLikeRateLimitExpire
}
func GetEmailCaptchaKey(email string) string {
return fmt.Sprintf(emailCaptchaFmt, email)
}
func GetUserBuyVidRateLimitKey() string {
return userBuyVidRateLimitKey
}
func GetUserBuyVidRateLimitExpire() time.Duration {
return userBuyVidRateLimitExpire
}
func GetInitialVideoPopularityKey() string {
return initialPopKey
}
func GetTagSortVideoKey(tid string, newsType string, sort int, skip, limit uint64) string {
return fmt.Sprintf(tagSortVidKey, newsType, tid, sort, skip, limit)
}
func GetTagSortVideoExpire() time.Duration {
return tagSortVidExpire
}
func ReqLimtKey(uid uint64, m string) string {
return fmt.Sprintf(userReqLimit, uid, m)
}
func ReqLimtKeyExpire() time.Duration {
return userReqLimitExpire
}
func UserCollectionKey(uid uint64, pageNum, pageSize uint64, playTimeType int, sortType string) string {
return fmt.Sprintf(userCollectionKey, uid, pageNum, pageSize, sortType, playTimeType)
}
func UserCollectionExpire() time.Duration {
return userCollectionExpire
}
func VidPageViewListKey(timestamp int64) string {
return fmt.Sprintf(vidPageViewListKey, timestamp)
}
func VidPageViewListExpire() time.Duration {
return vidPageViewListExpire
}
func GetUserActive2023RedisKey(uid uint64) string {
return fmt.Sprintf(active2023RedisKey, uid)
}
func GetUserActive2023Expred() time.Duration {
return active2023Expired
}
func GetVersionRedisKey(a, b, c, d string) string {
return fmt.Sprintf(CenterVersionCache, a, b, c, d)
}
func PlayLeaderboardKey(rT string, timestamp int64) string {
return fmt.Sprintf(playLeaderboardKey, rT, timestamp)
}
func PlayLeaderboardKeyExpire() time.Duration {
return playLeaderboardKeyExpire
}
func GetUserDailyTaskRewardLockKey(uid uint64, taskId string) string {
return fmt.Sprintf(userDailyTaskRewardLockKey, uid, taskId)
}
func GetUserDailyTaskRewardLockExpired() time.Duration {
return userDailyTaskRewardLockExpire
}
// 缓存用户每日完成数量. 比如点击了x次广告
func GetUserDailyTaskCountKey(uid uint64, taskType int64) string {
return fmt.Sprintf(userDailyTaskCountKey, uid, taskType, time.Now().Format("2006-01-02"))
}
// 缓存用户每日领取奖励次数.
func GetUserDailyTaskRewardTimeKey(uid uint64, taskType int64) string {
return fmt.Sprintf(userDailyTaskRewardTimeKey, uid, taskType, time.Now().Format("2006-01-02"))
}
func GetUserDailyTaskExpired() time.Duration {
year, month, day := time.Now().Date()
return time.Until(time.Date(year, month, day+1, 0, 1, 0, 0, time.Local)) // 多缓存1分钟
}
// 用户一次性任务是否完成. value: 0 未完成; 1 已完成
func GetUserOnceTaskCompleteKey(uid uint64, taskType int64) string {
return fmt.Sprintf(userOnceTaskCompleteKey, uid, taskType)
}
func GetUserOnceTaskCompleteExpired() time.Duration {
return userOnceTaskCompleteExpire
}
const (
videoShareList = "videoShareList"
videoShareExpired = time.Minute * 10
)
func GetVideoShareListKey() string {
return videoShareList
}
func GetVideoShareListExpired() time.Duration {
return videoShareExpired
}
func GetShortVideoListCacheKey(types int, tid string, page, pagesize uint64) string {
return fmt.Sprintf(shortVideoListCache, types, tid, page, pagesize)
}
func GetRankingListExpired() time.Duration {
return RankingListCacheExpire
}
func GetRankingListCacheKey(v ...any) string {
return fmt.Sprintf(rankingListCacheKey, v...)
}
func GetHotRankingListCacheKey(tagIds []primitive.ObjectID, pageNumber, pageSize uint64) string {
b, _ := json.Marshal(tagIds)
md5Str := crypt.ByteToMd5(b)
return fmt.Sprintf(hotRankingListCacheKey, md5Str, pageNumber, pageSize)
}
func GetMostNewModuleVideoListKey(sortType int, page, pageSize uint64) string {
return fmt.Sprintf(mostNewModuleVideoListKey, sortType, page, pageSize)
}