app

package
v0.0.0-...-5952180 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodePwd

func EncodePwd(value string) string

func EncodeSha1

func EncodeSha1(value string) string

func GenerateToken

func GenerateToken(userId int, username string, userType int) (string, error)

func GetJwtSecret

func GetJwtSecret() string

func GetPageNum

func GetPageNum(c *gin.Context) int

func GetPageOffset

func GetPageOffset(page, pageSize int) int

func GetPageSize

func GetPageSize(c *gin.Context) int

func InitPagination

func InitPagination(pageNum, pageSize int) (int, int)

Types

type Claims

type Claims struct {
	Id       int    `json:"id"`
	Username string `json:"username"`
	UserType int    `json:"userType"`
	jwt.StandardClaims
}

func GetJwtClaims

func GetJwtClaims(c *gin.Context) (*Claims, error)

GetJwtClaims 获取jwt登陆用户的基础信息

func GetLoginUser

func GetLoginUser(ctx context.Context) *Claims

GetLoginUser 获取登陆用户的基础信息

func ParseToken

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

type Response

type Response struct {
	Ctx *gin.Context
}

func NewResponse

func NewResponse(ctx *gin.Context) *Response

func (*Response) ToResponse

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

func (*Response) ToResponseError

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

func (*Response) ToResponseList

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

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) Errors

func (v ValidErrors) Errors() []string

Jump to

Keyboard shortcuts

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