utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const CustomMsgPrefix = "CUSTOM:"

Variables

View Source
var JwtTokenHead string
View Source
var JwtTokenHeaderKey string

Functions

func ComparePassword

func ComparePassword(password string, encryptedPassword string) bool

验证密码

func EncryptPassword

func EncryptPassword(password string) string

加密密码

func GenerateToken

func GenerateToken(username string) (error, string)

根据用户名生成JWT的token

func GetDB

func GetDB() *gorm.DB

func GetUserNameFromToken

func GetUserNameFromToken(tokenStr string) (error, string)

从token中获取登录用户名

func GetUuid

func GetUuid() *snowflake.Node

func InitDB

func InitDB(dbInstance *gorm.DB)

func InitUuid

func InitUuid(nodeInstance *snowflake.Node)

func MatchUrl

func MatchUrl(urls []string, path string) bool

匹配URL

func NormalizeErrorMessage

func NormalizeErrorMessage(err error) string

格式化错误响应信息

func NormalizeUrl

func NormalizeUrl(url string) string

func RefreshHeadToken

func RefreshHeadToken(oldToken string) (error, string)

当原来的token没过期时是可以刷新的 @param oldToken 带tokenHead的token

func StringToInt64

func StringToInt64(val string, defaults int64) int64

字符转数字

Types

This section is empty.

Jump to

Keyboard shortcuts

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