This commit is contained in:
solosw
2026-01-05 14:11:34 +08:00
parent 35ef825371
commit 99b11b04e4
658 changed files with 99266 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package handlers
import (
"awesomeProject/internal/common"
"awesomeProject/internal/models"
"net/http"
"github.com/gin-gonic/gin"
)
// UserBannerHandler 用户端轮播图处理器
type UserBannerHandler struct{}
// GetActiveBanners 获取启用的轮播图列表
func (h *UserBannerHandler) GetActiveBanners(c *gin.Context) {
var banners []models.Banner
// 查询启用的轮播图,按排序顺序排列
err := common.GetDB().Where("status = ?", 1).Order("sort_order ASC, created_at DESC").Find(&banners).Error
if err != nil {
c.JSON(http.StatusOK, common.Error(500, "查询轮播图失败"))
return
}
c.JSON(http.StatusOK, common.Success(banners))
}