Documentation ¶
Index ¶
- Variables
- func AddRoleResource(ctx *models.Context, roleId int, resourcesIds []int) error
- func CreateAppDefaultRole(ctx *models.Context, appId int, roleName string, fullName string) (*app.App, error)
- func CreateResources(ctx *models.Context, resources []Resource) error
- func DeleteAppRole(ctx *models.Context, appId int) (*app.App, error)
- func DeleteResource(ctx *models.Context, id int) error
- func DeleteResources(ctx *models.Context, ids []int) error
- func DeleteRole(ctx *models.Context, id int) error
- func GetRoleIdByName(ctx *models.Context, name string, appId int) (int, error)
- func InitDatabase(ctx *models.Context)
- func IsLeafRole(ctx *models.Context, roleId int) bool
- func IsOffspring(ctx *models.Context, roleId int, queryId int) (bool, error)
- func IsUserInAppAdminRole(ctx *models.Context, user iuser.User, appId int) (bool, group.MemberRole)
- func IsUserInRole(ctx *models.Context, user iuser.User, role *Role) (bool, group.MemberRole)
- func RemoveRoleResource(ctx *models.Context, roleId int, resourceIds []int) error
- func SetAppRole(ctx *models.Context, roleId int, appId int) (*app.App, error)
- func UpdateResources(ctx *models.Context, resources []Resource) error
- func UpdateRoleResource(ctx *models.Context, roleId int, resourcesIds []int) error
- type Resource
- func CreateResource(ctx *models.Context, resource *Resource) (*Resource, error)
- func GetAllResources(ctx *models.Context, appId int) ([]Resource, error)
- func GetResource(ctx *models.Context, id int) (*Resource, error)
- func GetResources(ctx *models.Context, appId int, user iuser.User) ([]Resource, error)
- func GetResourcesByIds(ctx *models.Context, ids []int) ([]Resource, error)
- func GetResourcesByRoleId(ctx *models.Context, roleId int) ([]Resource, error)
- func GetResourcesByRoleIds(ctx *models.Context, roleIds []int) ([]Resource, error)
- func UpdateResource(ctx *models.Context, id int, name string, desc string, data string) (*Resource, error)
- type Role
- func CreateRoleWithGroup(ctx *models.Context, roleName string, fullName string, appId int, groupId int) (*Role, error)
- func CreateRoleWithoutGroup(ctx *models.Context, roleName string, fullName string, appId int, superId int) (*Role, error)
- func GetAppAdminRole(ctx *models.Context, appId int) (*Role, error)
- func GetDirectRoles(ctx *models.Context, user iuser.User, appId int) ([]*Role, error)
- func GetRole(ctx *models.Context, id int) (*Role, error)
- func GetRoles(ctx *models.Context, username string, appId int) ([]Role, error)
- func GetRolesByAppId(ctx *models.Context, appId int) ([]Role, error)
- func GetRolesByGroupIds(ctx *models.Context, groupIds []int) ([]Role, error)
- func GetSubTreeRoles(ctx *models.Context, roleId int) ([]*Role, error)
- func UpdateRole(ctx *models.Context, id int, name string, fullname string, parent int) (*Role, error)
- type RoleMembers
- type RoleResources
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRoleNotFound = errors.New("role not found") ErrLeafRoleHasNoSubRole = errors.New("leaf role has no subrole") ErrRootRoleHasNoParent = errors.New("can't set root role's parent") ErrRootRoleCannotBeDeleted = errors.New("can't delete root role") )
View Source
var (
ErrAppHasNoRole = errors.New("app has no admin role")
)
Functions ¶
func AddRoleResource ¶
func CreateAppDefaultRole ¶
func GetRoleIdByName ¶
func InitDatabase ¶
func IsUserInAppAdminRole ¶
func IsUserInRole ¶
func RemoveRoleResource ¶
Types ¶
type Resource ¶
type Resource struct { Id int `json:"id"` Name string `json:"name"` Description string `db:"fullname" json:"description"` AppId int `db:"app_id" json:"app_id"` Data string `json:"data"` Owner string `json:"owner"` Created string `json:"created"` Updated string `json:"updated"` }
func CreateResource ¶
func GetResources ¶
func GetResourcesByRoleId ¶
func GetResourcesByRoleIds ¶
type Role ¶
type Role struct { Id int `json:"id"` Name string `json:"name"` FullName string `json:"description"` SuperRoleId int `db:"super_id" json:"parent_id"` AppId int `db:"app_id" json:"app_id"` Created string `json:"created"` Updated string `json:"updated"` }
func CreateRoleWithGroup ¶
func CreateRoleWithoutGroup ¶
func GetDirectRoles ¶
func GetRolesByGroupIds ¶
type RoleMembers ¶
type RoleMembers struct { Role Type group.MemberRole `json:"type"` Members []group.Member `json:"members"` }
func GetAllRoleMembers ¶
func GetDirectRoleMembers ¶
type RoleResources ¶
func GetResourcesForRole ¶
func GetResourcesForRole(ctx *models.Context, appId int) ([]RoleResources, error)
Click to show internal directories.
Click to hide internal directories.