app

package
v0.0.0-...-e272627 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(id int, username, password string) (string, error)

func GetJWTSecret

func GetJWTSecret() []byte

func GetPageOffset

func GetPageOffset(pageNum, pageSize int) int

func GetRemoteIp

func GetRemoteIp(req *http.Request) string

func ToResponseCode

func ToResponseCode(writer http.ResponseWriter, err error)

func ToResponseData

func ToResponseData(writer http.ResponseWriter, data interface{})

func ToResponseList

func ToResponseList(writer http.ResponseWriter, total int64, data interface{})

func Wrap

func Wrap(handler HandlerFunc) func(c *gin.Context)

func WrapList

func WrapList(handler HandlerListFunc) func(c *gin.Context)

Types

type Claims

type Claims struct {
	UserId   int    `json:"user_id"`
	UserName string `json:"user_name"`
	jwt.StandardClaims
}

func ParseToken

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

type CommResponse

type CommResponse struct {
	*retcode.RetErr
	Data interface{} `json:"data,omitempty"`
}

type ErrResponse

type ErrResponse struct {
	*retcode.RetErr
}

type HandlerFunc

type HandlerFunc func(ctx *gin.Context) (res interface{}, err error)

type HandlerListFunc

type HandlerListFunc func(ctx *gin.Context) (res interface{}, total int64, err error)

type ListResponse

type ListResponse struct {
	*retcode.RetErr
	Total int64       `json:"total"`
	Data  interface{} `json:"data,omitempty"`
}

type Page

type Page struct {
	// 页码
	PageNum int `json:"page_num"`
	// 每页数量
	PageSize int `json:"page_size"`
}

func CorrectPage

func CorrectPage(size, num int) Page

Jump to

Keyboard shortcuts

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