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

35 lines
880 B
Go
Executable File

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