新增获取收藏列表接口
This commit is contained in:
@@ -35,3 +35,18 @@ func (c *FsProductCollectionModel) Delete2(ctx context.Context, userId, guestId,
|
||||
Where("user_id = ? and guest_id = ? and id = ?", userId, guestId, id).
|
||||
Delete(&FsProductCollection{}).Error
|
||||
}
|
||||
|
||||
// 获取列表
|
||||
func (c *FsProductCollectionModel) GetList(ctx context.Context, userId, guestId int64, page, limit int, sort string) (resp []FsProductCollection, total int64, err error) {
|
||||
db := c.db.WithContext(ctx).Model(&FsProductCollection{}).
|
||||
Where("user_id = ? and guest_id = ?", userId, guestId)
|
||||
if sort != "" {
|
||||
db = db.Order(sort)
|
||||
}
|
||||
if err = db.Count(&total).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
offset := (page - 1) * limit
|
||||
err = db.Offset(offset).Limit(limit).Find(&resp).Error
|
||||
return resp, total, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user