This commit is contained in:
2026-03-10 17:49:53 +08:00
parent bf4c114ee2
commit 6b80182986
4 changed files with 2088 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"os"
"sort"
"time"
@@ -38,8 +39,16 @@ func NewGinRouter(cfg *config.Config, logger *zap.Logger) *GinRouter {
engine := gin.New()
// 加载HTML模板企业报告等页面
// 这里直接加载项目根目录下的 qiye.html后续如有更多模板可改为 LoadHTMLGlob
engine.LoadHTMLFiles("qiye.html")
// 为避免生产环境文件不存在导致panic这里先检查文件是否存在
const reportTemplatePath = "resources/qiye.html"
if _, err := os.Stat(reportTemplatePath); err == nil {
engine.LoadHTMLFiles(reportTemplatePath)
logger.Info("已加载企业报告模板文件", zap.String("template", reportTemplatePath))
} else {
logger.Warn("未找到企业报告模板文件,将跳过模板加载(请确认部署时包含 resources/qiye.html",
zap.String("template", reportTemplatePath),
zap.Error(err))
}
return &GinRouter{
engine: engine,