fix
This commit is contained in:
@@ -1,2 +1,13 @@
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user