utils

package
v0.0.0-...-db60f45 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

* @Author: lihuan * @Date: 2024-08-27 20:42:11 * @LastEditors: lihuan * @LastEditTime: 2024-09-18 21:07:29 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2024-09-13 22:03:05 * @LastEditors: lihuan * @LastEditTime: 2024-09-14 23:19:26 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2024-09-01 20:42:11 * @LastEditors: lihuan * @LastEditTime: 2024-09-22 18:03:59 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2024-09-19 19:42:00 * @LastEditors: lihuan * @LastEditTime: 2024-09-21 21:46:52 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2024-08-27 20:42:11 * @LastEditors: lihuan * @LastEditTime: 2024-09-02 20:33:10 * @Email: 17719495105@163.com

* @Author: lihuan * @Date: 2021-12-13 20:15:52 * @LastEditors: lihuan * @LastEditTime: 2024-09-05 21:28:46 * @Email: 17719495105@163.com

Index

Constants

View Source
const (
	Success           = 2000
	ErrParamsParse    = 2001
	ErrInvalidToken   = 2003
	ErrTokenTimeout   = 2004
	ErrTokenParse     = 2005
	ErrPhoneNotExit   = 2006
	ErrRecordNotFound = 2007
	ErrCustomtMsg     = 2008
)

Variables

This section is empty.

Functions

func EncodeMd5

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

s:加密字符串 sum:密钥

func ErrorResponse

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

func GenerateToken

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

func GetMsg

func GetMsg(code int) string

func HttpHandle

func HttpHandle(ctx *gin.Context, opt HttpHandleOptions) ([]byte, error)

func InitLogger

func InitLogger(c *Conf) *logrus.Logger

func SuccessResponse

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

Types

type Application

type Application struct {
	Address string
	Port    int
	Mode    string
}

type Claims

type Claims struct {
	ID string `json:"id"`
	jwt.StandardClaims
}

func ParseToken

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

type Conf

type Conf struct {
	Application Application
	Token       Token
	Md5         Md5
	MySql       MySql
	Redis       Redis
	WX          WX
	Log         Log
}
var Cfg *Conf = nil

func InitConf

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

type HttpHandleOptions

type HttpHandleOptions struct {
	Url   string
	Reply interface{}
}

type Log

type Log struct {
	LogFilePath string `yaml:"log_file_path"`
	LogFileName string `yaml:"log_file_name"`
}

type Md5

type Md5 struct {
	Secret string
}

type MySql

type MySql struct {
	Dns string
}

type Redis

type Redis struct {
	Dns  string
	Pass string
	DB   int
}

type Token

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

type WX

type WX struct {
	AppID     string `yaml:"app_id"`
	AppSecret string `yaml:"app_secret"`
}

Jump to

Keyboard shortcuts

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