diff --git a/product-service/domain/repository/product_repository.go b/product-service/domain/repository/product_repository.go index 13e6810..bc71043 100644 --- a/product-service/domain/repository/product_repository.go +++ b/product-service/domain/repository/product_repository.go @@ -51,7 +51,7 @@ func (u *ProductRepository) Page(length int32, pageIndex int32) (coun int64, pro } func (u *ProductRepository) ShowProductDetail(id int32) (product *model.ProductDetail, err error) { - sql := "select p.`id` , p.`name`, p.product_type,p.category_id ,p.starting_price,\n " + + sql := "select p.`id` , p.`name`, p.product_type,p.category_id ,p.starting_price, p.main_picture,\n " + " pd.detail as detail ,GROUP_CONCAT(pp.picture SEPARATOR ',') as picture_list\n" + "FROM `product` p\n" + " left join product_detail pd on p.id = pd.product_id\n " + diff --git a/shoppingCart-service/client/client.go b/shoppingCart-service/client/client.go index 32e0a33..1cc4c4f 100644 --- a/shoppingCart-service/client/client.go +++ b/shoppingCart-service/client/client.go @@ -80,13 +80,17 @@ func main() { } // respDetail, err := clientA.ShowProductDetail(context.TODO(), reqDetail) - req.ProductName = respDetail.ProductDetail[0].Name - req.ProductMainPicture = respDetail.ProductDetail[0].MainPicture - log.Println(" /ProductDetailReq get :", req) + if respDetail != nil { + req.ProductName = respDetail.ProductDetail[0].Name + req.ProductMainPicture = respDetail.ProductDetail[0].MainPicture + } + + log.Println(" /ShowProductDetail resp :", respDetail) //SKU //添加购物车 远程调用服务 + log.Println(" /AddCart req :", req) resp, err := client.AddCart(context.TODO(), req) - log.Println(" /increase :", resp) + log.Println(" /AddCart resp :", resp) //根据响应做输出 if err != nil { log.Println(err.Error()) diff --git a/shoppingCart-service/domain/repository/cart_repository.go b/shoppingCart-service/domain/repository/cart_repository.go index 89a82fa..1a48476 100644 --- a/shoppingCart-service/domain/repository/cart_repository.go +++ b/shoppingCart-service/domain/repository/cart_repository.go @@ -32,10 +32,11 @@ type CartRepository struct { func (u *CartRepository) AddCart(req *proto.AddCartReq) (obj *model.ShoppingCart, err error) { cart := model.ShoppingCart{ - Number: req.Number, - ProductId: req.ProductId, - ProductSkuId: req.ProductSkuId, - ProductName: req.ProductName, + Number: req.Number, + ProductId: req.ProductId, + ProductSkuId: req.ProductSkuId, + ProductName: req.ProductName, + ProductMainPicture: req.ProductMainPicture, } cart.CreateTime = time.Now() // u.mysqlDB.Create(&cart)