util

package
v0.0.0-...-3e48e4f Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.2.0"

Variables

View Source
var Errors = CustomErrors{
	NotLoginError:          CustomError{false, 10100, "请先登录"},
	TokenInvalidError:      CustomError{false, 10101, "访问令牌无效"},
	TokenIllegalError:      CustomError{false, 10102, "访问令牌不合法"},
	TokenNotAvailableError: CustomError{false, 10103, "令牌无法解析"},
	PermissionDeniedError:  CustomError{false, 10104, "权限不足"},
	ParamEmptyError:        CustomError{false, 10105, "缺少关键参数"},
	ParamIllegalError:      CustomError{false, 10106, "参数类型错误"},
	UnexpectedError:        CustomError{false, 99999, "发生意料之外的错误"},
}

Functions

func CalculateMD5

func CalculateMD5(input string) string

func GenerateRandom

func GenerateRandom(charset string, length int) string

func GenerateRandomNumber

func GenerateRandomNumber(length int) string

func GenerateRandomString

func GenerateRandomString(length int) string

func GetBool

func GetBool(key string) bool

func GetFloat64

func GetFloat64(key string) float64

func GetInt

func GetInt(key string) int

func GetInt32

func GetInt32(key string) int32

func GetPostBool

func GetPostBool(ctx *gin.Context, name string, defaultValue bool) bool

func GetPostInt

func GetPostInt(ctx *gin.Context, name string, defaultValue int) int

func GetPostInt64

func GetPostInt64(ctx *gin.Context, name string, defaultValue int64) int64

func GetString

func GetString(key string) string

func InitConfig

func InitConfig()

func InitDB

func InitDB() *xorm.Engine

func InitDBTable

func InitDBTable(engine *xorm.Engine)

func OutErr

func OutErr(module, format string, v ...any)

func OutLog

func OutLog(module, msg string)

func OutLogf

func OutLogf(module, format string, v ...any)

func Reload

func Reload()

func ReturnData

func ReturnData(ctx *gin.Context, state bool, obj any)

func ReturnError

func ReturnError(ctx *gin.Context, err CustomError)

func ReturnMessage

func ReturnMessage(ctx *gin.Context, state bool, message string)

func ReturnMessageData

func ReturnMessageData(ctx *gin.Context, state bool, message string, obj any)

func Set

func Set(key string, value interface{})

Types

type CustomError

type CustomError struct {
	State   bool   `json:"state"`
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*CustomError) Error

func (e *CustomError) Error() string

type CustomErrors

type CustomErrors struct {
	// 未登录
	NotLoginError CustomError
	// 令牌无效
	TokenInvalidError CustomError
	// 令牌不合法
	TokenIllegalError CustomError
	// 令牌不合法
	TokenNotAvailableError CustomError
	// 权限不足
	PermissionDeniedError CustomError
	// 参数为空
	ParamEmptyError CustomError
	// 参数不合法
	ParamIllegalError CustomError
	// 意料之外
	UnexpectedError CustomError
}

Jump to

Keyboard shortcuts

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