Documentation
¶
Index ¶
- Variables
- 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 IdVO
- type ListVO
- type Page
- type PageRequest
- type PageVO
- type ResponseBody
- type Sorting
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SuccessResponse = ResponseBody[any]{ Code: http.StatusOK, Message: http.StatusText(http.StatusOK), Data: nil, } )
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 PageRequest ¶
func (*PageRequest) ValidateAndSetDefault ¶
func (p *PageRequest) ValidateAndSetDefault()
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 SuccessResponseWithData ¶
func SuccessResponseWithData[T any](data T) ResponseBody[T]
Click to show internal directories.
Click to hide internal directories.