Documentation ¶
Index ¶
- Variables
- func Authenticator(c *gin.Context) (interface{}, error)
- func Authorizator(data interface{}, c *gin.Context) bool
- func LoginLogToDB(c *gin.Context, status string, msg string, username string)
- func LogoutResponse(c *gin.Context, code int)
- func PayloadFunc(data interface{}) jwt.MapClaims
- func Unauthorized(c *gin.Context, code int, message string)
- type Login
- type SysRole
- type SysUser
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidVerificationCode = errors.New("invalid verification code")
Functions ¶
func Authenticator ¶
Authenticator 获取token @Summary 登陆 @Description 获取token @Description LoginHandler can be used by clients to get a jwt token. @Description Payload needs to be json in the form of {"username": "USERNAME", "password": "PASSWORD"}. @Description Reply will be of the form {"token": "TOKEN"}. @Description dev mode:It should be noted that all fields cannot be empty, and a value of 0 can be passed in addition to the account password @Description 注意:开发模式:需要注意全部字段不能为空,账号密码外可以传入0值 @Tags 登陆 @Accept application/json @Product application/json @Param account body Login true "account" @Success 200 {string} string "{"code": 200, "expire": "2019-08-07T12:45:48+08:00", "token": ".eyJleHAiOjE1NjUxNTMxNDgsImlkIjoiYWRtaW4iLCJvcmlnX2lhdCI6MTU2NTE0OTU0OH0.-zvzHvbg0A" }" @Router /api/v1/login [post]
func Authorizator ¶
Authorizator See AuthCheckRole handler
func LoginLogToDB ¶
LoginLogToDB Write log to database
func LogoutResponse ¶
func PayloadFunc ¶
Types ¶
type Login ¶
type SysRole ¶
type SysRole struct { RoleId int `json:"roleId" gorm:"primaryKey;autoIncrement"` // 角色编码 RoleName string `json:"roleName" gorm:"size:128;"` // 角色名称 Status string `json:"status" gorm:"size:4;"` // RoleKey string `json:"roleKey" gorm:"size:128;"` //角色代码 RoleSort int `json:"roleSort" gorm:""` //角色排序 Flag string `json:"flag" gorm:"size:128;"` // Remark string `json:"remark" gorm:"size:255;"` //备注 DataScope string `json:"dataScope" gorm:"size:8;"` Params string `json:"params" gorm:"-"` MenuIds []int `json:"menuIds" gorm:"-"` DeptIds []int `json:"deptIds" gorm:"-"` models.ControlBy models.ModelTime }
type SysUser ¶
type SysUser struct { UserId int `gorm:"primaryKey;autoIncrement;comment:编码" json:"userId"` Username string `json:"username" gorm:"size:64;comment:用户名"` Password string `json:"-" gorm:"size:128;comment:密码"` NickName string `json:"nickName" gorm:"size:128;comment:昵称"` Phone string `json:"phone" gorm:"size:11;comment:手机号"` RoleId int `json:"roleId" gorm:"size:20;comment:角色ID"` Salt string `json:"-" gorm:"size:255;comment:加盐"` Avatar string `json:"avatar" gorm:"size:255;comment:头像"` Sex string `json:"sex" gorm:"size:255;comment:性别"` Email string `json:"email" gorm:"size:128;comment:邮箱"` DeptId int `json:"deptId" gorm:"size:20;comment:部门"` PostId int `json:"postId" gorm:"size:20;comment:岗位"` Remark string `json:"remark" gorm:"size:255;comment:备注"` Status string `json:"status" gorm:"size:4;comment:状态"` DeptIds []int `json:"deptIds" gorm:"-"` PostIds []int `json:"postIds" gorm:"-"` RoleIds []int `json:"roleIds" gorm:"-"` //Dept *SysDept `json:"dept"` models.ControlBy models.ModelTime }