ginx

package
v2.0.77 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserIDKey        = prefix + "/user-id"
	DeptIDKey        = prefix + "/dept-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, status int)

Fail Fail

func FailWithCode

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

FailWithCode FailWithCode

func FailWithCodeData

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

FailWithCodeData FailWithCodeData

func FailWithCodeMsg

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

FailWithCodeMsg FailWithCodeMsg

func FailWithError

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

FailWithError FailWithError

func FailWithMsg

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

FailWithMsg FailWithMsg

func GetBody

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

GetBody Get request body

func GetDeptID added in v2.0.31

func GetDeptID(c *gin.Context) int

GetDeptID 获取用户ID

func GetToken

func GetToken(c *gin.Context) string

GetToken 获取用户令牌

func GetUserID

func GetUserID(c *gin.Context) int

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, status, code int, msg string, data interface{})

Result Result

func ResultWithCode

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

ResultWithCode ResultWithCode

func ResultWithCodeData

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

ResultWithCodeData ResultWithCodeData

func SetDeptID added in v2.0.31

func SetDeptID(c *gin.Context, deptID int)

SetDeptID 设定用户ID

func SetUserID

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

SetUserID 设定用户ID

func SetUserName

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

SetUserName 设定用户名

func Success

func Success(c *gin.Context, status int, 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