zwxi 1 gadu atpakaļ
vecāks
revīzija
2f9934c6e8
3 mainītis faili ar 14 papildinājumiem un 44 dzēšanām
  1. 12 41
      controller/public.go
  2. 2 2
      models/tables/banner/query.go
  3. 0 1
      routers/public.go

+ 12 - 41
controller/public.go

@@ -352,7 +352,6 @@ func GetTelAreaList(c *gin.Context) {
 	response.OkData("获取成功", respList, c)
 }
 
-
 // BannerMark banner图埋点
 // @Tags 公共模块
 // @Summary  banner图埋点
@@ -391,7 +390,6 @@ func BannerMark(c *gin.Context) {
 		response.FailMsg("参数有误", "Id错误", c)
 	}
 
-
 	item, err := banner.GetBannerById(req.Id)
 	if err != nil {
 		fmt.Println("GetByUserId:", err.Error())
@@ -440,7 +438,6 @@ func BannerMark(c *gin.Context) {
 	response.Ok("成功", c)
 }
 
-
 // BannerList banner图列表
 // @Tags 公共模块
 // @Summary  banner图列表
@@ -454,11 +451,21 @@ func BannerMark(c *gin.Context) {
 // @Router /banner/list [get]
 func BannerList(c *gin.Context) {
 	isHomepage, _ := strconv.Atoi(c.Query("is_homepage"))
-	cond := " enable=1 "
+	page, _ := strconv.Atoi(c.Query("page"))
+	limit, _ := strconv.Atoi(c.Query("limit"))
+	enable, _ := strconv.Atoi(c.Query("enable"))
+	cond := "  "
+	if enable == 0 {
+		cond = " enable = 0 "
+	} else {
+		cond = " enable = 1 "
+	}
+
 	if isHomepage != 1 {
 		cond = " AND id <> 9999"
 	}
-	list, err := banner.GetBannerList(cond)
+
+	list, err := banner.GetBannerList(cond, page, limit)
 	if err != nil {
 		response.FailMsg("获取失败", "获取banner失败, Err: "+err.Error(), c)
 		return
@@ -466,39 +473,3 @@ func BannerList(c *gin.Context) {
 
 	response.OkData("获取成功", list, c)
 }
-
-// BannerList banner图列表
-// @Tags 公共模块
-// @Summary  banner图列表
-// @Description banner图列表
-// @Security ApiKeyAuth
-// @securityDefinitions.basic BasicAuth
-// @Accept  json
-// @Product json
-// @Success 200 {string} string 获取验证码成功
-// @Failure 400 {string} string 请输入邮箱地址
-// @Router /banner_collection/list [get]
-func BannerCollectionList(c *gin.Context) {
-	cond := " id <> 9999"
-	list, err := banner.GetBannerList(cond)
-	if err != nil {
-		response.FailMsg("获取失败", "获取banner失败, Err: "+err.Error(), c)
-		return
-	}
-	resp := make([]*respond.BannerRespItem,0)
-	nowitem := respond.BannerRespItem{
-		Enable: 1,
-	}
-	historyitem := respond.BannerRespItem{
-		Enable: 0,
-	}
-	for _, v := range list {
-		if v.Enable == 1 {
-			nowitem.List = append(nowitem.List, v)
-		} else {
-			historyitem.List = append(historyitem.List, v)
-		}
-	}
-	resp = append(resp, &nowitem, &historyitem)
-	response.OkData("获取成功", resp, c)
-}

+ 2 - 2
models/tables/banner/query.go

@@ -3,8 +3,8 @@ package banner
 import "hongze/hongze_yb/global"
 
 // GetBannerList
-func GetBannerList(cond string) (list []*Banner, err error) {
-	err = global.DEFAULT_MYSQL.Where(cond).Find(&list).Error
+func GetBannerList(cond string, page, limit int) (list []*Banner, err error) {
+	err = global.DEFAULT_MYSQL.Where(cond).Limit(limit).Offset((page - 1) * limit).Find(&list).Error
 	return
 }
 

+ 0 - 1
routers/public.go

@@ -30,7 +30,6 @@ func initPublic(r *gin.Engine) {
 		rGroup.POST("/view_log/update", controller.UpdateViewLog)
 		rGroup.POST("/banner/mark", controller.BannerMark)
 		rGroup.GET("/banner/list", controller.BannerList)
-		rGroup.GET("/banner_collection/list", controller.BannerCollectionList)
 	}
 
 	rGroup2 := r.Group("api/public")