app

package
v0.0.0-...-9d33de4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindAndValid

func BindAndValid(c *gin.Context, form interface{}) (httpCode, errCode int)

BindAndValid binds and validates data

func MarkErrors

func MarkErrors(errors []*validation.Error)

MarkErrors logs error logs

func QueryWithInt

func QueryWithInt(ctx *gin.Context, key string) (int, error)

获取int类型查询参数

func Recover

func Recover(appG *Gin)

异常恢复

func Valid

func Valid(form interface{}) (int, int)

使用 validates 数据校验

Types

type Auth

type Auth struct {
	UserId   int    `json:"user_id"`
	Username string `json:"username"`
}

认证信息

func GetUserInfo

func GetUserInfo(content *gin.Context) *Auth

获取gin上下文中的用户信息

type Gin

type Gin struct {
	C *gin.Context
}

Gin业务响应

func (*Gin) Fail

func (g *Gin) Fail(data interface{})

返回失败gin.JSON

func (*Gin) Response

func (g *Gin) Response(httpCode, errCode int, data interface{})

返回gin.JSON

func (*Gin) Success

func (g *Gin) Success(data interface{})

返回成功gin.JSON

type Response

type Response struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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