1、新增自定义用户私人价格2、优化api服务鉴权缓存3、新增管理员端对公充值

This commit is contained in:
2024-10-21 16:01:20 +08:00
parent 8896fd6b30
commit 2292d25d74
37 changed files with 1903 additions and 907 deletions

View File

@@ -23,6 +23,7 @@ type ServiceContext struct {
UserConfigModel model.UserConfigModel
SecretRpc sentinel.SecretClient
ProductRpc sentinel.ProductClient
UserProductRpc sentinel.UserProductClient
}
func NewServiceContext(c config.Config) *ServiceContext {
@@ -35,7 +36,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
// 初始化 SecretRpc 和 ProductRpc
var secretRpc sentinel.SecretClient
var productRpc sentinel.ProductClient
var userProductRpc sentinel.UserProductClient
// 捕获RPC初始化时的错误但不影响服务启动
secretClient, err := zrpc.NewClient(c.SentinelRpc)
if err != nil {
@@ -49,6 +50,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
logx.Errorf("Failed to connect to ProductRpc: %v", err)
} else {
productRpc = sentinel.NewProductClient(productClient.Conn())
userProductRpc = sentinel.NewUserProductClient(productClient.Conn())
}
// 使用 MustNewRedis 来初始化 Redis 客户端
@@ -66,5 +68,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
RechargeModel: model.NewRechargeModel(db, c.CacheRedis),
SecretRpc: secretRpc, // 捕获连接错误后,继续运行
ProductRpc: productRpc, // 捕获连接错误后,继续运行
UserProductRpc: userProductRpc,
}
}