feat: completed development wecom message

This commit is contained in:
zzw
2026-09-18 17:39:48 +08:00
parent dd460f6be2
commit 1ca44d25df
57 changed files with 1754 additions and 1412 deletions
@@ -0,0 +1,32 @@
package utils
import (
"context"
"fmt"
"lone-services/pkg/rpcclient"
"lone-services/pkg/utils"
productpb "lone-services/rpc/product/pb"
)
// GetProductById 通过产品服务 InfoById 获取产品详情
func GetProductById(ctx context.Context, id int) (*productpb.Item, error) {
svcName := utils.GetConfigString("services.product")
if svcName == utils.StringEmpty {
return nil, fmt.Errorf("config services.product empty")
}
cli, err := rpcclient.Get(svcName)
if err != nil {
return nil, err
}
item, err := productpb.NewProductClient(cli.Conn()).InfoById(ctx, &productpb.InfoByIdReq{
Id: int64(id),
})
if err != nil {
return nil, err
}
if item == nil || item.GetId() < 1 {
return nil, fmt.Errorf("product not found: %d", id)
}
return item, nil
}