app

package
v0.0.0-...-bcd2c7c Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptOK

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

AdaptOK 用于对接前端(暂时替代OK)

func Custom

func Custom(c *gin.Context, h gin.H)

func Error

func Error(c *gin.Context, code ErrCode, data interface{})

func ErrorParams

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

func Errorf

func Errorf(c *gin.Context, code ErrCode, format string, values ...interface{})

func InternalServerError

func InternalServerError(c *gin.Context)

func OK

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

func PageOK

func PageOK(c *gin.Context, result interface{}, count int, pageIndex int, pageSize int, msg string)

分页数据处理

Types

type ErrCode

type ErrCode int
var (
	// 客户端发送的数据包含非法参数
	Err_Invalid_Argument ErrCode = 400

	// token缺失或过期,请求未能通过身份认证
	Err_Unauthenticated ErrCode = 401

	// 客户端没有足够的权限
	Err_Permission_Denied ErrCode = 403

	// 资源未找到
	Err_Not_found ErrCode = 404

	// 并发冲突
	Err_Aborted ErrCode = 409

	// 资源配额不足或达不到速率限制
	Err_Resource_Exhausted ErrCode = 429

	// 请求被客户端取消
	Err_Cancelled ErrCode = 499

	// 内部服务器错误
	Err_Internal ErrCode = 500

	// API方法没有被服务器实现
	Err_Not_Implemented ErrCode = 501

	// 服务不可用
	Err_Unavailable ErrCode = 503

	// 请求超过了截止日期
	Err_Dealine_Exceed ErrCode = 504
)

func (ErrCode) Error

func (c ErrCode) Error() string

func (ErrCode) String

func (c ErrCode) String() string

type ErrResponse

type ErrResponse struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Detail  interface{} `json:"details"`
}

type Page

type Page struct {
	List      interface{} `json:"list"`
	Count     int         `json:"count"`
	PageIndex int         `json:"pageIndex"`
	PageSize  int         `json:"pageSize"`
}

type PageResponse

type PageResponse struct {
	// 代码
	Code int `json:"code" example:"200"`
	// 数据集
	Data Page `json:"data"`
	// 消息
	Msg string `json:"msg"`
}

func (*PageResponse) ReturnOK

func (res *PageResponse) ReturnOK() *PageResponse

type Response

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

func (*Response) ReturnOK

func (res *Response) ReturnOK() *Response

Jump to

Keyboard shortcuts

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