utils

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     = errors.New("Token is expired")
	TokenNotValidYet = errors.New("Token not active yet")
	TokenMalformed   = errors.New("That's not even a token")
	TokenInvalid     = errors.New("Couldn't handle this token:")
)

Functions

func CreateDir

func CreateDir(dirs ...string) (err error)

func DeLFile

func DeLFile(filePath string) error

func DecryptPwd

func DecryptPwd(password, hash string) bool

DecryptPwd 对比明文密码和数据库的哈希值

func EncryptPwd

func EncryptPwd(password string) string

EncryptPwd encrypt password via bcrypt

func FileExist

func FileExist(path string) bool

FileExist 判断文件是否存在

func FileMove

func FileMove(src string, dst string) (err error)

@author: [songzhibin97](https://github.com/songzhibin97) @function: FileMove @description: 文件移动供外部调用 @param: src string, dst string(src: 源位置,绝对路径or相对路径, dst: 目标位置,绝对路径or相对路径,必须为文件夹) @return: err error

func GetClaims

func GetClaims(c *gin.Context) (*request.CustomClaims, error)

func GetUserID

func GetUserID(c *gin.Context) uint

GetUserID 从Gin的Context中获取从jwt解析出来的用户ID

func GetUserInfo

func GetUserInfo(c *gin.Context) *request.CustomClaims

GetUserInfo 从Gin的Context中获取从jwt解析出来的用户角色id

func GetUserUuid

func GetUserUuid(c *gin.Context) uuid.UUID

GetUserUuid 从Gin的Context中获取从jwt解析出来的用户UUID

func Md5Sum

func Md5Sum(str []byte, b []byte) string

func ParseDuration

func ParseDuration(d string) (time.Duration, error)

func PathExists

func PathExists(path string) (bool, error)

func TrimSpace

func TrimSpace(target interface{})

@author: [songzhibin97](https://github.com/songzhibin97) @function: TrimSpace @description: 去除结构体空格 @param: target interface (target: 目标结构体,传入必须是指针类型) @return: null

Types

type Jwt

type Jwt struct {
	SigningKey []byte
}

func NewJwt

func NewJwt() *Jwt

func (*Jwt) CreateClaims

func (j *Jwt) CreateClaims(baseClaims request.BaseClaims) request.CustomClaims

func (*Jwt) CreateToken

func (j *Jwt) CreateToken(claims request.CustomClaims) (string, error)

CreateToken create jwt token

func (*Jwt) FreshTokenWithToken

func (j *Jwt) FreshTokenWithToken(oldToken string, claims request.CustomClaims) (string, error)

FreshTokenWithToken get newer token via older token

func (*Jwt) ParseToken

func (j *Jwt) ParseToken(tokenString string) (*request.CustomClaims, error)

ParseToken parse token

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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