ginx

package
v1.0.26 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserIDKey        = prefix + "/user-id"
	UserNameKey      = prefix + "/user-name"
	RoleIDKey        = prefix + "/role-id"
	RoleKey          = prefix + "/role-key"
	RoleNameKey      = prefix + "/role-name"
	DataScopeKey     = prefix + "/data-scope"
	ReqBodyKey       = prefix + "/req-body"
	ResBodyKey       = prefix + "/res-body"
	LoggerReqBodyKey = prefix + "/logger-req-body"
)

定义上下文中的键

View Source
const (
	SuccessStatus = 200
	FailStatus    = -1
)

Variables

This section is empty.

Functions

func Fail

func Fail(c *gin.Context)

Fail Fail

func FailWithCode

func FailWithCode(c *gin.Context, code int)

FailWithCode FailWithCode

func FailWithCodeData

func FailWithCodeData(c *gin.Context, code int, data interface{})

FailWithCodeData FailWithCodeData

func FailWithCodeMsg

func FailWithCodeMsg(c *gin.Context, code int, msg string)

FailWithCodeMsg FailWithCodeMsg

func FailWithError

func FailWithError(c *gin.Context, err error)

FailWithError FailWithError

func FailWithMsg

func FailWithMsg(c *gin.Context, msg string)

FailWithMsg FailWithMsg

func GetBody

func GetBody(c *gin.Context) []byte

GetBody Get request body

func GetDataScope

func GetDataScope(c *gin.Context) string

GetDataScope 获取数据范围

func GetIntUserID

func GetIntUserID(c *gin.Context) int

GetIntUserID 获取整型用户ID

func GetRoleID

func GetRoleID(c *gin.Context) int

GetRoleID 获取角色ID

func GetRoleKey

func GetRoleKey(c *gin.Context) string

GetRoleKey 获取角色Key

func GetRoleName

func GetRoleName(c *gin.Context) string

GetRoleName 获取角色名

func GetToken

func GetToken(c *gin.Context) string

GetToken 获取用户令牌

func GetUintUserID

func GetUintUserID(c *gin.Context) uint

GetUintUserID 获取无符号整型用户ID

func GetUserID

func GetUserID(c *gin.Context) string

GetUserID 获取用户ID

func GetUserName

func GetUserName(c *gin.Context) string

GetUserName 获取用户名

func JSON

func JSON(c *gin.Context, status int, data interface{})

JSON JSON

func OK

func OK(c *gin.Context)

OK OK

func OkWithData

func OkWithData(c *gin.Context, data interface{})

OkWithData OkWithData

func OkWithDataMsg

func OkWithDataMsg(c *gin.Context, data interface{}, msg string)

OkWithDataMsg OkWithDataMsg

func ParseForm

func ParseForm(c *gin.Context, obj interface{}) error

ParseForm 解析Form请求

func ParseJSON

func ParseJSON(c *gin.Context, obj interface{}) error

ParseJSON 解析请求JSON

func ParseQuery

func ParseQuery(c *gin.Context, obj interface{}) error

ParseQuery 解析Query参数

func Result

func Result(c *gin.Context, code int, msg string, data interface{})

Result Result

func ResultWithCode

func ResultWithCode(c *gin.Context, code int)

ResultWithCode ResultWithCode

func ResultWithCodeData

func ResultWithCodeData(c *gin.Context, code int, data interface{})

ResultWithCodeData ResultWithCodeData

func SetDataScope

func SetDataScope(c *gin.Context, dataScope string)

SetDataScope 设置数据范围

func SetRoleID

func SetRoleID(c *gin.Context, id int)

SetRoleID 设定角色ID

func SetRoleKey

func SetRoleKey(c *gin.Context, key string)

SetRoleKey 设定角色Key

func SetRoleName

func SetRoleName(c *gin.Context, roleName string)

SetRoleName 设定角色名

func SetUserID

func SetUserID(c *gin.Context, userID string)

SetUserID 设定用户ID

func SetUserName

func SetUserName(c *gin.Context, userName string)

SetUserName 设定用户名

func Success

func Success(c *gin.Context, data interface{})

Success Success

Types

type Response

type Response struct {
	Code      int         `json:"code"`      // 响应代码
	Data      interface{} `json:"data"`      // 数据集
	Msg       string      `json:"msg"`       // 消息
	RequestID string      `json:"requestId"` // 请求ID
}

Response Response

Jump to

Keyboard shortcuts

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