new
This commit is contained in:
@@ -5,8 +5,10 @@ import (
|
||||
"github.com/smartwalle/alipay/v3"
|
||||
"github.com/zeromicro/go-zero/core/stores/redis"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"tianyuan-api/apps/sentinel/internal/config"
|
||||
"tianyuan-api/apps/sentinel/internal/model"
|
||||
"tianyuan-api/apps/user/user"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
@@ -18,6 +20,7 @@ type ServiceContext struct {
|
||||
ProductsModel model.ProductsModel
|
||||
UserProductsModel model.UserProductsModel
|
||||
PayOrderModel model.PayOrderModel
|
||||
WalletRpc user.WalletServiceClient
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
@@ -41,6 +44,8 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("加载支付宝公钥失败: %v", err))
|
||||
}
|
||||
|
||||
walletRpc := user.NewWalletServiceClient(zrpc.MustNewClient(c.UserRpc).Conn())
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
Redis: rds,
|
||||
@@ -50,5 +55,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
ProductsModel: model.NewProductsModel(db, c.CacheRedis),
|
||||
UserProductsModel: model.NewUserProductsModel(rds, db, c.CacheRedis),
|
||||
PayOrderModel: model.NewPayOrderModel(db, c.CacheRedis),
|
||||
WalletRpc: walletRpc,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user