修复产品修改、删除
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/smartwalle/alipay/v3"
|
||||
"github.com/zeromicro/go-zero/core/stores/redis"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"tianyuan-api/apps/sentinel/internal/config"
|
||||
@@ -10,10 +12,12 @@ import (
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
Redis *redis.Redis
|
||||
AlipayClient *alipay.Client
|
||||
WhitelistModel model.WhitelistModel
|
||||
SecretsModel model.SecretsModel
|
||||
ProductsModel model.ProductsModel
|
||||
UserProductsModel model.UserProductsModel
|
||||
PayOrderModel model.PayOrderModel
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
@@ -25,12 +29,26 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
}
|
||||
// 使用 MustNewRedis 来初始化 Redis 客户端
|
||||
rds := redis.MustNewRedis(redisConf)
|
||||
|
||||
// 创建支付宝客户端
|
||||
client, err := alipay.New(c.Alipay.AppID, c.Alipay.PrivateKey, c.Alipay.IsProduction)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("创建支付宝客户端失败: %v", err))
|
||||
}
|
||||
|
||||
// 加载支付宝公钥
|
||||
err = client.LoadAliPayPublicKey(c.Alipay.AlipayPublicKey)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("加载支付宝公钥失败: %v", err))
|
||||
}
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
Redis: rds,
|
||||
AlipayClient: client,
|
||||
WhitelistModel: model.NewWhitelistModel(rds, db, c.CacheRedis),
|
||||
SecretsModel: model.NewSecretsModel(db, c.CacheRedis),
|
||||
ProductsModel: model.NewProductsModel(db, c.CacheRedis),
|
||||
UserProductsModel: model.NewUserProductsModel(rds, db, c.CacheRedis),
|
||||
PayOrderModel: model.NewPayOrderModel(db, c.CacheRedis),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user