Documentation ¶
Index ¶
- Variables
- func Error(c *gin.Context, errMsg error, errCode ...int)
- func InitHttp(prefix string) *gin.Engine
- func ParamError(c *gin.Context)
- func RegisterInterceptor(f func(g *gin.Context))
- func RegisterParam(paramName string, f func(g *gin.Context) (string, error))
- func RegisterRouter(f func(g *gin.RouterGroup))
- func Success(c *gin.Context, data ...any)
- func Valid(data interface{}) error
- type AbstractHandler
- type AbstractParser
- type Handler
- type NodeResult
- type PageResponse
- type Parser
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var RequestParam = "request_param"
* gin context全局变量用于存储传参,返回,错误日志
View Source
var ResponseBody = "response_body"
View Source
var ResponseErr = "response_err"
Functions ¶
Types ¶
type AbstractHandler ¶
type AbstractHandler struct { }
func (*AbstractHandler) ContextExec ¶
func (s *AbstractHandler) ContextExec(c *gin.Context) (any, error)
func (*AbstractHandler) ContextHandler ¶
type AbstractParser ¶
type AbstractParser[T Handler] struct { C *gin.Context IsContext bool // contains filtered or unexported fields }
func (*AbstractParser[T]) Form ¶
func (b *AbstractParser[T]) Form(params ...string)
通用从 form 中获取文件或参数并反射到serviceParam中并执行
func (*AbstractParser[T]) Path ¶
func (b *AbstractParser[T]) Path(params ...string)
通用从 param 获取参数传递:url/{id}/{params...}
func (*AbstractParser[T]) Query ¶
func (b *AbstractParser[T]) Query(params ...string)
通用从 Query 获取参数传递:url?id=1
type Handler ¶
type Handler interface { //常规业务函数,返回data Handler(service Handler) (any, error) //将context传递到全局 ContextHandler(c *gin.Context, service Handler) (any, error) //需要重载的接口 Exec() (any, error) ContextExec(c *gin.Context) (any, error) }
对外提供业务服务的handler接口(多态特性)
type NodeResult ¶
type NodeResult[T any] struct { Node T `json:"node"` ChildList []NodeResult[T] `json:"childList"` }
type PageResponse ¶
type PageResponse[T any] struct { Response[T] //当前页 CurrentPage int `json:"currentPage"` //每页数量 PageSize int `json:"pageSize"` //总页数 PageCount int `json:"pageCount"` //总数量 TotalCount int `json:"totalCount"` }
func PageResult ¶
封装分页返回数据
Click to show internal directories.
Click to hide internal directories.