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
-13
View File
@@ -5,7 +5,6 @@ import (
"net/http"
"strconv"
"sale/internal/crawler"
"sale/internal/models"
"sale/internal/schemas"
"sale/internal/utils"
@@ -164,15 +163,3 @@ func (h *ArticleHandler) TogglePin(c *gin.Context) {
utils.DB.First(&article, id)
c.JSON(http.StatusOK, gin.H{"data": article})
}
// CrawlRibenyan 采集 ribenyan.com 文章
func (h *ArticleHandler) CrawlRibenyan(c *gin.Context) {
crawler := crawler.NewRibenyanCrawler(utils.DB)
if err := crawler.CrawlArticles(); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"message": "Crawl completed successfully"})
}