kra/internal/conf/provider.go

60 lines
1.1 KiB
Go

package conf
import (
"github.com/google/wire"
"go.uber.org/zap"
)
// ProviderSet is conf providers.
var ProviderSet = wire.NewSet(
ProvideServer,
ProvideJWT,
ProvideMysql,
ProvideCaptcha,
ProvideSystem,
ProvideUseStrictAuth,
ProvideZapLogger,
)
// ProvideZapLogger 提供zap日志实例
func ProvideZapLogger() *zap.Logger {
logger, _ := zap.NewProduction()
return logger
}
// ProvideServer 提供Server配置
func ProvideServer(c *Bootstrap) *Server {
return c.Server
}
// ProvideJWT 提供JWT配置
func ProvideJWT(c *Bootstrap) *JWT {
return c.Jwt
}
// ProvideMysql 提供Mysql配置
func ProvideMysql(c *Bootstrap) *Mysql {
return c.Mysql
}
// ProvideCaptcha 提供Captcha配置
func ProvideCaptcha(c *Bootstrap) *Captcha {
return c.Captcha
}
// ProvideSystem 提供System配置
func ProvideSystem(c *Bootstrap) *System {
return c.System
}
// UseStrictAuth 用于wire注入的类型包装
type UseStrictAuth bool
// ProvideUseStrictAuth 提供UseStrictAuth配置
func ProvideUseStrictAuth(c *System) UseStrictAuth {
if c == nil {
return false
}
return UseStrictAuth(c.UseStrictAuth)
}