rest

package
v0.0.0-...-da9a27d Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TokenExpireDuration = time.Hour * 24 * 30

TokenExpireDuration expireDuration

Variables

View Source
var MySecret = []byte("#1024helper")

MySecret ...

Functions

func AuthCros

func AuthCros() gin.HandlerFunc

AuthCros ....

func BindURI

func BindURI(c *gin.Context) bool

BindURI check bind uri

func GenToken

func GenToken(name string) (string, error)

GenToken 生成JWT

func HTTPResponse

func HTTPResponse(c *Context, httpCode *int, err *error, data interface{})

HTTPResponse 统一返回格式

Types

type Context

type Context struct {
	context.Context

	Operator *Operator
	// contains filtered or unexported fields
}

Context context define

func NewContext

func NewContext(c *gin.Context) *Context

NewContext new context

type ListData

type ListData struct {
	TotalOption
	List interface{} `json:"list"`
}

ListData ...

func NewListData

func NewListData(opt PageOption, total int64, list interface{}) *ListData

NewListData fill data

type Operator

type Operator struct {
	jwt.StandardClaims
	Name string
}

Operator ...

type PageOption

type PageOption struct {
	PageIndex int    `form:"pageIndex"`
	PageSize  int    `form:"pageSize"`
	Sort      string `form:"sort"` //asc or desc
	Scope     string `form:"scope"`
}

PageOption ...

func (*PageOption) Check

func (opt *PageOption) Check()

Check ...

type ResultReply

type ResultReply struct {
	Result bool        `json:"result"`
	Msg    interface{} `json:"msg"`
}

ResultReply ...

func (*ResultReply) SetResult

func (r *ResultReply) SetResult(err error)

SetResult ...

type TotalOption

type TotalOption struct {
	PageIndex  int   `json:"pageIndex"`
	PageSize   int   `json:"pageSize"`
	TotalCount int64 `json:"totalCount"`
	TotalPage  int   `json:"totalPage"`
}

TotalOption ...

Jump to

Keyboard shortcuts

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