Documentation ¶
Index ¶
- func ErrorHandler(ctx *gin.Context, err error)
- func Wrap[T any](fn func(ctx *gin.Context) (T, error)) gin.HandlerFunc
- func WrapWithBody[T any, R any](fn func(ctx *gin.Context, req R) (T, error)) gin.HandlerFunc
- type ErrorResponseBody
- type HttpCodeError
- type ListVO
- type Page
- type PageVO
- type ResponseBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorHandler ¶
func WrapWithBody ¶
Types ¶
type ErrorResponseBody ¶
func NewErrorResponseBody ¶
func NewErrorResponseBody(httpCode int, message string) ErrorResponseBody
func (ErrorResponseBody) Error ¶
func (er ErrorResponseBody) Error() string
type HttpCodeError ¶
type HttpCodeError int
type PageVO ¶
type PageVO[T any] struct { Page // 总页数 TotalPages int64 `json:"totalPages"` // 总数量 TotalCount int64 `json:"totalCount"` List []T `json:"list"` }
func (*PageVO[T]) SetTotalCountAndCalculateTotalPages ¶
type ResponseBody ¶
type ResponseBody[T any] struct { Code int `json:"code"` Message string `json:"message"` Data T `json:"data,omitempty"` }
func NewResponseBody ¶
func NewResponseBody[T any](code int, message string, data T) *ResponseBody[T]
func SuccessResponse ¶
func SuccessResponse() *ResponseBody[any]
func SuccessResponseWithData ¶
func SuccessResponseWithData[T any](data T) *ResponseBody[T]
func (ResponseBody[T]) Error ¶
func (er ResponseBody[T]) Error() string
Click to show internal directories.
Click to hide internal directories.