package service import ( "goproduct/domain/model" "goproduct/domain/repository" "goproduct/proto" ) type ICartService interface { AddCart(*proto.AddCartReq) (obj *model.ShoppingCart, err error) UpdateCart(*proto.AddCartReq) (obj *model.ShoppingCart, err error) } 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.AddCartReq) (obj *model.ShoppingCart, err error) { return u.cartRepository.UpdateCart(req) }