This commit is contained in:
laodaming 2023-09-20 18:27:32 +08:00
parent 8273ded750
commit b992a052ce
3 changed files with 24 additions and 5 deletions

View File

@ -44,6 +44,22 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
if req.CurrentPage <= 0 { if req.CurrentPage <= 0 {
req.CurrentPage = constants.DEFAULT_PAGE req.CurrentPage = constants.DEFAULT_PAGE
} }
//获取全部购物车id
allCratIds, count, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{
UserId: userinfo.UserId,
Fields: "id",
Sort: "id DESC",
Page: 1,
Limit: 1000,
})
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "system err:failed to get your shopping carts")
}
ids := make([]int64, 0, count)
for _, v := range allCratIds {
ids = append(ids, v.Id)
}
limit := 10 limit := 10
//获取用户购物车列表 //获取用户购物车列表
carts, total, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{ carts, total, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{
@ -206,6 +222,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
CurrentPage: req.CurrentPage, CurrentPage: req.CurrentPage,
PerPage: limit, PerPage: limit,
}, },
AllCartIdArray: ids,
CartList: list, CartList: list,
}) })
} }

View File

@ -35,6 +35,7 @@ type GetCartsReq struct {
type GetCartsRsp struct { type GetCartsRsp struct {
Meta Meta `json:"meta"` //分页信息 Meta Meta `json:"meta"` //分页信息
AllCartIdArray []int64 `json:"all_cartId_array"` //全部购物车id不分页
CartList []CartItem `json:"cart_list"` CartList []CartItem `json:"cart_list"`
} }

View File

@ -53,6 +53,7 @@ type GetCartsReq {
} }
type GetCartsRsp { type GetCartsRsp {
Meta Meta `json:"meta"` //分页信息 Meta Meta `json:"meta"` //分页信息
AllCartIdArray []int64 `json:"all_cartId_array"` //全部购物车id不分页
CartList []CartItem `json:"cart_list"` CartList []CartItem `json:"cart_list"`
} }
type CartItem { type CartItem {