f
This commit is contained in:
@@ -160,20 +160,8 @@ func (h *QYGLReportHandler) GetQYGLReportPDFByID(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// 先尝试从缓存中读取(基于报告ID)
|
||||
if h.pdfCacheManager != nil {
|
||||
if cachedBytes, hit, _, err := h.pdfCacheManager.GetByReportID(id); err == nil && hit && len(cachedBytes) > 0 {
|
||||
h.logger.Info("企业全景报告 PDF 缓存命中",
|
||||
zap.String("report_id", id),
|
||||
zap.Int("pdf_size", len(cachedBytes)),
|
||||
)
|
||||
encodedFileName := url.QueryEscape(fileName)
|
||||
c.Header("Content-Type", "application/pdf")
|
||||
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", encodedFileName))
|
||||
c.Data(http.StatusOK, "application/pdf", cachedBytes)
|
||||
return
|
||||
}
|
||||
}
|
||||
// 临时关闭企业全景报告 PDF 的读取缓存,强制每次都重新生成
|
||||
// 如果后续需要恢复缓存,可在此重新启用 pdfCacheManager.GetByReportID 的逻辑。
|
||||
|
||||
// 根据当前请求推断访问协议(支持通过反向代理的 X-Forwarded-Proto)
|
||||
scheme := "http"
|
||||
@@ -205,15 +193,8 @@ func (h *QYGLReportHandler) GetQYGLReportPDFByID(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 将生成结果写入缓存(忽略写入错误,不影响主流程)
|
||||
if h.pdfCacheManager != nil {
|
||||
if err := h.pdfCacheManager.SetByReportID(id, pdfBytes); err != nil {
|
||||
h.logger.Warn("保存企业全景报告 PDF 到缓存失败",
|
||||
zap.String("report_id", id),
|
||||
zap.Error(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
// 临时关闭企业全景报告 PDF 的写入缓存,只返回最新生成的 PDF。
|
||||
// 若后续需要重新启用缓存,可恢复对 pdfCacheManager.SetByReportID 的调用。
|
||||
|
||||
encodedFileName := url.QueryEscape(fileName)
|
||||
c.Header("Content-Type", "application/pdf")
|
||||
|
||||
Reference in New Issue
Block a user