代码提交

This commit is contained in:
2026-10-16 12:28:09 +08:00
parent 75a0d00258
commit 5c5f5908aa
3 changed files with 17 additions and 7 deletions
+2 -2
View File
@@ -4,8 +4,8 @@ redis:
passwd: "Redis@fish2026!" passwd: "Redis@fish2026!"
subscribe: true subscribe: true
mongodb: mongodb:
addr: "mongodb://admin:3NjreBBLVOkptSWbV%21@172.104.56.78:47018,172.104.56.119:47018,172.104.56.146:47018/web_huangguo2?replicaSet=web_jiqun3&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2" addr: "mongodb://web_huangguo2:xDdEkf6m0HDpkEpxpphi@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/web_huangguo2?replicaSet=fish0&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
logaddr: "mongodb://admin:3NjreBBLVOkptSWbV%21@172.104.56.78:47018,172.104.56.119:47018,172.104.56.146:47018/web_huangguo2_log?replicaSet=web_jiqun3&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2" logaddr: "mongodb://web_huangguo2:xDdEkf6m0HDpkEpxpphi@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/web_huangguo2_log?replicaSet=fish0&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
es: es:
addr: "http://139.162.47.194:9200" addr: "http://139.162.47.194:9200"
user: "elastic" user: "elastic"
+13 -3
View File
@@ -79,6 +79,16 @@ func GetRandomLetters(n int) string {
return string(b) return string(b)
} }
// GetRandomAlphanumeric 生成 n 位大小写字母 + 数字随机串
func GetRandomAlphanumeric(n int) string {
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
b := make([]byte, n)
for i := range b {
b[i] = chars[rand.IntN(len(chars))]
}
return string(b)
}
func GetSlugInfo(text string) string { func GetSlugInfo(text string) string {
return SanitizeSlug(slug.Make(text)) return SanitizeSlug(slug.Make(text))
} }
@@ -114,12 +124,12 @@ func IsSlugAllDigits(s string) bool {
} }
// RandomSlugLength 随机 slug 长度 // RandomSlugLength 随机 slug 长度
const RandomSlugLength = 8 const RandomSlugLength = 10
// MakeRandomSlug 生成唯一的随机 slug(8 位小写字母);exists 返回 true 表示已被占用。 // MakeRandomSlug 生成唯一的随机 slug(10 位大小写字母+数字混合);exists 返回 true 表示已被占用。
func MakeRandomSlug(exists func(string) bool) string { func MakeRandomSlug(exists func(string) bool) string {
for { for {
s := strings.ToLower(GetRandomLetters(RandomSlugLength)) s := GetRandomAlphanumeric(RandomSlugLength)
if !exists(s) { if !exists(s) {
return s return s
} }
+2 -2
View File
@@ -4,8 +4,8 @@ redis:
passwd: "Redis@fish2026!" passwd: "Redis@fish2026!"
subscribe: true subscribe: true
mongodb: mongodb:
addr: "mongodb://admin:3NjreBBLVOkptSWbV%21@172.104.56.78:47018,172.104.56.119:47018,172.104.56.146:47018/web_huangguo2?replicaSet=web_jiqun3&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2" addr: "mongodb://web_huangguo2:xDdEkf6m0HDpkEpxpphi@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/web_huangguo2?replicaSet=fish0&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
logaddr: "mongodb://admin:3NjreBBLVOkptSWbV%21@172.104.56.78:47018,172.104.56.119:47018,172.104.56.146:47018/web_huangguo2_log?replicaSet=web_jiqun3&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2" logaddr: "mongodb://web_huangguo2:xDdEkf6m0HDpkEpxpphi@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/web_huangguo2_log?replicaSet=fish0&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
es: es:
addr: "http://139.162.47.194:9200" addr: "http://139.162.47.194:9200"
user: "elastic" user: "elastic"