Documentation ¶
Overview ¶
Package utils @file : p.crypt.go @author : china.gdxs@gmail.com @time : 2024/2/3 16:49 @Description:
Package utils @file : db.log.go @author : china.gdxs@gmail.com @time : 2023/11/9 17:44 @Description:
Package utils @file : p.email.go @author : xs @time : 2024/6/17 13:59 @Description: 邮件警告通知
Package jwt_auth @author: ekin @date: 2022/5/31 @Description: jwt token解析
Package utils @file : p.db.go @author : china.gdxs@gmail.com @time : 2023/11/9 16:18 @Description:
Package utils @file : p.redis.go @author : china.gdxs@gmail.com @time : 2023/11/10 09:08 @Description: redis config
Package utils @file : p.viper.go @author : china.gdxs@gmail.com @time : 2023/11/9 16:11 @Description:
Package utils @file : providers.go @author : china.gdxs@gmail.com @time : 2023/11/9 16:08 @Description: utils
Index ¶
- Variables
- func NewGorm(v *viper.Viper, lg logger.Interface) (db *gorm.DB, fc func(), err error)
- func NewGormLog(v *viper.Viper, l *zap.Logger) (res logger.Interface, err error)
- func NewLog(v *viper.Viper) (l *zap.Logger, fc func(), err error)
- func NewRedis(v *viper.Viper) (rdb *redis.Client, err error)
- func NewViper(path string) (v *viper.Viper, err error)
- func TraceCtx(ctx context.Context) context.Context
- func WithCtx(ctx context.Context, log *zap.Logger) *zap.Logger
- type Crypt
- type GormLog
- func (l *GormLog) Error(ctx context.Context, msg string, data ...any)
- func (l *GormLog) Info(ctx context.Context, msg string, data ...any)
- func (l *GormLog) LogMode(level logger.LogLevel) logger.Interface
- func (l *GormLog) Trace(ctx context.Context, begin time.Time, ...)
- func (l *GormLog) Warn(ctx context.Context, msg string, data ...any)
- func (l *GormLog) WithCtx(ctx context.Context) *zap.Logger
- type GormOpts
- type JwtAuth
- func (a *JwtAuth) CreateTokenWithMapPayload(payloads map[string]interface{}, seconds int64) (string, error)
- func (a *JwtAuth) NeedCheck(path string) bool
- func (a *JwtAuth) SetPath(paths ...string) *JwtAuth
- func (a *JwtAuth) SetPrefix(paths ...string) *JwtAuth
- func (a *JwtAuth) SetSecret(secret string) *JwtAuth
- func (a *JwtAuth) SetWhitelist(paths ...string) *JwtAuth
- func (a *JwtAuth) Verifier(r *http.Request) (jwt.MapClaims, error)
- type JwtOpts
- type Log
- type LogOpts
- type MailEntity
- type RedisOpt
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidToken = errors.New("【jwt_auth】invalid auth token") ErrNoClaims = errors.New("【jwt_auth】no auth params") )
var ProviderSet = wire.NewSet(NewJwtAuth, NewOps)
var ProviderSet = wire.NewSet( NewViper, NewLog, NewGorm, NewGormLog, NewRedis, NewJwtAuth, NewJWTOps, NewCrypt, )
Functions ¶
func NewGormLog ¶
NewGormLog 注意等级, 不配置表示沉默 trace 不记录任何日志
Types ¶
type Crypt ¶
type Crypt struct {
// contains filtered or unexported fields
}
func NewCryptByKey ¶
type GormLog ¶
type GormLog struct {
// contains filtered or unexported fields
}
type GormOpts ¶
type GormOpts struct { Host string `yaml:"host"` // ip Port int32 `yaml:"port"` // 端口 Database string `yaml:"database"` // 表名称 User string `yaml:"user"` // 用户名 Pwd string `yaml:"pwd"` // 密码 PreFix string `yaml:"prefix"` // 表前缀 MaxIdleConn int `yaml:"maxIdleConn"` MaxOpenConn int `yaml:"maxOpenConn"` // 最大链接池数 ConnMaxLifetime time.Duration `yaml:"connMaxLifetime"` // 单个链接有效时长 Level string `yaml:"level"` SlowThreshold time.Duration `yaml:"slowTime"` // 慢查询阀值 SkipDefaultTransaction bool `yaml:"skipDefaultTransaction"` // true 开启禁用事物,大约 30%+ 性能提升 SingularTable bool `yaml:"singularTable"` }
type JwtAuth ¶
type JwtAuth struct {
// contains filtered or unexported fields
}
func NewJwtAuth ¶
func (*JwtAuth) CreateTokenWithMapPayload ¶
func (a *JwtAuth) CreateTokenWithMapPayload(payloads map[string]interface{}, seconds int64) (string, error)
create token with map
func (*JwtAuth) SetWhitelist ¶
setting whitelist paths
type JwtOpts ¶
type LogOpts ¶
type LogOpts struct { Filename string `yaml:"filename"` // 文件名称 MaxSize int `yaml:"maxSize"` // 最大文件 MaxBackups int `yaml:"maxBackups"` // 最大备份数 MaxAge int `yaml:"maxAge"` //保留时长天 days Level string `yaml:"level"` // 日志登记 对应zap.level Stdout bool `yaml:"stdout"` // 是否在终端输出 Compress bool `yaml:"compress"` // 是否压缩文件 LocalTime bool `yaml:"localTime"` // 使用本地时间 IsContainer bool `yaml:"isContainer"` // 是否是容器, 容器存在公用app.log 情况可以按容器ip 区分 }
LogOpts is log configuration struct
type MailEntity ¶
type MailEntity struct { MainHost string `yaml:"mainHost"` MailFrom string `yaml:"mailFrom"` // 哨兵、发送邮件账号 MailPwd string `yaml:"mailPwd"` // 发送邮件密码 MailPort int `yaml:"mailPort"` // 发送邮件端口 MailGroup map[string][]string `yaml:"mailGroup"` // 邮件组 *Log }
func (*MailEntity) GetMailGroup ¶
func (this *MailEntity) GetMailGroup(key string) (result []string)
GetMailGroup 获取邮件组下所有邮箱 all 返回所有, map[] 不可以设置 all
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package crypt2go @file : crypt2go.go @author : china.gdxs@gmail.com @time : 2024/2/3 16:45 @Description:
|
Package crypt2go @file : crypt2go.go @author : china.gdxs@gmail.com @time : 2024/2/3 16:45 @Description: |
ecb
Package ecb @file : ecb.go @author : china.gdxs@gmail.com @time : 2024/2/3 16:45 @Description:
|
Package ecb @file : ecb.go @author : china.gdxs@gmail.com @time : 2024/2/3 16:45 @Description: |
padding
Package padding @file : padding.go @author : china.gdxs@gmail.com @time : 2024/2/3 16:47 @Description:
|
Package padding @file : padding.go @author : china.gdxs@gmail.com @time : 2024/2/3 16:47 @Description: |