app

package
v0.0.0-...-b2b1cb1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

https://juejin.cn/post/7067532738940633119

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(appKey, appSecret string) (string, error)

GenerateToken 生成 jwt token

func GetJWTSecret

func GetJWTSecret() []byte

func GetPage

func GetPage(c *gin.Context) int

func GetPageOffset

func GetPageOffset(page, pageSize int) int

func GetPageSize

func GetPageSize(c *gin.Context) int

Types

type Claims

type Claims struct {
	AppKey    string `json:"app_key"`
	AppSecret string `json:"app_secret"`
	jwt.StandardClaims
}

func ParseToken

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

ParseToken 解析和校验 token

type Pager

type Pager struct {
	Page      int `json:"page"`
	PageSize  int `json:"page_size"`
	TotalRows int `json:"total_rows"`
}

type Response

type Response struct {
	Ctx *gin.Context
}

func NewResponse

func NewResponse(ctx *gin.Context) *Response

func (*Response) ToErrorResponse

func (r *Response) ToErrorResponse(err *errcode.Error)

ToErrorResponse 错误返回

func (*Response) ToResponse

func (r *Response) ToResponse(data interface{})

ToResponse 正确数据返回

func (*Response) ToResponseList

func (r *Response) ToResponseList(list interface{}, totalRows int)

ToResponseList 分页数据返回

type ValidError

type ValidError struct {
	Key     string // 需要验证的字段
	Message string // 验证失败之后的错误信息
}

func (*ValidError) Error

func (v *ValidError) Error() string

type ValidErrors

type ValidErrors []*ValidError

func BindAndValid

func BindAndValid(c *gin.Context, v interface{}) (bool, ValidErrors)

func (ValidErrors) Error

func (v ValidErrors) Error() string

func (ValidErrors) Errors

func (v ValidErrors) Errors() []string

Jump to

Keyboard shortcuts

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