app

package
v0.0.0-...-2381096 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CODE_SUCCESS     = 200
	CODE_DOU_SUCCESS = 0
	MSG_SUCCESS      = "success"
	CODE_ROUTE_ERROR = 404
)

Variables

This section is empty.

Functions

func GenerateToken

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

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)

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

func (r *Response) BuildTpl(c *gin.Context, tpl string) *TplResp

BuildTpl 返回一个tpl响应

func (*Response) ErrorTpl

func (r *Response) ErrorTpl(c *gin.Context) *TplResp

ErrorTpl 返回一个错误的tpl响应

func (*Response) ToErrorResponse

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

func (*Response) ToResponse

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

func (*Response) ToResponseList

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

type ResponseCommonStruct

type ResponseCommonStruct struct {
	Msg   string      `json:"msg"`
	Code  int         `json:"code"`
	Data  interface{} `json:"data"`
	Pager Pager       `json:"pager"`
	Count int         `json:"count"`
}

type TplResp

type TplResp struct {
	// contains filtered or unexported fields
}

通用tpl响应

func (*TplResp) WriteTpl

func (resp *TplResp) WriteTpl(params ...gin.H)

WriteTpl 输出页面模板附加自定义函数

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