fix: 添加分类名称唯一约束,防止重复名称

This commit is contained in:
2026-05-25 17:38:11 +08:00
parent 4b03e593bc
commit 2cb86d1b38
6 changed files with 249 additions and 47 deletions
+2 -25
View File
@@ -1,8 +1,6 @@
package routes
import (
"net/http"
"sale/internal/api/handlers"
"sale/internal/api/middlewares"
@@ -28,6 +26,8 @@ func SetupRoutes(r *gin.Engine) {
r.Use(middlewares.CORSMiddleware())
r.Static("/uploads", "./uploads")
api := r.Group("/api")
{
api.GET("/installed", authHandler.CheckInstalled)
@@ -46,8 +46,6 @@ func SetupRoutes(r *gin.Engine) {
{
articles.GET("", articleHandler.List)
articles.GET("/:id", articleHandler.GetByID)
// 采集 API(管理员权限)
articles.POST("/crawl-ribenyan", articleHandler.CrawlRibenyan)
}
api.GET("/banners", bannerHandler.List)
@@ -217,25 +215,4 @@ func SetupRoutes(r *gin.Engine) {
}
}
}
// Serve uploads
r.Static("/uploads", "./uploads")
// Serve frontend static assets (CSS, JS, images, etc.)
r.StaticFS("/assets", http.Dir("./static/assets"))
// SPA fallback - serve index.html for all other routes (Vue Router History Mode)
// This must be the last route to catch all unmatched paths
r.NoRoute(func(c *gin.Context) {
path := c.Request.URL.Path
// For root and SPA routes, serve index.html
// API requests will return 404 if not found
if path == "/" || path == "/favicon.ico" || path == "/icons.svg" || path == "/favicon.svg" ||
len(path) > 4 && path[:4] != "/api/" {
c.File("/app/static/index.html")
} else {
// API routes - let them return 404 if not found
c.AbortWithStatus(404)
}
})
}