common

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequestResponse

func BadRequestResponse(c *gin.Context, message string)

BadRequestResponse 400 错误响应

func ErrorResponse

func ErrorResponse(c *gin.Context, code int, message string)

ErrorResponse 错误响应

func ForbiddenResponse

func ForbiddenResponse(c *gin.Context, message string)

ForbiddenResponse 403 禁止访问响应

func InternalServerErrorResponse

func InternalServerErrorResponse(c *gin.Context, message string)

InternalServerErrorResponse 500 服务器内部错误响应

func NotFoundResponse

func NotFoundResponse(c *gin.Context, message string)

NotFoundResponse 404 未找到响应

func SuccessResponse

func SuccessResponse(c *gin.Context, detail interface{})

SuccessResponse 成功响应

func SuccessWithCleanedCount

func SuccessWithCleanedCount(c *gin.Context, count int)

SuccessWithCleanedCount 带清理计数的成功响应

func SuccessWithFileInfo

func SuccessWithFileInfo(c *gin.Context, fileInfo interface{})

SuccessWithFileInfo 带文件信息的成功响应

func SuccessWithList

func SuccessWithList(c *gin.Context, list interface{}, total int, pagination ...PaginationParams)

SuccessWithList 带列表数据的成功响应(统一使用分页响应结构)

func SuccessWithMessage

func SuccessWithMessage(c *gin.Context, message string, detail interface{})

SuccessWithMessage 带自定义消息的成功响应

func SuccessWithPagination

func SuccessWithPagination(c *gin.Context, list interface{}, total int, page int, pageSize int)

SuccessWithPagination 带分页数据的成功响应(保留向后兼容性)

func SuccessWithToken

func SuccessWithToken(c *gin.Context, token string, userInfo interface{})

SuccessWithToken 带令牌的成功响应

func SuccessWithUploadInfo

func SuccessWithUploadInfo(c *gin.Context, shareCode string, downloadLink string)

SuccessWithUploadInfo 带上传信息的成功响应

func TooManyRequestsResponse

func TooManyRequestsResponse(c *gin.Context, message string)

TooManyRequestsResponse 429 请求过多响应

func UnauthorizedResponse

func UnauthorizedResponse(c *gin.Context, message string)

UnauthorizedResponse 401 未授权响应

Types

type PaginationParams

type PaginationParams struct {
	Page     int
	PageSize int
}

PaginationParams 分页参数

Jump to

Keyboard shortcuts

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