添加购物车查询商品主图片

master
shenzhuan 2 years ago
parent ad82c2e061
commit 094936ba93

@ -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 " +

@ -80,13 +80,17 @@ func main() {
}
//
respDetail, err := clientA.ShowProductDetail(context.TODO(), reqDetail)
if respDetail != nil {
req.ProductName = respDetail.ProductDetail[0].Name
req.ProductMainPicture = respDetail.ProductDetail[0].MainPicture
log.Println(" /ProductDetailReq get :", req)
}
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())

@ -36,6 +36,7 @@ func (u *CartRepository) AddCart(req *proto.AddCartReq) (obj *model.ShoppingCart
ProductId: req.ProductId,
ProductSkuId: req.ProductSkuId,
ProductName: req.ProductName,
ProductMainPicture: req.ProductMainPicture,
}
cart.CreateTime = time.Now() //
u.mysqlDB.Create(&cart)

Loading…
Cancel
Save