Documentation
¶
Index ¶
- func Error(c *gin.Context, err error)
- func Success(c *gin.Context, data interface{})
- type APIResponse
- func (res *APIResponse) ToString() string
- func (res *APIResponse) WithCurrent(current int) *APIResponse
- func (res *APIResponse) WithData(data interface{}) *APIResponse
- func (res *APIResponse) WithMessage(msg string) *APIResponse
- func (res *APIResponse) WithPerPage(perPage int) *APIResponse
- func (res *APIResponse) WithSize(size int) *APIResponse
- func (res *APIResponse) WithTotal(total int64) *APIResponse
- func (res *APIResponse) WithTraceID(traceID string) *APIResponse
- type PageReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIResponse ¶
type APIResponse struct { Code int `json:"code"` // 业务编码 Status bool `json:"status"` // 请求是否成功 Message string `json:"message,omitempty"` // 错误描述 Current int `json:"current,omitempty"` // 当前页码 Size int `json:"size,omitempty"` // 当前页数量 PerPage int `json:"per_page,omitempty"` // 每页数量 Total int64 `json:"total,omitempty"` // 总数量 Data interface{} `json:"data,omitempty"` // 数据 Order string `json:"order,omitempty"` // 排序字段 TraceID string `json:"trace_id,omitempty"` // 追踪ID }
APIResponse 标准响应结构
func NewResponse ¶
func NewResponse(err *xerror.Error) *APIResponse
func NewResponseData ¶
func NewResponseData(err *xerror.Error, data interface{}) *APIResponse
func NewResponseMessage ¶
func NewResponseMessage(err *xerror.Error, message string) *APIResponse
func (*APIResponse) WithCurrent ¶
func (res *APIResponse) WithCurrent(current int) *APIResponse
func (*APIResponse) WithData ¶
func (res *APIResponse) WithData(data interface{}) *APIResponse
func (*APIResponse) WithMessage ¶
func (res *APIResponse) WithMessage(msg string) *APIResponse
func (*APIResponse) WithPerPage ¶
func (res *APIResponse) WithPerPage(perPage int) *APIResponse
func (*APIResponse) WithSize ¶
func (res *APIResponse) WithSize(size int) *APIResponse
func (*APIResponse) WithTotal ¶
func (res *APIResponse) WithTotal(total int64) *APIResponse
func (*APIResponse) WithTraceID ¶
func (res *APIResponse) WithTraceID(traceID string) *APIResponse
type PageReq ¶
type PageReq struct { Current int `json:"current" form:"current" binding:"omitempty,min=1" default:"1"` // 当前页 Size int `json:"size" form:"size" binding:"omitempty,min=1" default:"10"` // 每页大小 Order string `json:"order" form:"order" binding:"omitempty" default:"id"` // 排序字段 }
func (PageReq) GetCurrent ¶
Click to show internal directories.
Click to hide internal directories.