新增添加购物车接口
This commit is contained in:
@@ -2,12 +2,6 @@ package gmodel
|
||||
|
||||
import "context"
|
||||
|
||||
// 获取用户购物车数量
|
||||
func (s *FsShoppingCartModel) CountUserCart(ctx context.Context, userId int64) (total int64, err error) {
|
||||
err = s.db.WithContext(ctx).Where("user_id = ?", userId).Limit(1).Count(&total).Error
|
||||
return total, err
|
||||
}
|
||||
|
||||
// 获取单个
|
||||
func (s *FsShoppingCartModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsShoppingCart, err error) {
|
||||
db := s.db.WithContext(ctx).Where("id = ?", id)
|
||||
@@ -18,6 +12,17 @@ func (s *FsShoppingCartModel) FindOne(ctx context.Context, id int64, fields ...s
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// 创建
|
||||
func (s *FsShoppingCartModel) Create(ctx context.Context, data *FsShoppingCart) error {
|
||||
return s.db.WithContext(ctx).Create(&data).Error
|
||||
}
|
||||
|
||||
// 获取用户购物车数量
|
||||
func (s *FsShoppingCartModel) CountUserCart(ctx context.Context, userId int64) (total int64, err error) {
|
||||
err = s.db.WithContext(ctx).Where("user_id = ?", userId).Limit(1).Count(&total).Error
|
||||
return total, err
|
||||
}
|
||||
|
||||
// 获取多个
|
||||
func (s *FsShoppingCartModel) GetAllByIds(ctx context.Context, ids []int64, sort string, fields ...string) (resp []FsShoppingCart, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user