fix
This commit is contained in:
parent
543308ddbc
commit
f09e1b8f93
|
@ -5,3 +5,6 @@ const DEFAULT_PAGE = 1
|
||||||
|
|
||||||
// 默认每页数量
|
// 默认每页数量
|
||||||
const DEFAULT_PAGE_SIZE = 20
|
const DEFAULT_PAGE_SIZE = 20
|
||||||
|
|
||||||
|
// 最大每页显示数量
|
||||||
|
const MAX_PAGE_SIZE = 300
|
||||||
|
|
|
@ -1,2 +1,13 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
// TODO: 使用model的属性做你想做的
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
// TODO: 使用model的属性做你想做的
|
||||||
|
|
||||||
|
func (p *FsCloudPickUpDetailModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsCloudPickUpDetail, err error) {
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = p.db.WithContext(ctx).Model(&FsCloudPickUpDetail{}).Where("`id` in (?)", ids).Find(&resp).Error
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
|
@ -35,3 +35,32 @@ func (p *FsCloudPickUpModel) GetCloudPickUpByIDAndUserID(ctx context.Context, us
|
||||||
|
|
||||||
return cloudOrder, err
|
return cloudOrder, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetPickupListByParamReq struct {
|
||||||
|
UserId *int64
|
||||||
|
Status *int64
|
||||||
|
Ids []int64
|
||||||
|
Page int
|
||||||
|
Limit int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *FsCloudPickUpModel) GetPickupListByParam(ctx context.Context, req GetPickupListByParamReq) (resp []FsCloudPickUp, total int64, err error) {
|
||||||
|
db := p.db.WithContext(ctx).Model(&FsCloudPickUp{})
|
||||||
|
if req.UserId != nil {
|
||||||
|
db = db.Where("`user_id` = ?", *req.UserId)
|
||||||
|
}
|
||||||
|
if req.Status != nil {
|
||||||
|
db = db.Where("`status` = ?", *req.Status)
|
||||||
|
}
|
||||||
|
if len(req.Ids) > 0 {
|
||||||
|
db = db.Where("`id` in (?)", req.Ids)
|
||||||
|
}
|
||||||
|
if err = db.Limit(1).Count(&total).Error; err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
offset := (req.Page - 1) * req.Limit
|
||||||
|
if err = db.Offset(offset).Limit(req.Limit).Order("id desc").Find(&resp).Error; err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (l *GetCloudListLogic) GetCloudList(req *types.GetCloudListReq, userinfo *a
|
||||||
if req.Page <= 0 {
|
if req.Page <= 0 {
|
||||||
req.Page = constants.DEFAULT_PAGE
|
req.Page = constants.DEFAULT_PAGE
|
||||||
}
|
}
|
||||||
if req.PageSize <= 0 || req.PageSize > 200 {
|
if req.PageSize <= 0 || req.PageSize > constants.MAX_PAGE_SIZE {
|
||||||
req.PageSize = constants.DEFAULT_PAGE_SIZE
|
req.PageSize = constants.DEFAULT_PAGE_SIZE
|
||||||
}
|
}
|
||||||
sizeFlag := false
|
sizeFlag := false
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fusenapi/constants"
|
||||||
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
@ -30,6 +32,40 @@ func (l *GetPickupListLogic) GetPickupList(req *types.GetPickupListReq, userinfo
|
||||||
if userinfo.GetIdType() != auth.IDTYPE_User {
|
if userinfo.GetIdType() != auth.IDTYPE_User {
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
||||||
}
|
}
|
||||||
|
if req.Page <= 0 {
|
||||||
|
req.Page = constants.DEFAULT_PAGE
|
||||||
|
}
|
||||||
|
if req.PageSize <= 0 || req.PageSize > constants.MAX_PAGE_SIZE {
|
||||||
|
req.PageSize = constants.DEFAULT_PAGE_SIZE
|
||||||
|
}
|
||||||
|
//获取列表
|
||||||
|
pickListReq := gmodel.GetPickupListByParamReq{
|
||||||
|
UserId: &userinfo.UserId,
|
||||||
|
Page: req.Page,
|
||||||
|
Limit: req.PageSize,
|
||||||
|
}
|
||||||
|
//状态筛选
|
||||||
|
if req.Status != -1 {
|
||||||
|
pickListReq.Status = &req.Status
|
||||||
|
}
|
||||||
|
pickupList, total, err := l.svcCtx.AllModels.FsCloudPickUp.GetPickupListByParam(l.ctx, pickListReq)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get pickup list")
|
||||||
|
}
|
||||||
|
if len(pickupList) == 0 {
|
||||||
|
return resp.SetStatus(basic.CodeOK)
|
||||||
|
}
|
||||||
|
pickupIds := make([]int64, 0, len(pickupList))
|
||||||
|
for _, v := range pickupList {
|
||||||
|
pickupIds = append(pickupIds, v.Id)
|
||||||
|
}
|
||||||
|
//获取详情数据
|
||||||
|
pickupDetailList, err := l.svcCtx.AllModels.FsCloudPickUpDetail.GetAllByIds(l.ctx, pickupIds)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get pickup detail list")
|
||||||
|
}
|
||||||
|
stockIds := make([]int64, 0, len(pickupList))
|
||||||
return resp.SetStatus(basic.CodeOK)
|
return resp.SetStatus(basic.CodeOK)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ type SupplementRsp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetPickupListReq struct {
|
type GetPickupListReq struct {
|
||||||
Status int64 `form:"status,options=0|1|2|3|4"`
|
Status int64 `form:"status,options=-1|1|2|3|4"`
|
||||||
Page int `form:"page"`
|
Page int `form:"page"`
|
||||||
PageSize int `form:"page_size"`
|
PageSize int `form:"page_size"`
|
||||||
Size int `form:"size"`
|
Size int `form:"size"`
|
||||||
|
|
|
@ -80,7 +80,7 @@ type SupplementRsp {
|
||||||
|
|
||||||
//提货列表
|
//提货列表
|
||||||
type GetPickupListReq {
|
type GetPickupListReq {
|
||||||
Status int64 `form:"status,options=0|1|2|3|4"`
|
Status int64 `form:"status,options=-1|1|2|3|4"`
|
||||||
Page int `form:"page"`
|
Page int `form:"page"`
|
||||||
PageSize int `form:"page_size"`
|
PageSize int `form:"page_size"`
|
||||||
Size int `form:"size"`
|
Size int `form:"size"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user