This commit is contained in:
2026-01-29 15:35:25 +08:00
parent 360fed3907
commit 167dd63a7a

View File

@@ -102,15 +102,15 @@ func ProcessPDFG01GZRequest(ctx context.Context, params []byte, deps *processors
// 计算缓存键作为报告ID可持久化 // 计算缓存键作为报告ID可持久化
reportID := cacheManager.GetCacheKey(paramsDto.Name, paramsDto.IDCard) reportID := cacheManager.GetCacheKey(paramsDto.Name, paramsDto.IDCard)
// 缓存命中,模拟慢几秒 // 缓存命中,模拟生成耗时约4秒
zapLogger.Info("PDF缓存命中返回缓存文件", zapLogger.Info("PDF缓存命中返回缓存文件",
zap.String("name", paramsDto.Name), zap.String("name", paramsDto.Name),
zap.String("id_card", paramsDto.IDCard), zap.String("id_card", paramsDto.IDCard),
zap.String("report_id", reportID), zap.String("report_id", reportID),
zap.Time("created_at", createdAt), zap.Time("created_at", createdAt),
) )
// 模拟慢几秒2-4秒 // 模拟生成耗时
time.Sleep(2 * time.Second) time.Sleep(4 * time.Second)
// 生成下载链接基于报告ID // 生成下载链接基于报告ID
downloadURL := generateDownloadURL(apiDomain, reportID) downloadURL := generateDownloadURL(apiDomain, reportID)
@@ -118,7 +118,6 @@ func ProcessPDFG01GZRequest(ctx context.Context, params []byte, deps *processors
return json.Marshal(map[string]interface{}{ return json.Marshal(map[string]interface{}{
"download_url": downloadURL, "download_url": downloadURL,
"report_id": reportID, "report_id": reportID,
"cached": true,
"created_at": createdAt.Format(time.RFC3339), "created_at": createdAt.Format(time.RFC3339),
"expires_at": expiresAt.Format(time.RFC3339), "expires_at": expiresAt.Format(time.RFC3339),
"ttl_seconds": int(cacheTTL.Seconds()), "ttl_seconds": int(cacheTTL.Seconds()),
@@ -206,7 +205,6 @@ func ProcessPDFG01GZRequest(ctx context.Context, params []byte, deps *processors
"download_url": downloadURL, "download_url": downloadURL,
"report_id": reportID, "report_id": reportID,
"report_number": reportNumber, "report_number": reportNumber,
"cached": false,
"expires_at": expiresAt.Format(time.RFC3339), "expires_at": expiresAt.Format(time.RFC3339),
"ttl_seconds": int(cacheTTL.Seconds()), "ttl_seconds": int(cacheTTL.Seconds()),
}) })