You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB

2 years ago
package service
import (
2 years ago
"shoppingCart/domain/model"
"shoppingCart/domain/repository"
"shoppingCart/proto"
2 years ago
)
type ICartService interface {
AddCart(*proto.AddCartReq) (obj *model.ShoppingCart, err error)
UpdateCart(*proto.UpdateCartReq) (obj *model.ShoppingCart, err error)
GetOrderTotal(int32List []int32) (obj float32, err error)
2 years ago
}
type CartService struct {
cartRepository repository.ICartRepository
}
func NewCartService(cartRepository repository.ICartRepository) ICartService {
return &CartService{cartRepository: cartRepository}
}
// "number": 0,
//
// "productId": 0,
// "productSkuId": 0
//
// 重写接口方法
func (u *CartService) AddCart(req *proto.AddCartReq) (obj *model.ShoppingCart, err error) {
return u.cartRepository.AddCart(req)
}
func (u *CartService) UpdateCart(req *proto.UpdateCartReq) (obj *model.ShoppingCart, err error) {
return u.cartRepository.UpdateCart(req)
}
func (u *CartService) GetOrderTotal(int32List []int32) (obj float32, err error) {
return u.cartRepository.GetOrderTotal(int32List)
}