public

package
v0.0.0-...-cccf1c7 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidatorKey  = "ValidatorKey"
	TranslatorKey = "TranslatorKey"
)

Variables

View Source
var MySecret = []byte("otto_lzn")

Functions

func ComLogNotice

func ComLogNotice(c *gin.Context, srtag string, m map[string]interface{})

ComLogNotice 普通日志

func ComLogWarning

func ComLogWarning(c *gin.Context, srtag string, m map[string]interface{})

ComLogWarning 错误日志

func ContextError

func ContextError(c context.Context, srtag string, m map[string]interface{})

ContextError 错误日志

func ContextNotice

func ContextNotice(c context.Context, srtag string, m map[string]interface{})

ContextNotice 普通日志

func ContextWarning

func ContextWarning(c context.Context, srtag string, m map[string]interface{})

ContextWarning 错误日志

func DefaultGetValidParams

func DefaultGetValidParams(c *gin.Context, params interface{}) error

DefaultGetValidParams 默认验证器

func GenToken

func GenToken(user Users) (string, error)

GenToken 创建 Token

func GetGinTraceContext

func GetGinTraceContext(c *gin.Context) *lib.TraceContext

GetGinTraceContext 从gin的Context中获取数据

func GetTraceContext

func GetTraceContext(c context.Context) *lib.TraceContext

GetTraceContext 从Context中获取数据

func GetTranslation

func GetTranslation(c *gin.Context) (ut.Translator, error)

func GetValidator

func GetValidator(c *gin.Context) (*validator.Validate, error)

func RefreshToken

func RefreshToken(tokenStr string) (string, error)

RefreshToken 刷新 Token

Types

type CustomClaims

type CustomClaims struct {
	Users
	jwt.StandardClaims
}

func ParseToken

func ParseToken(tokenStr string) (*CustomClaims, error)

ParseToken 解析 token

type ResponseCode

type ResponseCode int
const (
	SuccessCode ResponseCode = iota
	UndefErrorCode
	ValidErrorCode
	InternalErrorCode

	InvalidRequestErrorCode ResponseCode = 401
	CustomizeCode           ResponseCode = 1000

	GroupAllSaveFlowError ResponseCode = 2001
	OtherErrorCode        ResponseCode = -1
)

1000以下为通用码,1000以上为用户自定义码

type Users

type Users struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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