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.

44 lines
1.1 KiB

2 years ago
package handler
import (
"context"
"fmt"
"goproduct/domain/service"
"goproduct/proto"
)
type CartHandler struct {
CartService service.ICartService
}
// 新增购物车
2 years ago
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)
2 years ago
}
return err
2 years ago
}