utils

package
v0.0.0-...-ee74485 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(userId int64, security string, role int64, expireTime time.Time, issure string) (string, error)

GenerateToken

@Description: 生成token
@param userId 用户id
@param security 加密字符串
@param role 用户角色
@param expireTime 过期时间
@param issure 签发者
@return string token
@return error 错误

func GetRootPath

func GetRootPath(myPath string) string

GetRootPath 搜索项目的文件根目录, 并和 myPath 拼接起来

func JsonToStruct

func JsonToStruct(str string, value interface{}) error

JsonToStruct

@Description: json to struct
@param str
@param value
@return error

func StructToJson

func StructToJson(value interface{}) (string, error)

StructToJson

@Description: struct to json
@param value
@return string
@return error

func StructToMap

func StructToMap(value interface{}) map[string]interface{}

StructToMap

@Description: struct to map
@param value
@return map[string]interface{}

Types

type MyClaims

type MyClaims struct {
	jwt.StandardClaims
	UserId   int64 `json:"userId"`
	UserRole int64 `json:"userRole"`
}

func TokenVal

func TokenVal(jwtToken string) (claims *MyClaims, err error)

TokenVal

@Description: 验证token
@param jwtToken token
@return claims token信息
@return err 错误

Jump to

Keyboard shortcuts

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