新增获取收藏列表接口

This commit is contained in:
laodaming
2023-10-08 15:29:03 +08:00
parent 8c69e4d2d3
commit ddfe91a42e
6 changed files with 206 additions and 27 deletions

View File

@@ -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
}