cc23c30c9e
CI / changes (push) Successful in 1m34s
CI / ad (push) Successful in 27s
CI / admin (push) Successful in 17s
CI / aiserver (push) Successful in 26s
CI / analysis (push) Successful in 22s
CI / bff (push) Successful in 21s
CI / chore (push) Successful in 20s
CI / equipment (push) Successful in 19s
CI / express (push) Successful in 19s
CI / factory (push) Successful in 19s
CI / message (push) Successful in 18s
CI / order (push) Successful in 19s
CI / payment (push) Successful in 17s
CI / percutaneous (push) Successful in 17s
CI / product (push) Successful in 19s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / store (push) Successful in 20s
CI / support (push) Successful in 19s
CI / task (push) Successful in 21s
CI / user (push) Successful in 22s
CI / water (push) Successful in 25s
CI / wecom (push) Successful in 21s
CI / ws (push) Successful in 9s
43 lines
856 B
Go
43 lines
856 B
Go
package svc
|
|
|
|
import (
|
|
"context"
|
|
product "lone-services/rpc/product/pb"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
func GetProducts(ids []int64, name string) []*product.Item {
|
|
cli, err := GetRpcClient(name)
|
|
if err != nil {
|
|
logx.Error(err)
|
|
return nil
|
|
}
|
|
|
|
client := product.NewProductClient(cli.Conn())
|
|
items, err := client.ItemsByIds(context.Background(), &product.ItemsByIdsReq{Ids: ids})
|
|
if err != nil {
|
|
logx.Errorf("get store err: %v", err)
|
|
return nil
|
|
}
|
|
|
|
return items.Items
|
|
}
|
|
|
|
func GetProduct(id int64, name string) *product.Item {
|
|
cli, err := GetRpcClient(name)
|
|
if err != nil {
|
|
logx.Error(err)
|
|
return nil
|
|
}
|
|
|
|
client := product.NewProductClient(cli.Conn())
|
|
info, err := client.InfoById(context.Background(), &product.InfoByIdReq{Id: id})
|
|
if err != nil {
|
|
logx.Errorf("get store err: %v", err)
|
|
return nil
|
|
}
|
|
|
|
return info
|
|
}
|