init: 初始化 web_hgdjb_server 项目
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
package appg
|
||||
|
||||
import (
|
||||
"videoweb/pub/common/ipaddr"
|
||||
"videoweb/pub/payCenter"
|
||||
|
||||
"github.com/patrickmn/go-cache"
|
||||
)
|
||||
|
||||
const EsIndex = "sz"
|
||||
|
||||
var (
|
||||
Conf GlobalCfgEx
|
||||
Cache *cache.Cache
|
||||
DetectorV6 *ipaddr.XDBDetector
|
||||
DetectorV4 *ipaddr.XDBDetector
|
||||
)
|
||||
|
||||
type NameSource struct {
|
||||
FamilyNames []string `yaml:"familyNames"`
|
||||
MiddleNames []string `yaml:"middleNames"`
|
||||
AfterNames []string `yaml:"afterNames"`
|
||||
}
|
||||
type PictureSource struct {
|
||||
Portrait []string `yaml:"portrait"`
|
||||
UserbackGround []string `yaml:"userbackground"`
|
||||
ActressBackground []string `yaml:"actressbackground"`
|
||||
}
|
||||
type GlobalCfgEx struct {
|
||||
Redis struct {
|
||||
Addr string `yaml:"addr"`
|
||||
Db int `yaml:"db"`
|
||||
Passwd string `yaml:"passwd"`
|
||||
Subscribe bool `yaml:"subscribe"`
|
||||
}
|
||||
|
||||
Mongodb struct {
|
||||
Addr string `yaml:"addr"`
|
||||
LogAddr string `yaml:"logaddr"`
|
||||
RecomAddr string `yaml:"recomaddr"`
|
||||
AIOrderCenter string `yaml:"aiordercenter"`
|
||||
}
|
||||
Es struct {
|
||||
Addr string `yaml:"addr"`
|
||||
User string `yaml:"user"`
|
||||
Pass string `yaml:"pass"`
|
||||
} `yaml:"es"`
|
||||
RecomSys struct {
|
||||
Enable bool `yaml:"enable"`
|
||||
Addr string `yaml:"addr"`
|
||||
ApiKey string `yaml:"apikey"`
|
||||
} `yaml:"recomsys"`
|
||||
HttpOptions struct {
|
||||
DcCtxTimeOut uint64 `yaml:"dcCtxTimeOut"` //代充http请求 超时ctx取消时间
|
||||
} `yaml:"httpOptions"`
|
||||
Kafka struct {
|
||||
Url string `yaml:"url"`
|
||||
Group string `yaml:"group"`
|
||||
} `yaml:"kafka"`
|
||||
JwtKey string `yaml:"jwtKey"`
|
||||
RunMod string `yaml:"runMod"`
|
||||
ResKey string `yaml:"resKey"`
|
||||
CdnKey string `yaml:"cdnKey"`
|
||||
Pprof bool `yaml:"pprof"`
|
||||
Master bool `yaml:"master"` //是否是主节点
|
||||
Host string `yaml:"host"`
|
||||
ListenAddr string `yaml:"listenAddr"`
|
||||
KfAppId string `yaml:"kfAppId"`
|
||||
KfSecret string `yaml:"kfSecret"`
|
||||
KfApiUrlPrefix string `yaml:"kfApiUrlPrefix"`
|
||||
VersionUrl string `yaml:"versionUrl"`
|
||||
KafkaUrl string `yaml:"kafkaUrl"`
|
||||
CenterDomain string `yaml:"centerDomain"`
|
||||
TgToken string `yaml:"tgToken"`
|
||||
ReplayAttackConfig struct {
|
||||
Enable bool `yaml:"enable"`
|
||||
AppKey string `yaml:"appkey"`
|
||||
GuestKey string `yaml:"guestKey"`
|
||||
} `yaml:"attack"`
|
||||
ReplayH5AttackConfig struct {
|
||||
Enable bool `yaml:"enable"`
|
||||
AppKey string `yaml:"appkey"`
|
||||
GuestKey string `yaml:"guestKey"`
|
||||
} `yaml:"h5attack"`
|
||||
PayCenter struct {
|
||||
Addr string `yaml:"addr"`
|
||||
AppId int64 `yaml:"appId"`
|
||||
Serect string `yaml:"serect"`
|
||||
} `yaml:"payCenter"`
|
||||
AiCenterAppId int64 `yaml:"aiCenterAppId"`
|
||||
AiUndressingCallbackUrl string `yaml:"aiUndressingCallbackUrl"`
|
||||
NavigateUrl string `yaml:"navigateUrl"`
|
||||
NewProductUrl string `yaml:"newProductUrl"`
|
||||
TransactionUrl string `yaml:"transactionUrl"` // 支付下单地址
|
||||
LocalWebUrl string `yaml:"localWebUrl"`
|
||||
NewPayCenter payCenter.Conf `yaml:"newPayCenter"`
|
||||
JituanProductUrl string `yaml:"jituanProductUrl"`
|
||||
AiImageToVideoUrl string `yaml:"aiImageToVideoUrl"` // AI图生视频请求地址
|
||||
AiTextToImageUrl string `yaml:"aiTextToImageUrl"` // Ai文生图请求地址
|
||||
AiMateH5 string `yaml:"aiMateH5"`
|
||||
OrigDomain string `yaml:"origDomain"` // M3U8下载地址
|
||||
CdnAuthKey string `yaml:"cdnAuthKey"`
|
||||
TsAuthKey string `yaml:"tsAuthKey"`
|
||||
TrustedProxies string `yaml:"trustedProxies"`
|
||||
BucketVideoAddressV2 string `yaml:"bucketVideoAddressV2"`
|
||||
AdCenter struct {
|
||||
ApiDomain string `yaml:"apiDomain"` // api地址 如:https://adopenapi.adcs01.top
|
||||
MerchantCode string `yaml:"merchantCode"` // 商户 code
|
||||
AppCode string `yaml:"appCode"` // 应用 code
|
||||
AesKey string `yaml:"aesKey"` // 数据解密KEY
|
||||
} `yaml:"adCenter"`
|
||||
DataReport struct {
|
||||
Url string `yaml:"url"`
|
||||
} `yaml:"dataReport"`
|
||||
LsjMediaConf struct {
|
||||
AppId string `yaml:"appId"`
|
||||
ApiKey string `yaml:"apiKey"`
|
||||
ApiUrl string `yaml:"apiUrl"`
|
||||
ImageYuan string `yaml:"imageYuan"`
|
||||
KeyHex string `yaml:"keyHex"`
|
||||
M3u8Yuan string `yaml:"m3u8Yuan"`
|
||||
TsYuan string `yaml:"tsYuan"`
|
||||
DomainsRefreshHr int64 `yaml:"domainsRefreshHr"`
|
||||
} `yaml:"lsjMediaConf"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package appg
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/patrickmn/go-cache"
|
||||
)
|
||||
|
||||
func InitCache() {
|
||||
Cache = cache.New(5*time.Minute, 10*time.Minute)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package appg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand/v2"
|
||||
"time"
|
||||
)
|
||||
|
||||
var familyNames = []string{
|
||||
"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈",
|
||||
"褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许",
|
||||
"何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏",
|
||||
"陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章",
|
||||
"云", "苏", "潘", "葛", "奚", "范", "彭", "郎", "鲁", "韦",
|
||||
}
|
||||
|
||||
var givenNames = []string{
|
||||
"伟", "芳", "娜", "秀英", "敏", "静", "丽", "强", "磊", "洋",
|
||||
"艳", "勇", "军", "杰", "娟", "涛", "明", "超", "秀兰", "霞",
|
||||
"平", "刚", "桂英", "华", "玲", "辉", "英", "志明", "建国", "文",
|
||||
"国强", "小红", "建军", "小明", "宇", "浩", "晨", "鑫", "博", "宸",
|
||||
"若曦", "雨桐", "梓涵", "紫萱", "雨萱", "诗涵", "欣怡", "嘉怡", "子涵", "梦琪",
|
||||
}
|
||||
|
||||
// GenerateNickname 随机生成一个中文昵称,格式:姓+名
|
||||
// 若词表为空则降级为"用户"+时间戳后6位
|
||||
func GenerateNickname() string {
|
||||
if len(familyNames) == 0 || len(givenNames) == 0 {
|
||||
return fmt.Sprintf("用户%06d", time.Now().UnixNano()%1000000)
|
||||
}
|
||||
family := familyNames[rand.IntN(len(familyNames))]
|
||||
given := givenNames[rand.IntN(len(givenNames))]
|
||||
return family + given
|
||||
}
|
||||
Reference in New Issue
Block a user