gintool

package
v0.0.0-...-c716174 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success      = 0
	Unauthorized = 401
	Fail         = 400
)

Variables

This section is empty.

Functions

func AddRouteGroups

func AddRouteGroups(engine *gin.Engine, prefix string, routes []RouteGroup)

将分组后的路由集合根据分组注册

func ClearAllSession

func ClearAllSession(ctx *gin.Context)

func GetSession

func GetSession(ctx *gin.Context, k string) interface{}

func Logger

func Logger() gin.HandlerFunc

请求日志汇总信息

func RemoveSession

func RemoveSession(ctx *gin.Context, k string)

func ResultCodeWithData

func ResultCodeWithData(ctx *gin.Context, err error, data interface{})

func SetSession

func SetSession(ctx *gin.Context, k string, o interface{})

func UseSession

func UseSession(router *gin.Engine)

Types

type ApiResponse

type ApiResponse struct {
	Code    e.ErrCode   `json:"code"`              // 状态码
	Message string      `json:"message,omitempty"` // 状态短语
	Result  interface{} `json:"result,omitempty"`  // 数据结果集
	ErrMsg  string      `json:"err_msg,omitempty"` // 内部错误详情
}

type DataList

type DataList struct {
	List      interface{} `json:"list"` //列表
	SubList   interface{} `json:"sub_list,omitempty"`
	PageNum   int         `json:"page_num"`       //当前页码
	PageSize  int         `json:"page_size"`      //单页条数
	PageCount int         `json:"page_count"`     //总页数
	Total     int64       `json:"total"`          //总数
	Cols      interface{} `json:"cols"`           //检索字段
	Note      interface{} `json:"note,omitempty"` //注解
}

type Pager

type Pager struct {
	Page     int   `form:"page"  json:"page"`         //当前页
	PageSize int   `form:"pageSize"  json:"pageSize"` //每页条数
	Total    int64 `form:"total"  json:"total"`       //总条数

	PageCount int `form:"pageCount"  json:"pageCount"` //总页数
	NumStart  int `form:"numStart"  json:"numStart"`   //开始序数
}

分页对象

func CreatePager

func CreatePager(page, pagesize int) *Pager

通过页码和条数获取起始数

func (*Pager) SetTotal

func (p *Pager) SetTotal(total int64)

设置总数获取总页数

type Route

type Route struct {
	Method      string            //http请求方法
	Path        string            //请求路径
	HandlerFunc []gin.HandlerFunc //调用方法
	Comment     string            //路由注释信息
}

func NewRoute

func NewRoute(method, path string, handler ...gin.HandlerFunc) Route

func (Route) AddComment

func (r Route) AddComment(comment string) Route

给当前路由添加注释信息

type RouteGroup

type RouteGroup struct {
	Prefix  string  //路由分组前缀
	Route   []Route //子路由
	Comment string  //模块注释信息
	Module  string  //模块名称
}

Jump to

Keyboard shortcuts

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