feat(cron): 实现定时任务管理功能

- 新增 cron模块,支持定时任务管理- 实现了任务列表获取、任务添加、任务移除和任务状态获取等接口
- 添加了默认任务,包括数据同步、数据清理、健康检查和缓存刷新等
- 实现了优雅关闭功能,确保在服务停止时正确停止所有任务
- 添加了定时任务相关文档和使用指南
This commit is contained in:
hu xiaotong
2025-06-23 15:19:38 +08:00
parent 89a6cdc001
commit cecb19e497
16 changed files with 1571 additions and 7 deletions

View File

@@ -208,9 +208,9 @@ func (l *Logic) GetHeroDetailByCode(ctx context.Context, code string) (*v1.HeroD
for setsName, cnt := range setsNameCount {
percent := 0.0
if total > 0 {
percent = float64(cnt) * 100.0 / float64(total)
percent = float64(cnt) * 100.0 / float64(total) / 100.0 // 得到 0.156 而不是 15.6
}
percent = math.Round(percent*10) / 10 // 保留位小数
percent = math.Round(percent*1000) / 1000 // 保留位小数
percentVOList = append(percentVOList, percentVO{
SetName: setsName,
Percent: percent,
@@ -244,9 +244,9 @@ func (l *Logic) GetHeroDetailByCode(ctx context.Context, code string) (*v1.HeroD
for code, cnt := range artifactCount {
percent := 0.0
if totalArtifact > 0 {
percent = float64(cnt) * 100.0 / float64(totalArtifact)
percent = float64(cnt) * 100.0 / float64(total) / 100.0 // 得到 0.156 而不是 15.6
}
percent = math.Round(percent*10) / 10
percent = math.Round(percent*1000) / 1000 // 保留三位小数
artifactPercentVOList = append(artifactPercentVOList, artifactPercentVO{
ArtifactCode: code,
Percent: percent,