package svc import ( "ark-permission/internal/config" "ark-permission/internal/domain/repository" "ark-permission/internal/lib/required" repo "ark-permission/internal/repository" ers "code.30cm.net/wanderland/library-go/errors" "code.30cm.net/wanderland/library-go/errors/code" "github.com/zeromicro/go-zero/core/stores/redis" ) type ServiceContext struct { Config config.Config Validate required.Validate Redis redis.Redis TokenRedisRepo repository.TokenRepository } func NewServiceContext(c config.Config) *ServiceContext { newRedis, err := redis.NewRedis(c.RedisCluster, redis.Cluster()) if err != nil { panic(err) } ers.Scope = code.CloudEPPermission return &ServiceContext{ Config: c, Validate: required.MustValidator(), Redis: *newRedis, TokenRedisRepo: repo.NewTokenRepository(repo.TokenRepositoryParam{ Store: newRedis, }), } }