Documentation ¶
Index ¶
- Variables
- func AddPermissionsByList(permissions []Permission) error
- func Count(obj interface{}) (int64, error)
- func CreateEngine(cfg *config.Config) (engine *xorm.Engine, err error)
- func CreateUser(user *User) error
- func Delete(obj interface{}) error
- func DeleteById(id int64, obj interface{}) error
- func EnableCache() error
- func Engine() *xorm.Engine
- func Find(limit, start int, objs interface{}) error
- func Get(obj interface{}) error
- func GetById(id int64, obj interface{}) error
- func InitDefaultData() error
- func Insert(obj interface{}) error
- func IsEmailUsed(email string) bool
- func IsExist(obj interface{}) bool
- func IsUserNameExist(username string) bool
- func IsValidUserName(name string) error
- func SyncTables() error
- func UpdateById(id int64, obj interface{}, cols ...string) error
- type File
- type Login
- type Permission
- type PermissionRole
- type QueryResult
- type Role
- func (r *Role) AddPermissionsByIds(ids ...string) error
- func (r *Role) AddUser(user *User) error
- func (r *Role) AddUserByIds(ids ...int64) error
- func (r *Role) CheckValid() error
- func (r *Role) Delete() error
- func (r *Role) DeletePermissions(ids ...string) error
- func (r *Role) DeleteUserByIds(ids ...int64) error
- func (r *Role) IsGranted(permission *Permission) bool
- func (r *Role) IsGrantedById(permissionId string) bool
- func (r *Role) Permissions() (*[]Permission, error)
- func (r *Role) Users() (*[]User, error)
- type RoleUser
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotExist = errors.New("not exist")
)
View Source
var (
ErrPasswordNotMatch = errors.New("The password not matched")
)
Functions ¶
func AddPermissionsByList ¶
func AddPermissionsByList(permissions []Permission) error
func CreateUser ¶
func DeleteById ¶
func InitDefaultData ¶
func InitDefaultData() error
func UpdateById ¶
Types ¶
type File ¶
type File struct { Id int64 `json:"id"` Key string `json:key xorm:"UNIQUE NOT NULL"` Path string `json:"path"` Name string `json:"name"` Ext string `json:"ext"` Size int `json:"size"` UserId int64 `json:"user_id"` CreatedAt time.Time `xorm:"created" json:"created_at"` UpdatedAt time.Time `xorm:"updated" json:"updated_at"` URL string `xorm:"-" json:"url"` }
func (*File) CheckValid ¶
type Permission ¶
type Permission struct { Id string `xorm:"pk" json:"id"` Name string `json:"name"` Group string `json:"group"` CreatedAt time.Time `xorm:"created" json:"created_at"` UpdatedAt time.Time `xorm:"updated" json:"updated_at"` }
func (*Permission) AddRoles ¶
func (p *Permission) AddRoles(roles []*Role) error
func (*Permission) AddRolesByIds ¶
func (p *Permission) AddRolesByIds(ids []int64) error
func (*Permission) Roles ¶
func (p *Permission) Roles() (roles []*Role, err error)
type PermissionRole ¶
type QueryResult ¶
type QueryResult struct { Page int `json:"page"` PageSize int `json:"pagesize"` TotalRecord int64 `json:"total_record"` Data interface{} `json:"data"` }
func NewQueryResult ¶
func NewQueryResult(page int, pagesize int, total int64, data interface{}) *QueryResult
type Role ¶
type Role struct { Id int64 Name string `xorm:"UNIQUE NOT NULL"` UserId int64 `json:"user_id"` Description string CreatedAt time.Time `xorm:"created" json:"created_at"` UpdatedAt time.Time `xorm:"updated" json:"updated_at"` }
func (*Role) AddPermissionsByIds ¶
func (*Role) AddUserByIds ¶
func (*Role) CheckValid ¶
func (*Role) DeletePermissions ¶
func (*Role) DeleteUserByIds ¶
func (*Role) IsGranted ¶
func (r *Role) IsGranted(permission *Permission) bool
func (*Role) IsGrantedById ¶
func (*Role) Permissions ¶
func (r *Role) Permissions() (*[]Permission, error)
---- permissions ----
type User ¶
type User struct { Id int64 `json:"id"` Nickname string `json:"nickname"` Username string `xorm:"UNIQUE NOT NULL" json:"username"` Password string `xorm:"NOT NULL" json:"-"` Email string `xorm:"UNIQUE NOT NULL" json:"email"` // Permissions IsActive bool `json:"is_active"` IsAdmin bool `json:"is_admin"` // 头像 Avatar string `xorm:"VARCHAR(1024)" json:"avatar"` CreatedAt time.Time `xorm:"created" json:"created_at"` UpdatedAt time.Time `xorm:"updated" json:"updated_at"` DeletedAt time.Time `xorm:"deleted" json:"-"` Token string `xorm:"-" json:"token,omitempty"` ExpiredIn int64 `xorm:"-" json:"expired_in,omitempty"` }
func (*User) CheckValid ¶
func (*User) EncodePassword ¶
func (*User) IsValidPassword ¶
compare user password
Click to show internal directories.
Click to hide internal directories.