Documentation
¶
Index ¶
- Variables
- func AppendController(c Controller)
- func Error(c *gin.Context, code int, err error, msg ...string)
- func GetRequestLogger(c *gin.Context) *logger.Helper
- func OK(c *gin.Context, data interface{}, msg ...string)
- func PageOK(c *gin.Context, result interface{}, count int64, pageIndex int64, ...)
- type Api
- func (e *Api) AddError(err error)
- func (e *Api) Bind(d interface{}, bindings ...binding.Binding) *Api
- func (*Api) Create(c *gin.Context)
- func (*Api) Delete(c *gin.Context)
- func (e Api) Err(code int, err error, msg ...string)
- func (*Api) Get(c *gin.Context)
- func (*Api) Handlers() []gin.HandlerFunc
- func (*Api) List(c *gin.Context)
- func (e *Api) Make(c *gin.Context) *Api
- func (e Api) OK(data interface{}, msg ...string)
- func (*Api) Other(_ *gin.RouterGroup)
- func (e Api) PageOK(result interface{}, count int64, pageIndex int64, pageSize int64, ...)
- func (*Api) Path() string
- func (e *Api) SetEngine(engine *gin.RouterGroup)
- func (*Api) Update(c *gin.Context)
- type Controller
- type DefaultController
- func (e DefaultController) Create(c *gin.Context)
- func (e DefaultController) Delete(c *gin.Context)
- func (e DefaultController) Get(c *gin.Context)
- func (e *DefaultController) Handlers() []gin.HandlerFunc
- func (e DefaultController) List(c *gin.Context)
- func (e *DefaultController) Path() string
- func (e DefaultController) Update(c *gin.Context)
- type Page
- type Response
- type Responses
Constants ¶
This section is empty.
Variables ¶
View Source
var AuthHandler gin.HandlerFunc
View Source
var Controllers = make([]Controller, 0)
Controllers controllers
View Source
var DefaultLanguage = "zh-CN"
Functions ¶
func AppendController ¶
func AppendController(c Controller)
AppendController add controllers to Controllers
func GetRequestLogger ¶
GetRequestLogger 获取上下文提供的日志
Types ¶
type Api ¶
type Api struct {
Context *gin.Context
Log *logger.Helper
Error error
// contains filtered or unexported fields
}
func (*Api) Handlers ¶
func (*Api) Handlers() []gin.HandlerFunc
func (*Api) Other ¶
func (*Api) Other(_ *gin.RouterGroup)
func (Api) PageOK ¶
func (e Api) PageOK(result interface{}, count int64, pageIndex int64, pageSize int64, msg ...string)
PageOK 分页数据处理
func (*Api) SetEngine ¶
func (e *Api) SetEngine(engine *gin.RouterGroup)
type Controller ¶
type Controller interface {
// Path http path
Path() string
// Handlers middlewares
Handlers() []gin.HandlerFunc
// Create create
Create(*gin.Context)
// Update update
Update(*gin.Context)
// Delete delete
Delete(*gin.Context)
// Get get
Get(*gin.Context)
// List list
List(*gin.Context)
// Other other
Other(*gin.RouterGroup)
}
Controller controllers
type DefaultController ¶
type DefaultController struct {
Api
TableName string
Auth bool
CreateReq interface{}
UpdateReq interface{}
DeleteReq interface{}
GetReq interface{}
GetResp interface{}
ListReq interface{}
ListResp interface{}
}
func (DefaultController) Create ¶
func (e DefaultController) Create(c *gin.Context)
func (DefaultController) Delete ¶
func (e DefaultController) Delete(c *gin.Context)
func (DefaultController) Get ¶
func (e DefaultController) Get(c *gin.Context)
func (*DefaultController) Handlers ¶
func (e *DefaultController) Handlers() []gin.HandlerFunc
func (DefaultController) List ¶
func (e DefaultController) List(c *gin.Context)
func (*DefaultController) Path ¶
func (e *DefaultController) Path() string
func (DefaultController) Update ¶
func (e DefaultController) Update(c *gin.Context)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.