f
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user