transfer_middleware/cmd/rpc/internal/svc/serviceContext.go

46 lines
1.1 KiB
Go
Raw Normal View History

2024-06-07 11:11:04 +08:00
package svc
import (
"github.com/zeromicro/go-zero/core/stores/redis"
"trasfer_middleware/cmd/rpc/internal/config"
"trasfer_middleware/cmd/rpc/internal/logic/po/market"
2024-06-18 16:34:14 +08:00
"trasfer_middleware/cmd/rpc/internal/logic/po/rs"
2024-06-07 11:11:04 +08:00
"trasfer_middleware/cmd/rpc/internal/logic/po/zltx"
)
type ServiceContext struct {
Config config.Config
RedisClient *redis.Redis
ZltxOrder *zltx.ZltxOrder
Market *market.Market
2024-06-18 16:34:14 +08:00
RS *rs.RS
2024-06-07 11:11:04 +08:00
}
func NewServiceContext(c config.Config) *ServiceContext {
2024-06-12 13:46:14 +08:00
2024-06-07 11:11:04 +08:00
return &ServiceContext{
Config: c,
RedisClient: redis.MustNewRedis(redis.RedisConf{
Host: c.Redis.Host,
Type: c.Redis.Type,
Pass: c.Redis.Pass,
}),
ZltxOrder: zltx.NewZltxOrder(c.ZLTX),
Market: market.NewMarket(c.Market),
2024-06-18 16:34:14 +08:00
RS: rs.NewRs(c.RS),
2024-06-07 11:11:04 +08:00
}
}
2024-06-12 13:46:14 +08:00
/*func DbModel(datasource string, c config.Config) *Model {
sqlConn := sqlx.NewMysql(datasource)
2024-06-07 11:11:04 +08:00
return &Model{
2024-06-12 13:46:14 +08:00
MarketLogs: genModel.NewServerMiddleMarketLogsModel(sqlConn, c.Cache),
ZLTXLogs: genModel.NewServerMiddleZltxLogsModel(sqlConn, c.Cache),
2024-06-07 11:11:04 +08:00
}
}
type Model struct {
2024-06-12 13:46:14 +08:00
MarketLogs genModel.ServerMiddleMarketLogsModel
ZLTXLogs genModel.ServerMiddleZltxLogsModel
}*/