utils

package
v0.0.0-...-8bc0546 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeFileName = [...]string{Avatar: "user", ProductImg: "boss"}

Functions

func CaptchaVerify

func CaptchaVerify(c *gin.Context, code string) bool

func CreateDir

func CreateDir(dirName string) bool

创建文件夹

func DirExistOrNot

func DirExistOrNot(fileAddr string) bool

判断文件夹路径是否存在

func GenerateEmailToken

func GenerateEmailToken(userID, Operation uint, email, password string) (string, error)

GenerateEmailToken 签发邮箱验证Token

func GenerateToken

func GenerateToken(id uint, username string, authority int) (string, error)

签发用户Token

func PadPwd

func PadPwd(srcByte []byte, blockSize int) []byte

填充密码长度

func UnPadPwd

func UnPadPwd(dst []byte) ([]byte, error)

去掉填充的部分

func UploadToLocalStatic

func UploadToLocalStatic(file multipart.File, userId uint, Name string, utype UploadType) (filePath string, err error)

Types

type Claims

type Claims struct {
	ID        uint   `json:"id"`
	Username  string `json:"username"`
	Authority int    `json:"authority"`
	jwt.StandardClaims
}

func ParseToken

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

验证用户token

type EmailClaims

type EmailClaims struct {
	UserID        uint   `json:"user_id"`
	Email         string `json:"email"`
	Password      string `json:"password"`
	OperationType uint   `json:"operation_type"`
	jwt.StandardClaims
}

EmailClaims

func ParseEmailToken

func ParseEmailToken(token string) (*EmailClaims, error)

ParseEmailToken 验证邮箱验证token

type Encryption

type Encryption struct {
	// contains filtered or unexported fields
}

AES 加密算法

var Encrypt *Encryption

全局加密器

func NewEncryption

func NewEncryption() *Encryption

func (*Encryption) AesDecoding

func (k *Encryption) AesDecoding(pwd string) string

解密

func (*Encryption) AesEncoding

func (k *Encryption) AesEncoding(src string) string

加密

func (*Encryption) SetKey

func (k *Encryption) SetKey(key string)

set方法

type UploadType

type UploadType int
const (
	Avatar UploadType = iota
	ProductImg
)

Jump to

Keyboard shortcuts

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