fix
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"gorm.io/gorm"
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
@@ -44,13 +45,14 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", demo)
|
||||
}
|
||||
if req.Page <= 0 {
|
||||
req.Page = 1
|
||||
if req.Page <= 0 && req.Page > 10000 {
|
||||
req.Page = constants.DEFAULT_PAGE
|
||||
}
|
||||
//获取合适尺寸
|
||||
if req.Size > 0 {
|
||||
req.Size = image.GetCurrentSize(req.Size)
|
||||
}
|
||||
pageSize := constants.DEFAULT_PAGE_SIZE
|
||||
//查询用户信息(不用判断存在)
|
||||
userModel := gmodel.NewFsUserModel(l.svcCtx.MysqlConn)
|
||||
user, err := userModel.FindUserById(l.ctx, userinfo.UserId)
|
||||
@@ -60,7 +62,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
|
||||
}
|
||||
//查询符合的产品列表
|
||||
productModel := gmodel.NewFsProductModel(l.svcCtx.MysqlConn)
|
||||
productList, err := productModel.GetProductListByTypeIds(l.ctx, []int64{req.Cid}, "sort-desc")
|
||||
productList, total, err := productModel.GetProductListByTypeIds(l.ctx, []int64{req.Cid}, int(req.Page), pageSize, "sort-desc")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product list")
|
||||
@@ -172,6 +174,14 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetProductListRsp{
|
||||
Ob: types.Ob{
|
||||
Items: itemList,
|
||||
}, TypeName: *tagInfo.Title, Description: *tagInfo.Description,
|
||||
Meta: types.Meta{
|
||||
TotalCount: total,
|
||||
PageCount: int64(math.Ceil(float64(total) / float64(pageSize))),
|
||||
CurrentPage: int(req.Page),
|
||||
PerPage: pageSize,
|
||||
},
|
||||
},
|
||||
TypeName: *tagInfo.Title,
|
||||
Description: *tagInfo.Description,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user