Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - type Base
 - type MenuModel
 - func (t MenuModel) AddRole(roleId string) (int64, error)
 - func (t MenuModel) CheckRole(roleId string) bool
 - func (t MenuModel) Delete()
 - func (t MenuModel) DeleteRoles() error
 - func (t MenuModel) Find(id interface{}) MenuModel
 - func (t MenuModel) MapToModel(m map[string]interface{}) MenuModel
 - func (t MenuModel) New(title, icon, uri, header, pluginName string, parentId, order int64) (MenuModel, error)
 - func (t MenuModel) ResetOrder(data []byte)
 - func (t MenuModel) SetConn(con db.Connection) MenuModel
 - func (t MenuModel) Update(title, icon, uri, header, pluginName string, parentId int64) (int64, error)
 
- type OperationLogModel
 - func (t OperationLogModel) Find(id interface{}) OperationLogModel
 - func (t OperationLogModel) MapToModel(m map[string]interface{}) OperationLogModel
 - func (t OperationLogModel) New(userId int64, path, method, ip, input string) OperationLogModel
 - func (t OperationLogModel) SetConn(con db.Connection) OperationLogModel
 
- type OrderItem
 - type OrderItems
 - type PermissionModel
 - func (t PermissionModel) Find(id interface{}) PermissionModel
 - func (t PermissionModel) FindByName(name string) PermissionModel
 - func (t PermissionModel) FindBySlug(slug string) PermissionModel
 - func (t PermissionModel) IsEmpty() bool
 - func (t PermissionModel) IsSlugExist(slug string, id string) bool
 - func (t PermissionModel) MapToModel(m map[string]interface{}) PermissionModel
 - func (t PermissionModel) SetConn(con db.Connection) PermissionModel
 
- type RoleModel
 - func (t RoleModel) AddPermission(permissionId string) (int64, error)
 - func (t RoleModel) CheckPermission(permissionId string) bool
 - func (t RoleModel) DeletePermissions() error
 - func (t RoleModel) Find(id interface{}) RoleModel
 - func (t RoleModel) IsSlugExist(slug string, id string) bool
 - func (t RoleModel) MapToModel(m map[string]interface{}) RoleModel
 - func (t RoleModel) New(name, slug string) (RoleModel, error)
 - func (t RoleModel) SetConn(con db.Connection) RoleModel
 - func (t RoleModel) Update(name, slug string) (int64, error)
 - func (t RoleModel) WithTx(tx *sql.Tx) RoleModel
 
- type SiteModel
 - func (t SiteModel) AllToMap() map[string]string
 - func (t SiteModel) AllToMapInterface() map[string]interface{}
 - func (t SiteModel) Init(cfg map[string]string) SiteModel
 - func (t SiteModel) SetConn(con db.Connection) SiteModel
 - func (t SiteModel) Update(v form.Values) error
 - func (t SiteModel) WithTx(tx *sql.Tx) SiteModel
 
- type UserModel
 - func (t UserModel) AddPermission(permissionId string) (int64, error)
 - func (t UserModel) AddRole(roleId string) (int64, error)
 - func (t UserModel) CheckPermission(permission string) bool
 - func (t UserModel) CheckPermissionById(permissionId string) bool
 - func (t UserModel) CheckPermissionByUrlMethod(path, method string, formParams url.Values) bool
 - func (t UserModel) CheckRole(slug string) bool
 - func (t UserModel) CheckRoleId(roleId string) bool
 - func (t UserModel) DeletePermissions() error
 - func (t UserModel) DeleteRoles() error
 - func (t UserModel) Find(id interface{}) UserModel
 - func (t UserModel) FindByUserName(username interface{}) UserModel
 - func (t UserModel) GetAllRoleId() []interface{}
 - func (t UserModel) GetCheckPermissionByUrlMethod(path, method string) string
 - func (t UserModel) HasMenu() bool
 - func (t UserModel) HideUserCenterEntrance() bool
 - func (t UserModel) IsEmpty() bool
 - func (t UserModel) IsSuperAdmin() bool
 - func (t UserModel) IsVisitor() bool
 - func (t UserModel) MapToModel(m map[string]interface{}) UserModel
 - func (t UserModel) New(username, password, name, avatar string) (UserModel, error)
 - func (t UserModel) ReleaseConn() UserModel
 - func (t UserModel) SetConn(con db.Connection) UserModel
 - func (t UserModel) Template(str string) string
 - func (t UserModel) Update(username, password, name, avatar string, isUpdateAvatar bool) (int64, error)
 - func (t UserModel) UpdateAvatar(avatar string)
 - func (t UserModel) UpdatePwd(password string) UserModel
 - func (t UserModel) WithMenus() UserModel
 - func (t UserModel) WithPermissions() UserModel
 - func (t UserModel) WithRoles() UserModel
 - func (t UserModel) WithTx(tx *sql.Tx) UserModel
 
Constants ¶
const ( SiteItemOpenState = 1 SiteItemOffState = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct {
	TableName string
	Conn db.Connection
	Tx   *sql.Tx
}
    Base is base model structure.
type MenuModel ¶
type MenuModel struct {
	Base
	Id        int64
	Title     string
	ParentId  int64
	Icon      string
	Uri       string
	Header    string
	CreatedAt string
	UpdatedAt string
}
    MenuModel is menu model structure.
func MenuWithId ¶
MenuWithId return a default menu model of given id.
func (MenuModel) DeleteRoles ¶
DeleteRoles delete roles with menu.
func (MenuModel) MapToModel ¶
MapToModel get the menu model from given map.
func (MenuModel) New ¶
func (t MenuModel) New(title, icon, uri, header, pluginName string, parentId, order int64) (MenuModel, error)
New create a new menu model.
func (MenuModel) ResetOrder ¶
ResetOrder update the order of menu models.
type OperationLogModel ¶
type OperationLogModel struct {
	Base
	Id        int64
	UserId    int64
	Path      string
	Method    string
	Ip        string
	Input     string
	CreatedAt string
	UpdatedAt string
}
    OperationLogModel is operation log model structure.
func OperationLog ¶
func OperationLog() OperationLogModel
OperationLog return a default operation log model.
func (OperationLogModel) Find ¶
func (t OperationLogModel) Find(id interface{}) OperationLogModel
Find return a default operation log model of given id.
func (OperationLogModel) MapToModel ¶
func (t OperationLogModel) MapToModel(m map[string]interface{}) OperationLogModel
MapToModel get the operation log model from given map.
func (OperationLogModel) New ¶
func (t OperationLogModel) New(userId int64, path, method, ip, input string) OperationLogModel
New create a new operation log model.
func (OperationLogModel) SetConn ¶
func (t OperationLogModel) SetConn(con db.Connection) OperationLogModel
type OrderItem ¶
type OrderItem struct {
	ID       uint       `json:"id"`
	Children OrderItems `json:"children"`
}
    type OrderItems ¶
type OrderItems []OrderItem
type PermissionModel ¶
type PermissionModel struct {
	Base
	Id         int64
	Name       string
	Slug       string
	HttpMethod []string
	HttpPath   []string
	CreatedAt  string
	UpdatedAt  string
}
    PermissionModel is permission model structure.
func PermissionWithId ¶
func PermissionWithId(id string) PermissionModel
PermissionWithId return a default permission model of given id.
func (PermissionModel) Find ¶
func (t PermissionModel) Find(id interface{}) PermissionModel
Find return the permission model of given id.
func (PermissionModel) FindByName ¶
func (t PermissionModel) FindByName(name string) PermissionModel
FindBySlug return the permission model of given slug.
func (PermissionModel) FindBySlug ¶
func (t PermissionModel) FindBySlug(slug string) PermissionModel
FindBySlug return the permission model of given slug.
func (PermissionModel) IsEmpty ¶
func (t PermissionModel) IsEmpty() bool
IsEmpty check the user model is empty or not.
func (PermissionModel) IsSlugExist ¶
func (t PermissionModel) IsSlugExist(slug string, id string) bool
IsSlugExist check the row exist with given slug and id.
func (PermissionModel) MapToModel ¶
func (t PermissionModel) MapToModel(m map[string]interface{}) PermissionModel
MapToModel get the permission model from given map.
func (PermissionModel) SetConn ¶
func (t PermissionModel) SetConn(con db.Connection) PermissionModel
type RoleModel ¶
RoleModel is role model structure.
func RoleWithId ¶
RoleWithId return a default role model of given id.
func (RoleModel) AddPermission ¶
AddPermission add the permissions to the role.
func (RoleModel) CheckPermission ¶
CheckPermission check the permission of role.
func (RoleModel) DeletePermissions ¶
DeletePermissions delete all the permissions of role.
func (RoleModel) IsSlugExist ¶
IsSlugExist check the row exist with given slug and id.
func (RoleModel) MapToModel ¶
MapToModel get the role model from given map.
type SiteModel ¶
type SiteModel struct {
	Base
	Id    int64
	Key   string
	Value string
	Desc  string
	State int64
	CreatedAt string
	UpdatedAt string
}
    SiteModel is role model structure.
func (SiteModel) AllToMapInterface ¶
type UserModel ¶
type UserModel struct {
	Base `json:"-"`
	Id            int64             `json:"id"`
	Name          string            `json:"name"`
	UserName      string            `json:"user_name"`
	Password      string            `json:"password"`
	Avatar        string            `json:"avatar"`
	RememberToken string            `json:"remember_token"`
	Permissions   []PermissionModel `json:"permissions"`
	MenuIds       []int64           `json:"menu_ids"`
	Roles         []RoleModel       `json:"role"`
	Level         string            `json:"level"`
	LevelName     string            `json:"level_name"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
	// contains filtered or unexported fields
}
    UserModel is user model structure.
func UserWithId ¶
UserWithId return a default user model of given id.
func (UserModel) AddPermission ¶
AddPermission add a permission of the user model.
func (UserModel) CheckPermission ¶
CheckPermission check the permission of the user.
func (UserModel) CheckPermissionById ¶
CheckPermission check the permission of the user.
func (UserModel) CheckPermissionByUrlMethod ¶
func (UserModel) CheckRoleId ¶
CheckRole check the role of the user model.
func (UserModel) DeletePermissions ¶
DeletePermissions delete all the permissions of the user model.
func (UserModel) DeleteRoles ¶
DeleteRoles delete all the roles of the user model.
func (UserModel) FindByUserName ¶
FindByUserName return a default user model of given name.
func (UserModel) GetAllRoleId ¶
func (t UserModel) GetAllRoleId() []interface{}
func (UserModel) GetCheckPermissionByUrlMethod ¶
func (UserModel) HideUserCenterEntrance ¶
func (UserModel) IsSuperAdmin ¶
IsSuperAdmin check the user model is super admin or not.
func (UserModel) MapToModel ¶
MapToModel get the user model from given map.
func (UserModel) ReleaseConn ¶
UpdateAvatar update the avatar of user.
func (UserModel) Update ¶
func (t UserModel) Update(username, password, name, avatar string, isUpdateAvatar bool) (int64, error)
Update update the user model.
func (UserModel) UpdateAvatar ¶
UpdateAvatar update the avatar of user.
func (UserModel) WithPermissions ¶
WithPermissions query the permission info of the user.