f
This commit is contained in:
@@ -97,38 +97,8 @@ func ProcessPDFG01GZRequest(ctx context.Context, params []byte, deps *processors
|
|||||||
// 计算缓存键(内部使用,不直接暴露给用户)
|
// 计算缓存键(内部使用,不直接暴露给用户)
|
||||||
cacheKey := cacheManager.GetCacheKey(paramsDto.Name, paramsDto.IDCard)
|
cacheKey := cacheManager.GetCacheKey(paramsDto.Name, paramsDto.IDCard)
|
||||||
|
|
||||||
// 检查缓存(基于姓名+身份证)
|
// 直接生成PDF,不检查缓存(每次都重新生成)
|
||||||
_, hit, createdAt, err := cacheManager.Get(paramsDto.Name, paramsDto.IDCard)
|
zapLogger.Info("开始生成PDF",
|
||||||
if err != nil {
|
|
||||||
zapLogger.Warn("检查缓存失败,继续生成PDF", zap.Error(err))
|
|
||||||
} else if hit {
|
|
||||||
// 生成对外可见的报告ID(包含随机前缀,防止用户直接推断缓存键)
|
|
||||||
reportID := generateReportID(cacheKey)
|
|
||||||
|
|
||||||
// 缓存命中,模拟生成耗时(约4秒)
|
|
||||||
zapLogger.Info("PDF缓存命中,返回缓存文件",
|
|
||||||
zap.String("name", paramsDto.Name),
|
|
||||||
zap.String("id_card", paramsDto.IDCard),
|
|
||||||
zap.String("report_id", reportID),
|
|
||||||
zap.Time("created_at", createdAt),
|
|
||||||
)
|
|
||||||
// 模拟生成耗时
|
|
||||||
time.Sleep(4 * time.Second)
|
|
||||||
|
|
||||||
// 生成下载链接(基于报告ID)
|
|
||||||
downloadURL := generateDownloadURL(apiDomain, reportID)
|
|
||||||
expiresAt := createdAt.Add(cacheTTL)
|
|
||||||
return json.Marshal(map[string]interface{}{
|
|
||||||
"download_url": downloadURL,
|
|
||||||
"report_id": reportID,
|
|
||||||
"created_at": createdAt.Format(time.RFC3339),
|
|
||||||
"expires_at": expiresAt.Format(time.RFC3339),
|
|
||||||
"ttl_seconds": int(cacheTTL.Seconds()),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 缓存未命中,需要生成PDF
|
|
||||||
zapLogger.Info("PDF缓存未命中,开始生成PDF",
|
|
||||||
zap.String("name", paramsDto.Name),
|
zap.String("name", paramsDto.Name),
|
||||||
zap.String("id_card", paramsDto.IDCard),
|
zap.String("id_card", paramsDto.IDCard),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user