Documentation ¶
Index ¶
- Variables
- type AuthToken
- type Logger
- type Pagination
- type PaginationReq
- type RefreshToken
- type ReqCreateRole
- type ReqCreateRoles
- type ReqCreateUser
- type ReqMenu
- type ReqRole
- type ReqUpdateUser
- type ReqUser
- type RespMenu
- type RespMenuResource
- type RespMenuResources
- type RespRole
- type RespRoleMenu
- type RespRoleMenus
- type RespUser
- type SMenu
- type SMenuResource
- type SMenuResources
- type SRole
- type SRoleMenu
- type SRoleMenus
- type SUser
- type SUserRole
- type SUserRoles
Constants ¶
This section is empty.
Variables ¶
var ( // ErrGeneric is used for testing purposes and for errors handled later in the callstack ErrGeneric = errors.New("generic error") // ErrBadRequest (400) is returned for bad request (validation) ErrBadRequest = echo.NewHTTPError(400) ErrUnauthorized = echo.ErrUnauthorized )
Functions ¶
This section is empty.
Types ¶
type AuthToken ¶
type AuthToken struct { Token string `json:"token"` Expires string `json:"expires"` RefreshToken string `json:"refresh_token"` }
AuthToken holds authentication token details with refresh token
type Logger ¶
type Logger interface { // source, msg, error, params Log(echo.Context, string, string, error, map[string]interface{}) }
Logger represents logging interface
type Pagination ¶
Pagination holds paginations data
type PaginationReq ¶
PaginationReq holds pagination http fields and tags
func (*PaginationReq) Transform ¶
func (p *PaginationReq) Transform() *Pagination
Transform checks and converts http pagination into database pagination model
func (*PaginationReq) TransformMS ¶
func (p *PaginationReq) TransformMS() *Pagination
type RefreshToken ¶
RefreshToken holds authentication token details
type ReqCreateRole ¶
type ReqCreateRole struct {
Roleid string `json:"roleid" gorm:"type:varchar(40)"`
}
ReqCreateRole ReqCreateRole
func (*ReqCreateRole) ToSchemaSUserRole ¶
func (c *ReqCreateRole) ToSchemaSUserRole(userid string) *SUserRole
ToSchemaSUserRole ToSchemaSUserRole
type ReqCreateUser ¶
type ReqCreateUser struct { Recid string `json:"recid" validate:"required"` Code string `json:"code" validate:"required"` Name string `json:"name" validate:"required,min=3,alphanum"` NickName string `json:"nick_name" ` Password string `json:"password" validate:"required,min=4"` PasswordConfirm string `json:"password_confirm" validate:"required,min=4"` Email string `json:"email"` Mobile string `json:"mobile"` Phone string `json:"phone"` Address string `json:"address"` Active bool `json:"active" validate:"required"` Roles ReqCreateRoles `json:"roles" validate:"required"` }
ReqCreateUser ReqCreateUser
func (*ReqCreateUser) ToSchemaSUser ¶
func (c *ReqCreateUser) ToSchemaSUser() *SUser
ToSchemaSUser ToSchemaSUser
func (*ReqCreateUser) ToSchemaSUserRoles ¶
func (c *ReqCreateUser) ToSchemaSUserRoles() []*SUserRole
ToSchemaSUserRoles ToSchemaSUserRoles
type ReqMenu ¶
type ReqMenu struct { PaginationReq Code string `json:"code" validate:"omitempty"` Name string `json:"name" validate:"omitempty"` Router string `json:"router" validate:"omitempty"` Parentid string `json:"parentid" validate:"omitempty"` Hidden int `json:"hidden" validate:"isdefault=-1,min=-1,max=1,omitempty"` }
ReqMenu query 时的QueryParams
type ReqRole ¶
type ReqRole struct { PaginationReq Code string `json:"code" validate:"omitempty"` Name string `json:"name" validate:"omitempty"` }
ReqRole request role
type ReqUpdateUser ¶
type ReqUpdateUser struct { Recid string `json:"recid" validate:"required"` Code string `json:"code" validate:"required"` Name string `json:"name" validate:"required,min=3,alphanum"` NickName string `json:"nick_name" ` Email string `json:"email"` Mobile string `json:"mobile"` Phone string `json:"phone"` Address string `json:"address"` Active bool `json:"active" validate:"required"` Roles ReqCreateRoles `json:"roles" validate:"required"` }
ReqUpdateUser ReqUpdateUser
func (*ReqUpdateUser) ToSchemaSUser ¶
func (c *ReqUpdateUser) ToSchemaSUser() *SUser
ToSchemaSUser ToSchemaSUser
func (*ReqUpdateUser) ToSchemaSUserRoles ¶
func (c *ReqUpdateUser) ToSchemaSUserRoles() []*SUserRole
ToSchemaSUserRoles ToSchemaSUserRoles
type ReqUser ¶
type ReqUser struct { PaginationReq Code string `json:"code" validate:"omitempty"` Name string `json:"name" validate:"omitempty"` }
ReqUser request user
type RespMenu ¶
type RespMenu struct { Recid string `json:"recid" validate:"required"` Code string `json:"code" validate:"required"` Name string `json:"name" validate:"required"` Seq string `json:"seq" validate:"required"` Icon string `json:"icon" validate:"required"` Router string `json:"router" validate:"required"` Parentid string `json:"parentid" validate:"omitempty"` Hidden bool `json:"hidden" validate:"omitempty"` Usercode string `json:"usercode" validate:"required"` Resources RespMenuResources }
RespMenu RespMenu
func (*RespMenu) ToSchemaMenuResources ¶
func (m *RespMenu) ToSchemaMenuResources() SMenuResources
ToSchemaMenuResources ToSchemaMenuResources
type RespMenuResource ¶
type RespMenuResource struct { Code string `json:"code" validate:"required"` Name string `json:"name" validate:"required"` Method string `json:"method" validate:"required"` Path string `json:"path" validate:"required"` }
RespMenuResource RespMenuResource
func (*RespMenuResource) ToSchemaMenuResource ¶
func (m *RespMenuResource) ToSchemaMenuResource(menuid string) *SMenuResource
ToSchemaMenuResource ToSchemaMenuResource
type RespMenuResources ¶
type RespMenuResources []*RespMenuResource
RespMenuResources RespMenuResources
type RespRole ¶
type RespRole struct { ID uint `gorm:"primary_key"` CreatedAt time.Time UpdatedAt time.Time Recid string `json:"recid" gorm:"type:varchar(40);not null;unique"` Code string `json:"code" gorm:"type:varchar(50);not null;unique"` Name string `json:"name" gorm:"type:varchar(50);not null;unique"` Seq string `json:"seq" gorm:"type:varchar(10)"` Usercode string `json:"usercode" gorm:"type:varchar(40)"` Menus RespRoleMenus `json:"menus"` }
RespRole 返回
func (RespRole) ToSchemaRoleMenus ¶
ToSchemaRoleMenus dToSchemaRoleMenu
type RespRoleMenu ¶
type RespRoleMenu struct { Menuid string `json:"menuid" gorm:"type:varchar(40)"` Resources []string }
RespRoleMenu 返回
func (*RespRoleMenu) ToSchemaRoleMenu ¶
func (a *RespRoleMenu) ToSchemaRoleMenu(roleID string) SRoleMenu
ToSchemaRoleMenu ToSchemaRoleMenu
type SMenu ¶
type SMenu struct { gorm.Model Recid string `json:"recid" gorm:"type:varchar(40);not null;unique"` Code string `json:"code" gorm:"type:varchar(50);not null;unique"` Name string `json:"name" gorm:"type:varchar(50);not null;unique"` Seq string `json:"seq" gorm:"type:varchar(10)"` Icon string `json:"icon" gorm:"type:varchar(20)"` Router string `json:"router" gorm:"type:varchar(50)"` Parentid string `json:"parentid" gorm:"type:varchar(40)"` Hidden bool `json:"hidden"` Usercode string `json:"usercode" gorm:"type:varchar(40)"` }
SMenu 菜单
type SMenuResource ¶
type SMenuResource struct { gorm.Model Menuid string `json:"menuid" gorm:"type:varchar(40)"` Code string `json:"code" gorm:"type:varchar(50)"` Name string `json:"name" gorm:"type:varchar(50)"` Method string `json:"method" gorm:"type:varchar(50)"` Path string `json:"path" gorm:"type:varchar(50)"` }
SMenuResource 菜单
type SMenuResources ¶
type SMenuResources []*SMenuResource
SMenuResources SMenuResources
func (*SMenuResources) ToRespResource ¶
func (s *SMenuResources) ToRespResource() RespMenuResources
ToRespResource ToRespResource
type SRole ¶
type SRole struct { gorm.Model Recid string `json:"recid" gorm:"type:varchar(40);not null;unique"` Code string `json:"code" gorm:"type:varchar(50);not null;unique"` Name string `json:"name" gorm:"type:varchar(50);not null;unique"` Seq string `json:"seq" gorm:"type:varchar(10)"` Usercode string `json:"usercode" gorm:"type:varchar(40)"` }
SRole 角色
type SRoleMenu ¶
type SRoleMenu struct { gorm.Model Roleid string `json:"roleid" gorm:"type:varchar(40)"` Menuid string `json:"menuid" gorm:"type:varchar(40)"` Resource string }
SRoleMenu 角色对应的
func (*SRoleMenu) ToRespondRoleMenu ¶
func (a *SRoleMenu) ToRespondRoleMenu() *RespRoleMenu
ToRespondRoleMenu 转换为角色菜单对象
type SRoleMenus ¶
type SRoleMenus []SRoleMenu
SRoleMenus SRoleMenus
func (SRoleMenus) ToRespondRoleMenus ¶
func (a SRoleMenus) ToRespondRoleMenus() []*RespRoleMenu
ToRespondRoleMenus 转换为角色菜单对象列表
type SUser ¶
type SUser struct { gorm.Model Recid string `json:"recid" gorm:"type:varchar(40);not null;unique"` Code string `json:"code" gorm:"type:varchar(50);not null;unique"` Name string `json:"name" gorm:"type:varchar(50);not null;unique"` NickName string `json:"nick_name" gorm:"type:varchar(50)"` Password string `json:"-"` Email string `json:"email"` Mobile string `json:"mobile"` Phone string `json:"phone"` Address string `json:"address"` Active bool `json:"active"` LastLogin time.Time `json:"last_login" ` LastPasswordChange time.Time `json:"last_password_change"` Token string `json:"-"` }
SUser 用户
func (*SUser) ChangePassword ¶
ChangePassword updates user's password related fields
func (*SUser) UpdateLastLogin ¶
UpdateLastLogin updates last login field