Documentation ¶
Overview ¶
* @Author: Wangjun * @Date: 2021-05-15 22:43:19 * @LastEditTime: 2021-07-20 11:34:01 * @LastEditors: Wangjun * @Description: * @FilePath: \golib\autoroute\controller\auth.go * hnxr
* @Author: Wangjun * @Date: 2021-05-15 22:43:19 * @LastEditTime: 2021-11-25 10:10:14 * @LastEditors: Wangjun * @Description: * @FilePath: \xrcalcd:\go\src\gitee.com\haodreams\golib\autoroute\controller\libs.go * hnxr
* @Author: Wangjun * @Date: 2021-05-15 22:43:19 * @LastEditTime: 2024-04-01 14:04:28 * @LastEditors: wangjun haodreams@163.com * @Description: * @FilePath: \golib\autoroute\controller\param.go * hnxr
Index ¶
- func Error(c *gin.Context, msg string)
- func ErrorWithCode(c *gin.Context, msg string, code int)
- func IsPost(c *gin.Context) bool
- func Msg(c *gin.Context, msg string)
- func SetNeedAuthCallback(cb func(*gin.Context) (interface{}, error))
- type AuthController
- type Controller
- func (m *Controller) AddCookie(name, value string, maxAge int)
- func (m *Controller) Data(data interface{})
- func (m *Controller) DataWithCode(data interface{}, msg string, code ...int)
- func (m *Controller) DataWithMsg(data interface{}, msg string, code ...int)
- func (m *Controller) DataWithStatusCode(data interface{}, msg string, codes ...int)
- func (m *Controller) Display(url ...string)
- func (m *Controller) Error(msg string)
- func (m *Controller) ErrorBad(msg string)
- func (m *Controller) ErrorWithCode(msg string, code int)
- func (m *Controller) GetPage() (page, limit int)
- func (m *Controller) GetPageFromMap(mp map[string]string) (page, limit int)
- func (m *Controller) GetPagePosition(total int) (begin, end int)
- func (m *Controller) GetParam() *Param
- func (m *Controller) IsPost() bool
- func (m *Controller) JSON(code int, obj any)
- func (m *Controller) Msg(msg string)
- func (m *Controller) MsgData(data interface{})
- func (m *Controller) Page(array interface{}, callback func(interface{}) interface{})
- func (m *Controller) PageMapJSON(array interface{}, mp map[string]string, ...) ([]byte, error)
- func (m *Controller) QueryDB(db *gorm.DB, out interface{}, where string)
- func (c *Controller) RecvFile(path string) (size int64, fileName string, err error)
- func (m *Controller) Response(data interface{})
- func (m *Controller) Rows(count int, rows interface{}, msg string, code ...int)
- func (m *Controller) RowsJSON(count int, rows interface{}, msg string, code ...int) ([]byte, error)
- func (m *Controller) Setup(c *gin.Context, controllerName string) (err error)
- type Param
- func (m *Param) GetBool(key string) bool
- func (m *Param) GetFloat(key string) (float64, error)
- func (m *Param) GetInt(key string) (int, error)
- func (m *Param) GetInt64(key string) (int64, error)
- func (m *Param) GetMap() map[string]string
- func (m *Param) GetString(key string) string
- func (m *Param) GetTrimString(key string) string
- func (m *Param) Set(key, value string)
- type RsponseBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetNeedAuthCallback ¶
SetNeedAuthCallback 设置认证回调函数, gin.H
Types ¶
type AuthController ¶
type AuthController struct { Controller Sess *minauth.Session }
AuthController 认证控制器
type Controller ¶
type Controller struct { *gin.Context ControllerName string //控制器名称 ActionName string //事件名称 Map gin.H // contains filtered or unexported fields }
Controller 控制器
func (*Controller) AddCookie ¶
func (m *Controller) AddCookie(name, value string, maxAge int)
AddCookie = SetCookie
func (*Controller) DataWithCode ¶
func (m *Controller) DataWithCode(data interface{}, msg string, code ...int)
DataWithMsg 返回数据包
func (*Controller) DataWithMsg ¶
func (m *Controller) DataWithMsg(data interface{}, msg string, code ...int)
DataWithMsg 返回数据包 Deprecated: this function simply calls DataWithCode
func (*Controller) DataWithStatusCode ¶
func (m *Controller) DataWithStatusCode(data interface{}, msg string, codes ...int)
DataWithMsg 返回数据包,并指定code为返回状态码
func (*Controller) ErrorWithCode ¶
func (m *Controller) ErrorWithCode(msg string, code int)
ErrorWithCode ...
func (*Controller) GetPageFromMap ¶
func (m *Controller) GetPageFromMap(mp map[string]string) (page, limit int)
GetPageFromMap .
func (*Controller) GetPagePosition ¶
func (m *Controller) GetPagePosition(total int) (begin, end int)
GetPagePosition 获取合理的位置 end = 0 表示无效
func (*Controller) JSON ¶
func (m *Controller) JSON(code int, obj any)
func (*Controller) MsgData ¶
func (m *Controller) MsgData(data interface{})
MsgData 正常通知消息 Deprecated: this function simply calls DataWithCode
func (*Controller) Page ¶
func (m *Controller) Page(array interface{}, callback func(interface{}) interface{})
Page 显示指定页面的数据 array 传入指定的数组
func (*Controller) PageMapJSON ¶
func (m *Controller) PageMapJSON(array interface{}, mp map[string]string, callback func(interface{}) interface{}) ([]byte, error)
PageMapJSON .
func (*Controller) QueryDB ¶
func (m *Controller) QueryDB(db *gorm.DB, out interface{}, where string)
QueryDB 查询数据库 根据结构体自动生成 out 是结构体数组的指针 users=make([]*User, 0) out=&users
func (*Controller) RecvFile ¶
func (c *Controller) RecvFile(path string) (size int64, fileName string, err error)
func (*Controller) Rows ¶
func (m *Controller) Rows(count int, rows interface{}, msg string, code ...int)
Rows ... {"code":500,"count":0,"data":[], "msg":"` + emsg + `"}`))
type Param ¶
type Param struct {
// contains filtered or unexported fields
}
Param 自动读取参数
func (*Param) GetTrimString ¶
GetTrimString 获取去掉2边空格后的字符串
type RsponseBody ¶
type RsponseBody struct { Code int `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` }
应答的数据结构