package handler import ( "context" "fmt" "goproduct/domain/service" "goproduct/proto" ) type CartHandler struct { CartService service.ICartService } // 新增购物车 func (u *CartHandler) AddCart(ctx context.Context, req *proto.AddCartReq, resp *proto.AddCartResp) error { obj, err := u.CartService.AddCart(req) if err != nil { println(" AddCart err :", err) } else { resp.CanSetShoppingCartNumber = int64(obj.Number) resp.ShoppingCartNumber = int64(obj.Number) resp.IsBeyondMaxLimit = false // 查询sku resp.ID = obj.ID //增加新增cart的ID fmt.Println(" AddCart handler >>>>>> ", resp) } return err } //修改购物车 func (u *CartHandler) UpdateCart(ctx context.Context, req *proto.AddCartReq, resp *proto.AddCartResp) error { obj, err := u.CartService.UpdateCart(req) if err != nil { println(" UpdateCart err :", err) } else { resp.CanSetShoppingCartNumber = int64(obj.Number) resp.ShoppingCartNumber = int64(obj.Number) resp.IsBeyondMaxLimit = false // 查询sku resp.ID = obj.ID //增加新增cart的ID fmt.Println(" UpdateCart handler >>>>>> ", resp) } return err }