Documentation ¶
Index ¶
- Variables
- func BuildErrorResponse(context *gin.Context, data interface{})
- func BuildExcelExport(ctx *gin.Context, headers HeaderList, dataList interface{}, fileName string) (err error)
- func BuildExceptionResponse(context *gin.Context, res ErrEnum, data interface{})
- func BuildFailResponse(context *gin.Context, data interface{})
- func BuildFileResponse(context *gin.Context, filePath string)
- func BuildResponse(context *gin.Context, code int, message string, data interface{})
- func BuildSuccessResponse(context *gin.Context, data interface{})
- type ErrEnum
- type Header
- type HeaderList
- type PageResponse
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // 应用错误 Success = ErrEnum{Code: 2000, Msg: "服务响应成功"} Error = ErrEnum{Code: 5000, Msg: "服务响应异常"} Fail = ErrEnum{Code: 4000, Msg: "服务请求失败"} ParamErr = ErrEnum{Code: 2001, Msg: "请求参数异常"} DuplicateErr = ErrEnum{Code: 2002, Msg: "重复性校验未通过"} // 业务错误 UserAuthError = ErrEnum{Code: 1001, Msg: "账号鉴权失败"} UserPasswordErr = ErrEnum{Code: 1002, Msg: "账号密码错误"} // 组件错误 DBSelectErr = ErrEnum{Code: 6001, Msg: "数据库查询异常"} DBInsertErr = ErrEnum{Code: 6002, Msg: "数据库写入异常"} DBUpdateErr = ErrEnum{Code: 6003, Msg: "数据库更新异常"} DBDeleteErr = ErrEnum{Code: 6004, Msg: "数据库删除异常"} RedisGetNil = ErrEnum{Code: 6101, Msg: "redis: nil"} )
常用异常
Functions ¶
func BuildExcelExport ¶
func BuildExcelExport(ctx *gin.Context, headers HeaderList, dataList interface{}, fileName string) (err error)
Gin框架返回Excel文件流
func BuildExceptionResponse ¶
异常响应
func BuildResponse ¶
自定义响应
Types ¶
type PageResponse ¶
type PageResponse struct { CurrPage int64 `json:"currPage" comment:"当前页码"` PageSize int64 `json:"pageSize" comment:"当前页数量"` PageTotal int64 `json:"pageTotal" comment:"总页数"` ResultTotal int64 `json:"resultTotal" comment:"结果总数量"` ResultList interface{} `json:"resultList" comment:"返回结果集"` }
分页结果
func BuildPageData ¶
func BuildPageData(param *request.Page, result interface{}, total int64) *PageResponse
封装分页结果
Click to show internal directories.
Click to hide internal directories.