util

package
v0.0.0-...-76b4d0c Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(ciphertext []byte) ([]byte, error)

AesDecrypt Aes 解密

func AesEncrypt

func AesEncrypt(plaintext []byte) ([]byte, error)

AesEncrypt Aes 加密

func Compare

func Compare(inputPwd, hashPwd string) error

Compare 比较密码

func EncodeMD5

func EncodeMD5(value string) string

EncodeMD5 生成 MD5

func GenerateToken

func GenerateToken(loginName string) (string, error)

GenerateToken 生成 token

func GetPage

func GetPage(c *gin.Context) int

GetPage 保证了各接口的page处理是一致的

func GetRandomCode

func GetRandomCode() string

GetRandomCode 随机六位验证码

func GetRandomSalt

func GetRandomSalt() string

GetRandomSalt return len=12 salt

func GetRandomString

func GetRandomString(length int) string

GetRandomString 生成随机字符串

func GetTrans

func GetTrans() ut.Translator

GetTrans 获取翻译

func GetValidate

func GetValidate() *validator.Validate

GetValidate GetValidator

func RegPhone

func RegPhone(phone string) bool

func RegUserName

func RegUserName(username string) bool

func ValidEmail

func ValidEmail(email string) bool

ValidEmail 验证邮箱

Types

type Claims

type Claims struct {
	LoginName []byte `json:"loginname"`
	jwt.StandardClaims
}

Claims 声明

func ParseToken

func ParseToken(c *gin.Context) (*Claims, error)

ParseToken 解析 token

func ParseToken2

func ParseToken2(token string) (*Claims, error)

ParseToken2 解析 token

type Error

type Error interface {
	error
	Code() int
}

Error 带有错误码 与 错误信息的错误类

func Encrypt

func Encrypt(inputPassword string) (string, Error)

Encrypt 加密 inputPassword 未加密的密码

func ErrNew

func ErrNew(code int, text string) Error

ErrNew returns an error that formats as the given text.

func ErrNewCode

func ErrNewCode(code int) Error

ErrNew returns an error that formats as the given text.

func ErrNewErr

func ErrNewErr(err error) Error

ErrNew returns an error that formats as the given text.

func ErrNewSql

func ErrNewSql(err error) Error

ErrNew returns an error that formats as the given text.

func GetTokenLoginName

func GetTokenLoginName(c *gin.Context) (string, Error)

GetTokenLoginName 根据 token 获取用户登录,用于去数据库获取用户id

Jump to

Keyboard shortcuts

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