feat: move marketing admin to /api/admin and remove built-in page
This commit is contained in:
@@ -2,8 +2,6 @@ package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
@@ -22,29 +20,6 @@ import (
|
||||
smokehandler "wx_service/internal/smoke/handler"
|
||||
)
|
||||
|
||||
func resolveMarketingPage() string {
|
||||
candidates := []string{
|
||||
filepath.Join("web", "marketing", "index.html"),
|
||||
filepath.Join("..", "web", "marketing", "index.html"),
|
||||
}
|
||||
|
||||
if executable, err := os.Executable(); err == nil {
|
||||
exeDir := filepath.Dir(executable)
|
||||
candidates = append(candidates,
|
||||
filepath.Join(exeDir, "web", "marketing", "index.html"),
|
||||
filepath.Join(exeDir, "..", "web", "marketing", "index.html"),
|
||||
)
|
||||
}
|
||||
|
||||
for _, path := range candidates {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
return filepath.Join("web", "marketing", "index.html")
|
||||
}
|
||||
|
||||
func Register(
|
||||
router *gin.Engine,
|
||||
db *gorm.DB,
|
||||
@@ -93,7 +68,7 @@ func Register(
|
||||
registerMarketingRoutes(api, protected, adminToken, marketingCategoryHandler, marketingTemplateHandler, marketingDownloadHandler)
|
||||
}
|
||||
|
||||
registerAdminRoutes(router, adminHandler)
|
||||
registerAdminRoutes(router, adminHandler, marketingCategoryHandler, marketingTemplateHandler, marketingDownloadHandler)
|
||||
|
||||
// 保质期提醒模块使用独立前缀 /api/expiry,与现有 /api/v1 并存。
|
||||
expiryAPI := router.Group("/api/expiry")
|
||||
@@ -108,11 +83,6 @@ func Register(
|
||||
}
|
||||
}
|
||||
|
||||
// Web 管理后台静态文件
|
||||
marketingPage := resolveMarketingPage()
|
||||
router.StaticFile("/admin/marketing", marketingPage)
|
||||
router.StaticFile("/admin/marketing/", marketingPage)
|
||||
|
||||
// 健康检查:用于容器/负载均衡探活
|
||||
router.GET("/healthz", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"status": "ok"})
|
||||
|
||||
Reference in New Issue
Block a user