fusenapi/server/inventory/internal/logic/getpickuplistlogic.go

72 lines
1.9 KiB
Go
Raw Normal View History

2023-06-29 03:15:42 +00:00
package logic
import (
2023-06-29 05:59:55 +00:00
"fusenapi/constants"
"fusenapi/model/gmodel"
2023-06-29 03:15:42 +00:00
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/inventory/internal/svc"
"fusenapi/server/inventory/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetPickupListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetPickupListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPickupListLogic {
return &GetPickupListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetPickupListLogic) GetPickupList(req *types.GetPickupListReq, userinfo *auth.UserInfo) (resp *basic.Response) {
2023-06-29 03:46:04 +00:00
if userinfo.GetIdType() != auth.IDTYPE_User {
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
}
2023-06-29 05:59:55 +00:00
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))
2023-06-29 03:15:42 +00:00
return resp.SetStatus(basic.CodeOK)
}