Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitUserModel ¶
InitUserModel initialize the user model with given config
Types ¶
type Group ¶
type Group struct { Model Name string `json:"name" form:"name" validate:"empty=false & format=strict_html"` CodeName string `json:"code_name" json:"code_name" validate:"empty=false & format=slug" gorm:"type:varchar(100);unique_index"` Parent uint `json:"parent" form:"parent"` Roles []*Role `json:"roles_data" gorm:"many2many:group_roles;" validate:"-"` RoleSet []string `json:"roles" form:"roles" gorm:"-"` }
Group group struct
type Model ¶
type Model struct { ID uint `json:"id" gorm:"primary_key"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"deleted_at" sql:"index"` }
Model common model stuff
type Permission ¶
type Permission struct { Model CodeName string `json:"code_name" form:"code_name" validate:"empty=false"` Title string `json:"title" form:"title" validate:"empty=false"` Description string `json:"description" form:"description"` App string `json:"app" form:"app" validate:"empty=false"` }
Permission permission struct
type Permissions ¶
type Permissions []Permission
Permissions slice of permissions
func (Permissions) Sync ¶
func (perms Permissions) Sync(app string)
Sync synchronize permissions on startup
type Role ¶
type Role struct { Model Name string `json:"name" form:"name" validate:"empty=false & format=strict_html"` CodeName string `json:"code_name" json:"code_name" validate:"empty=false & format=slug" gorm:"type:varchar(100);unique_index"` Parent uint `json:"parent" form:"parent"` Groups []*Group `json:"-" gorm:"many2many:group_roles;"` Permission *Permissions `json:"permissions_data" gorm:"-" validate:"-"` PermissionSet []string `json:"permissions" form:"permissions" gorm:"-"` }
Role role struct
func (*Role) SetPermission ¶
func (r *Role) SetPermission(permissions Permissions) error
SetPermission set role permission
type RolePermission ¶
RolePermission role to permission orm
type User ¶
type User struct { Model Name string `json:"name" form:"name"` Username string `json:"username" form:"username" validate:"empty=false | format=username" gorm:"type:varchar(32);unique_index"` Password string `json:"-" form:"-" validate:"empty=false & format=strict_html"` Email string `json:"email" form:"email" validate:"empty=false & format=email" gorm:"type:varchar(32);unique_index"` Roles []*Role `json:"roles" form:"roles" validate:"-"` Group *Group `json:"-" form:"-" gorm:"-" validate:"-"` GroupID uint `json:"group_id" form:"group_id"` Anonymous bool `json:"anonymous" form:"anonymous" gorm:"-"` Active bool `json:"active" form:"active"` Seen time.Time `json:"seen" form:"seen"` Admin bool `json:"admin" form:"admin"` Params data.Map `gorm:"type:json" form:"params" json:"params"` }
User user struct
func (*User) SetPassword ¶
SetPassword set user password
Click to show internal directories.
Click to hide internal directories.