Merge branch 'feat-cjy-tag' into dev
This commit is contained in:
commit
cf6a932dbb
@ -10,6 +10,7 @@ import (
|
|||||||
"fonchain-fiee/pkg/model/login"
|
"fonchain-fiee/pkg/model/login"
|
||||||
"fonchain-fiee/pkg/service"
|
"fonchain-fiee/pkg/service"
|
||||||
"fonchain-fiee/pkg/utils"
|
"fonchain-fiee/pkg/utils"
|
||||||
|
"math/rand"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -212,12 +213,24 @@ func GetValidProfileKey(ctx context.Context, platformIDs []uint32) (string, erro
|
|||||||
if len(profileKeys.Data) == 0 {
|
if len(profileKeys.Data) == 0 {
|
||||||
return "", errors.New("当前没有有效的profileKey")
|
return "", errors.New("当前没有有效的profileKey")
|
||||||
}
|
}
|
||||||
if profileKeys.Data[0].ProfileKey != "" {
|
|
||||||
return profileKeys.Data[0].ProfileKey, nil
|
// 过滤出所有非空的 profileKey
|
||||||
|
validProfileKeys := make([]string, 0)
|
||||||
|
for _, item := range profileKeys.Data {
|
||||||
|
if item.ProfileKey != "" {
|
||||||
|
validProfileKeys = append(validProfileKeys, item.ProfileKey)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(validProfileKeys) == 0 {
|
||||||
return "", errors.New("profileKey为空")
|
return "", errors.New("profileKey为空")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 从有效的 profileKey 中随机选择一个
|
||||||
|
randIndex := rand.Intn(len(validProfileKeys))
|
||||||
|
return validProfileKeys[randIndex], nil
|
||||||
|
}
|
||||||
|
|
||||||
// SaveTagsToDatabase 将标签保存到数据库
|
// SaveTagsToDatabase 将标签保存到数据库
|
||||||
func SaveTagsToDatabase(ctx *gin.Context, tags []string, source uint32) error {
|
func SaveTagsToDatabase(ctx *gin.Context, tags []string, source uint32) error {
|
||||||
if len(tags) == 0 {
|
if len(tags) == 0 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user