common

package
v0.0.0-...-10680b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessCode = 0
	ErrorCode   = 1
)

Variables

View Source
var JWTExp string
View Source
var JWTKey string

Functions

func EncryptPassword

func EncryptPassword(password string) string

func GenToken

func GenToken(ctx context.Context, field CustomField) (string, error)

func GetDB

func GetDB() *gorm.DB

GetDB get global dbClient

func GetJwtFactory

func GetJwtFactory() *xjwt.JWTFactory

func GetRedis

func GetRedis() *redis.Client

GetRedis get global redisClient

func InitGlobal

func InitGlobal() func()

InitGlobal init global vat and return a clean up func.

func InitJwtFactory

func InitJwtFactory(login xjwt.LoginFunc)

func RefreshToken

func RefreshToken(ctx context.Context, token string) (string, error)

func RegisteGlobalDB

func RegisteGlobalDB(db *gorm.DB)

RegisteGlobalDB registe global dbClient

func RegisteGlobalRedis

func RegisteGlobalRedis(client *redis.Client)

RegisteGlobalRedis registe global redisClient

func ResponseMsg

func ResponseMsg(code int32) string

func SetJwtFactory

func SetJwtFactory(jf *xjwt.JWTFactory)

func ValidatePassword

func ValidatePassword(password, encryptPassword string) bool

Types

type Claims

type Claims struct {
	CustomField
	jwt.StandardClaims
}

func ValidToken

func ValidToken(ctx context.Context, token string) (Claims, error)

type Config

type Config struct {
	Redis xredis.Config
	DB    xdb.Config
	Jwt   xjwt.Config
}

func InitConfig

func InitConfig() Config

type CustomField

type CustomField struct {
	UserID int64
	Name   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL