transfer_rs/cmd/api/internal/svc/serviceContext.go

35 lines
880 B
Go
Raw Normal View History

2024-06-18 18:14:57 +08:00
package svc
import (
"github.com/zeromicro/go-zero/core/stores/sqlx"
2024-06-19 18:05:50 +08:00
"github.com/zeromicro/go-zero/rest"
2024-06-18 18:14:57 +08:00
"rs/cmd/api/internal/config"
2024-06-19 18:05:50 +08:00
"rs/cmd/api/internal/types"
2024-06-18 18:14:57 +08:00
"rs/genModel"
)
type ServiceContext struct {
2024-06-19 18:05:50 +08:00
*types.BaseServiceContext
DecryptMiddleware rest.Middleware
2024-06-18 18:14:57 +08:00
}
func NewServiceContext(c config.Config) *ServiceContext {
2024-06-19 18:05:50 +08:00
//conn := zrpc.MustNewClient(zrpc.RpcClientConf{
// Target: c.Nacos.Target,
//})
2024-06-18 18:14:57 +08:00
sqlConn := sqlx.NewMysql(c.DB.Coupon.DataSource)
2024-06-19 18:05:50 +08:00
//client := transferClient.NewTransfer(conn)
base := types.BaseServiceContext{
Config: c,
//TransferRpc: client,
2024-06-18 18:14:57 +08:00
ProductRedirectConf: genModel.NewProductRedirectConfModel(sqlConn, c.Cache),
2024-06-19 18:05:50 +08:00
Merchant: genModel.NewMerchantModel(sqlConn, c.Cache),
2024-06-18 18:14:57 +08:00
}
2024-06-19 18:05:50 +08:00
return &ServiceContext{
BaseServiceContext: &base,
//DecryptMiddleware: middleware.NewDecryptMiddleware(&base).Handle,
}
2024-06-18 18:14:57 +08:00
}