Documentation ¶
Index ¶
- Constants
- Variables
- func GetBody(c *gin.Context) []byte
- func GetToken(c *gin.Context) string
- func GetUserID(c *gin.Context) string
- func NewRouter(o *Options, logger *zap.Logger, init InitControllers, ...) *gin.Engine
- func NoMethodHandler() gin.HandlerFunc
- func NoRouteHandler() gin.HandlerFunc
- func ParseForm(c *gin.Context, obj interface{}) error
- func ParseJSON(c *gin.Context, obj interface{}) error
- func ParseQuery(c *gin.Context, obj interface{}) error
- func ResError(c *gin.Context, err error, status ...int)
- func ResJSON(c *gin.Context, status int, v interface{})
- func ResList(c *gin.Context, v interface{})
- func ResOK(c *gin.Context)
- func ResPage(c *gin.Context, v interface{}, pr *PaginationResult)
- func ResSuccess(c *gin.Context, v interface{})
- func SetUserID(c *gin.Context, userID string)
- type ErrorItem
- type ErrorResult
- type IDResult
- type InitControllers
- type ListResult
- type Options
- type OrderDirection
- type OrderField
- type PaginationParam
- type PaginationResult
- type Server
- type StatusResult
- type StatusText
Constants ¶
View Source
const ( UserIDKey = prefix + "/user-id" ReqBodyKey = prefix + "/req-body" ResBodyKey = prefix + "/res-body" LoggerReqBodyKey = prefix + "/logger-req-body" )
定义上下文中的键
Variables ¶
View Source
var ProviderSet = wire.NewSet(New, NewRouter, NewOptions)
Functions ¶
Types ¶
type ErrorResult ¶
type ErrorResult struct {
Error ErrorItem `json:"error"` // 错误项
}
ErrorResult 响应错误
type InitControllers ¶
type ListResult ¶
type ListResult struct { List interface{} `json:"list"` Pagination *PaginationResult `json:"pagination,omitempty"` }
ListResult 响应列表数据
type OrderDirection ¶
type OrderDirection int
OrderDirection 排序方向
const ( // OrderByASC 升序排序 OrderByASC OrderDirection = 1 // OrderByDESC 降序排序 OrderByDESC OrderDirection = 2 )
type OrderField ¶
type OrderField struct { Key string // 字段名(字段名约束为小写蛇形) Direction OrderDirection // 排序方向 }
OrderField 排序字段
func NewOrderField ¶
func NewOrderField(key string, d OrderDirection) *OrderField
NewOrderField 创建排序字段
func NewOrderFieldWithKeys ¶
func NewOrderFieldWithKeys(keys []string, directions ...map[int]OrderDirection) []*OrderField
NewOrderFieldWithKeys 创建排序字段(默认升序排序),可指定不同key的排序规则 keys 需要排序的key directions 排序规则,按照key的索引指定,索引默认从0开始
func NewOrderFields ¶
func NewOrderFields(orderFields ...*OrderField) []*OrderField
NewOrderFields 创建排序字段列表
type PaginationParam ¶
type PaginationParam struct { Pagination bool `form:"-"` // 是否使用分页查询 OnlyCount bool `form:"-"` // 是否仅查询count Current uint `form:"current,default=1"` // 当前页 PageSize uint `form:"pageSize,default=10" binding:"max=100"` // 页大小 }
PaginationParam 分页查询条件
type PaginationResult ¶
type PaginationResult struct { Total int `json:"total"` Current uint `json:"current"` PageSize uint `json:"pageSize"` }
PaginationResult 分页查询结果
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Application ¶
type StatusResult ¶
type StatusResult struct {
Status StatusText `json:"status"` // 状态(OK)
}
StatusResult 响应状态
type StatusText ¶
type StatusText string
StatusText 定义状态文本
const ( OKStatus StatusText = "OK" ErrorStatus StatusText = "ERROR" FailStatus StatusText = "FAIL" )
定义HTTP状态文本常量
func (StatusText) String ¶
func (t StatusText) String() string
Click to show internal directories.
Click to hide internal directories.