Merge branch 'feat-cjy-tag' into dev

This commit is contained in:
cjy 2026-01-12 16:49:23 +08:00
commit cf6a932dbb

View File

@ -10,6 +10,7 @@ import (
"fonchain-fiee/pkg/model/login"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/utils"
"math/rand"
"path/filepath"
"strings"
"time"
@ -212,10 +213,22 @@ func GetValidProfileKey(ctx context.Context, platformIDs []uint32) (string, erro
if len(profileKeys.Data) == 0 {
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为空")
}
// 从有效的 profileKey 中随机选择一个
randIndex := rand.Intn(len(validProfileKeys))
return validProfileKeys[randIndex], nil
}
// SaveTagsToDatabase 将标签保存到数据库