utils

package
v0.0.0-...-b0f014a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

* @Author: lihuan * @Date: 2021-12-13 20:15:52 * @LastEditors: lihuan * @LastEditTime: 2021-12-13 21:38:24 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2021-12-13 20:15:52 * @LastEditors: lihuan * @LastEditTime: 2021-12-15 21:00:16 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2021-12-13 20:15:52 * @LastEditors: lihuan * @LastEditTime: 2021-12-22 22:10:49 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2021-10-09 10:08:01 * @LastEditTime: 2021-12-15 20:14:20 * @Email: 17719495105@163.com

Index

Constants

View Source
const (
	Success           = 2000
	ParamsParseError  = 2001
	RpcError          = 2002
	InvalidToken      = 2003
	TokenTimeout      = 2004
	TokenParse        = 2005
	ErrorPhoneNotExit = 2006
)

Variables

This section is empty.

Functions

func EncodeMd5

func EncodeMd5(s string, sum []byte) string

s:加密字符串 sum:密钥

func ErrorResponse

func ErrorResponse(ctx *gin.Context, r interface{})

func ErrorTranslate

func ErrorTranslate(e validator.ValidationErrors) string

func GenerateToken

func GenerateToken(id int64, username, secret_password string, secret []byte, exp int) (string, error)

func GetMsg

func GetMsg(code int) string

func SuccessResponse

func SuccessResponse(ctx *gin.Context, data interface{})

func Validator

func Validator()

Types

type Application

type Application struct {
	Address string
	Port    int
	Mode    string
}

type Claims

type Claims struct {
	UserName string `json:"username"`
	ID       int64  `json:"id"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string, secret []byte) (*Claims, error)

type Conf

type Conf struct {
	Application Application
	Token       Token
	Md5         Md5
}
var Cfg *Conf = nil

func GetConf

func GetConf(path string) (*Conf, error)

type Md5

type Md5 struct {
	Secret string
}

type Token

type Token struct {
	Secret     string
	ExpireTime int `yaml:"expire_time"`
}

Jump to

Keyboard shortcuts

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