This commit is contained in:
2024-10-15 17:19:23 +08:00
parent 8f903b457f
commit c76451788c
42 changed files with 1600 additions and 237 deletions

View File

@@ -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,
}
}