refactor(internal): 优化 OSS 预签名 URL 缓存刷新任务和英雄数据缓存逻辑

- 注释掉 OSS预签名 URL 缓存刷新任务的定时执行代码
- 在 hero/hero.go 中增加对 Redis缓存和英雄数据集的非空校验
- 修改 OSS预签名 URL 生成逻辑,自动替换为 CDN 域名
This commit is contained in:
hu xiaotong
2025-07-17 17:37:13 +08:00
parent 8ab1379cae
commit 9ef6ac9cdb
3 changed files with 64 additions and 6 deletions

View File

@@ -103,6 +103,37 @@ func (t *ThirdPartyDataSync) fetchHeroDataFromAPI(ctx context.Context) ([]byte,
return content, nil
}
// fetchHeroBuildsFromAPI 通过角色英文名POST请求获取配装数据
func (t *ThirdPartyDataSync) FetchHeroBuildsFromAPI(ctx context.Context, heroName string) (string, error) {
apiURL := consts.HeroNameURL
headers := map[string]string{
"User-Agent": "EpicGameBot/1.0",
"Accept": "application/json",
"Content-Type": "application/json",
}
// 直接将角色名作为body
//bodyBytes := []byte(heroName)
heroNameEN := i18n.Zh2En(heroName)
fmt.Println(heroNameEN)
resp, err := t.client.Header(headers).Post(ctx, apiURL, "Argent Waves Hwayoung")
if err != nil {
return "", fmt.Errorf("API请求失败: %v", err)
}
defer resp.Close()
if resp.StatusCode != 200 {
return "", fmt.Errorf("API响应错误状态码: %d", resp.StatusCode)
}
content := resp.ReadAll()
g.Log().Debug(ctx, "配装API响应内容长度:", len(content))
return string(content), nil
}
// 从API获取神器数据
func (t *ThirdPartyDataSync) fetchArtifactDataFromAPI(ctx context.Context) (string, error) {
// 示例API地址