29 lines
895 B
Go
29 lines
895 B
Go
|
package svc
|
||
|
|
||
|
import (
|
||
|
"github.com/zeromicro/go-zero/rest"
|
||
|
"github.com/zeromicro/go-zero/zrpc"
|
||
|
"tianyuan-api/apps/admin/internal/config"
|
||
|
"tianyuan-api/apps/admin/internal/middleware"
|
||
|
"tianyuan-api/apps/sentinel/sentinel"
|
||
|
"tianyuan-api/apps/user/user"
|
||
|
)
|
||
|
|
||
|
type ServiceContext struct {
|
||
|
Config config.Config
|
||
|
AuthInterceptor rest.Middleware
|
||
|
EntRpc user.EnterpriseClient
|
||
|
UserRpc user.UserClient
|
||
|
ProductRpc sentinel.ProductClient
|
||
|
}
|
||
|
|
||
|
func NewServiceContext(c config.Config) *ServiceContext {
|
||
|
return &ServiceContext{
|
||
|
Config: c,
|
||
|
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
|
||
|
EntRpc: user.NewEnterpriseClient(zrpc.MustNewClient(c.UserRpc).Conn()),
|
||
|
UserRpc: user.NewUserClient(zrpc.MustNewClient(c.UserRpc).Conn()),
|
||
|
ProductRpc: sentinel.NewProductClient(zrpc.MustNewClient(c.SentinelRpc).Conn()),
|
||
|
}
|
||
|
}
|