fix
This commit is contained in:
@@ -24,22 +24,22 @@ func (s *FsShoppingCartModel) FineOneUserCart(ctx context.Context, id, userId in
|
||||
|
||||
// 创建
|
||||
func (s *FsShoppingCartModel) Create(ctx context.Context, data *FsShoppingCart) error {
|
||||
return s.db.WithContext(ctx).Create(&data).Error
|
||||
return s.db.WithContext(ctx).Model(&FsShoppingCart{}).Create(&data).Error
|
||||
}
|
||||
|
||||
// 删除
|
||||
func (s *FsShoppingCartModel) Delete(ctx context.Context, id, userId int64) error {
|
||||
return s.db.WithContext(ctx).Where("user_id = ? and id = ?", userId, id).Delete(&FsShoppingCart{}).Error
|
||||
return s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("user_id = ? and id = ?", userId, id).Delete(&FsShoppingCart{}).Error
|
||||
}
|
||||
|
||||
// 更新
|
||||
func (s *FsShoppingCartModel) Update(ctx context.Context, id, userId int64, data *FsShoppingCart) error {
|
||||
return s.db.WithContext(ctx).Where("user_id = ? and id = ?", userId, id).Updates(&data).Error
|
||||
return s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("user_id = ? and id = ?", userId, id).Updates(&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
|
||||
err = s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("user_id = ?", userId).Limit(1).Count(&total).Error
|
||||
return total, err
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s *FsShoppingCartModel) GetAllByIds(ctx context.Context, ids []int64, sort
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
db := s.db.WithContext(ctx).Where("id in (?)", ids)
|
||||
db := s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("id in (?)", ids)
|
||||
if len(fields) > 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
@@ -70,7 +70,7 @@ type GetAllCartsByParamReq struct {
|
||||
}
|
||||
|
||||
func (s *FsShoppingCartModel) GetAllCartsByParam(ctx context.Context, req GetAllCartsByParamReq) (resp []FsShoppingCart, total int64, err error) {
|
||||
db := s.db.WithContext(ctx)
|
||||
db := s.db.WithContext(ctx).Model(&FsShoppingCart{})
|
||||
if req.UserId > 0 {
|
||||
db = db.Where("user_id = ?", req.UserId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user