Documentation ¶
Index ¶
- func AssignDefaultRolePermissions(db *gorm.DB, roleID uint, userID uint) []string
- func AssignDefaultRolePermissionsUUID(db *gorm.DB, roleID uint, userID uuid.UUID) []string
- func AssignPermissionsToCategory(db *gorm.DB, categoryID uint, permissions []uint) []string
- func AssignRole(db *gorm.DB, userID uint, roleID uint) error
- func AssignRolePermissions(db *gorm.DB, roleID uint, permissionIDs []uint) []string
- func AssignRoleUUID(db *gorm.DB, userID uuid.UUID, roleID uint) error
- func AssignUserPermissions(db *gorm.DB, userID uint, permissionIDs []uint) []string
- func AssignUserPermissionsUUID(db *gorm.DB, userID uuid.UUID, permissionIDs []uint) []string
- func CheckPermission(db *gorm.DB, userID uint, permissionID uint) (bool, error)
- func CheckPermissionUUID(db *gorm.DB, userID uuid.UUID, permName string) (bool, error)
- func CheckRole(db *gorm.DB, userID uint, roleID uint) (bool, error)
- func CheckRolePermission(db *gorm.DB, roleID uint, permissionID uint) (bool, error)
- func CheckRoleUUID(db *gorm.DB, userID uuid.UUID, roleID uint) (bool, error)
- func CheckUserPermissionUrl(db *gorm.DB, userID uint, permissionPath string) (bool, error)
- func CheckUserPermissionUrlUUID(db *gorm.DB, userID uuid.UUID, permissionPath string) (bool, error)
- func CreateCategory(db *gorm.DB, categoryName string) error
- func CreatePermission(db *gorm.DB, permissionName string, description string, urlID uint) error
- func CreateRole(db *gorm.DB, roleName string) error
- func CreateStaticPermission(db *gorm.DB, permissionID uint, permissionData []string) error
- func CreateStaticPermissionCategory(db *gorm.DB, categoryID uint, categoryName string) error
- func CreateStaticPermissionUrl(db *gorm.DB, urlID uint, urlPath string) error
- func CreateStaticRole(db *gorm.DB, roleID uint, roleName string) error
- func CreateUrl(db *gorm.DB, path string) error
- func DeleteCategory(db *gorm.DB, categoryID uint) error
- func DeletePermission(db *gorm.DB, permissionID uint) error
- func DeleteRole(db *gorm.DB, roleID uint) error
- func DeleteUrl(db *gorm.DB, urlID uint) error
- func GetAllCategoryPermissions(db *gorm.DB) ([]domain.CategoryPermissionsResponse, error)
- func GetCategories(db *gorm.DB) ([]models.Category, error)
- func GetCategoryByID(db *gorm.DB, categoryID uint) (category models.Category, err error)
- func GetCategoryByName(db *gorm.DB, categoryName string) (category models.Category, err error)
- func GetPermissionByID(db *gorm.DB, permissionID uint) (permission models.Permission, err error)
- func GetPermissionByName(db *gorm.DB, permissionName string) (permission models.Permission, err error)
- func GetPermissionByUrl(db *gorm.DB, permissionPath string) (permission models.Permission, err error)
- func GetPermissions(db *gorm.DB) ([]models.Permission, error)
- func GetPermissionsByCategory(db *gorm.DB, categoryID uint) ([]models.Permission, error)
- func GetRoleByID(db *gorm.DB, roleID uint) (role models.Role, err error)
- func GetRoleByName(db *gorm.DB, roleName string) (role models.Role, err error)
- func GetRoles(db *gorm.DB) (roles []models.Role, err error)
- func GetUrlByID(db *gorm.DB, urlID uint) (url models.Url, err error)
- func GetUrlByPath(db *gorm.DB, path string) (url models.Url, err error)
- func GetUrls(db *gorm.DB) ([]models.Url, error)
- func GetUserRoles(db *gorm.DB, userID uint) ([]models.Role, error)
- func GetUserRolesUUID(db *gorm.DB, userID uuid.UUID) ([]models.Role, error)
- func RevokePermission(db *gorm.DB, userID uint, permName string) error
- func RevokePermissionUUID(db *gorm.DB, userID uuid.UUID, permName string) error
- func RevokeRole(db *gorm.DB, userID uint, roleID uint) error
- func RevokeRolePermission(db *gorm.DB, roleID uint, permissionID uint) error
- func RevokeRoleUUID(db *gorm.DB, userID uuid.UUID, roleID uint) error
- func UpdateCategory(db *gorm.DB, categoryID uint, categoryName string) error
- func UpdatePermission(db *gorm.DB, permissionID uint, permissionName string, description string, ...) error
- func UpdateRole(db *gorm.DB, roleID uint, roleName string) error
- func UpdateUrl(db *gorm.DB, urlID uint, path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignDefaultRolePermissions ¶
AssignDefaultRolePermissions assigns default role permissions to a user.
It takes in three parameters: db of type *gorm.DB, roleID of type uint and userID of type uint and returns an error object. It further delegates the permissions assigning with AssignUserPermissions function.
func AssignDefaultRolePermissionsUUID ¶
AssignDefaultRolePermissionsUUID assigns default role permissions to a user.
It takes in three parameters: db of type *gorm.DB, roleID of type uint and userID of type uuid.UUID and returns an error object. It further delegates the permissions assigning with AssignUserPermissionsUUID function.
func AssignPermissionsToCategory ¶
AssignPermissionsToCategory associates permission(s) with a category.
It takes in three parameters: db of type *gorm.DB, categoryID of type uint and permissions of type slice of uint and returns and returns an error object.
func AssignRole ¶
AssignRole assigns a role to a user.
It takes in three parameters: db of type *gorm.DB, userID of type uint and roleID of type uint and returns an error object. It returns an error object if the user is already assigned with the role.
func AssignRolePermissions ¶
AssignRolePermissions assigns a list of permissions to a specified role.
It takes in three parameters: db of type *gorm.DB, roleID of type uint and permissionIDs of type slice of uint with ids of permissions. It returns an error object. It immediately returns with an err object if a requested permission is not found, else create new relationship record of role with the permission.
func AssignRoleUUID ¶
AssignRole assigns a role to a user.
It takes in three parameters: db of type *gorm.DB, userID of type uuid.UUID and roleID of type uint and returns an error object. It returns an error object if the user is already assigned with the role.
func AssignUserPermissions ¶
AssignUserPermissions assigns a list of permission to a user.
It takes in three parameters: db of type *gorm.DB, userID of type uint and permissionIDs of type slice of uint and returns an error object.
func AssignUserPermissionsUUID ¶
AssignUserPermissionsUUID assigns a list of permission to a user.
It takes in three parameters: db of type *gorm.DB, userID of type uuid.UUID and permissionIDs of type slice of uint and returns an error object.
func CheckPermission ¶
CheckPermission checks if a permission with the specified id is assigned to a user.
It takes in three parameters: db of type *gorm.DB, userID of type uint and permmissionID of type uint. It returns a boolean to specify if the permission is assigned to the user and an error object.
func CheckPermissionUUID ¶
CheckPermissionUUID checks if a permission with the specified name is assigned to a user.
It takes in three parameters: db of type *gorm.DB, userID of type uuid.UUID and permName of type string. It returns a boolean to specify if the permission is assigned to the user and an error object.
func CheckRole ¶
CheckRole checks if the role with the specified id is assigned to the user.
It takes in three parameters: db of type *gorm.DB, userID of type uint and roleID of type uint. It returns a boolean to specify if the role is assigned to the user and an error object.
func CheckRolePermission ¶
CheckRolePermission checks if a role has a specific permission.
It takes in three parameters: db of type *gorm.DB, roleID of type uint and permissionID of type uint. It returns a boolean to specify if the role has the permission and an error object.
func CheckRoleUUID ¶
CheckRoleUUID checks if the role with the specified id is assigned to the user.
It takes in three parameters: db of type *gorm.DB, userID of type uuid.UUID and roleID of type uint. It returns a boolean to specify if the role is assigned to the user and an error object.
func CheckUserPermissionUrl ¶
CheckUserPermissionUrl checks if a user has permission to a url path.
It takes in three parameters: db of type *gorm.DB, userID of type uint and permissionPath of type string. It returns a bool to indicate if a user has the permission to the url path and an error object.
func CheckUserPermissionUrlUUID ¶
CheckUserPermissionUrl checks if a user has permission to a url path.
It takes in three parameters: db of type *gorm.DB, userID of type uuid.UUID and permissionPath of type string. It returns a bool to indicate if a user has the permission to the url path and an error object.
func CreateCategory ¶
CreateCategory creates a new category in the database with the specified category name.
It takes in two parameters: db of type *gorm.DB and categoryName of type string and returns an error object.
func CreatePermission ¶
CreatePermission creates a new permission in the database with the specified permission name and description.
It takes in three parameters: db of type *gorm.DB and permissionName and description of type string and returns an error object.
func CreateRole ¶
CreateRole creates a new role in the database with the specified role name.
It takes in two parameters: db of type *gorm.DB and roleName of type string and returns an error object.
func CreateStaticPermission ¶
CreateStaticPermission creates a new permission with the specified ID and permission data.
It takes in three parameters: db of type *gorm.DB and permissionID of type uint and permissionData of type slice of string (includes permission name and desription) and returns an error object.
func CreateStaticPermissionCategory ¶
CreateStaticCategory creates a new category with the specified ID and category name.
It takes in three parameters: db of type *gorm.DB and categoryID of type uint and categoryName of type string and returns an error object.
func CreateStaticPermissionUrl ¶
CreateStaticPermissionUrl creates a new url with the specified ID and url path name.
It takes in three parameters: db of type *gorm.DB, urlID of type uint and urlPath of type string and returns an error object.
func CreateStaticRole ¶
CreateStaticRole creates a new role with the specified ID and role name.
It takes in three parameters: db of type *gorm.DB, roleID of type uint and roleName of type string and returns an error object.
func CreateUrl ¶
CreateUrl creates a new url in the database with the specified url path name.
It takes in two parameters: db of type *gorm.DB and path of type string and returns an error object.
func DeleteCategory ¶
DeleteCategory deletes a category with the given id.
It takes in two parameters: db of type *gorm.DB and categoryID of type uint and returns an error object. It also deletes the association of permissions from the category before deleting it.
func DeletePermission ¶
DeletePermission deletes a permission with the given id.
It takes in two parameters: db of type *gorm.DB and permissionID of type uint and returns an error object.
func DeleteRole ¶
DeleteRole deletes a role with the given id.
It takes in two parameters: db of type *gorm.DB and roleID of type uint and returns an error object. It returns immediately if the role has been assigned to an user. It also revokes the association of permissions from the role before deleting it.
func DeleteUrl ¶
DeleteUrl deletes an url with the given id along with its associated object.
It takes in two parameters: db of type *gorm.DB and urlID of type uint and returns an error object. It also deletes the association of url with the permission and also user permission before deleting it.
func GetAllCategoryPermissions ¶
func GetAllCategoryPermissions(db *gorm.DB) ([]domain.CategoryPermissionsResponse, error)
GetAllCategoryPermissions retrieves all the permissions associated with each of the category in the database.
It takes in an object of database of type *gorm.DB as parameter and returns data of type slice of domain.CategoryPermissionsResponse and an error object.
func GetCategories ¶
GetCategories retrieves a list of category objects from the database.
It takes in a database parameter db of type *gorm.DB to query and retrieve all the categories from the database. It returns a slice of category objects and an error object.
func GetCategoryByID ¶
GetCategoryByID retrieves a category from the database by its id.
It takes in two parameters: db of type *gorm.DB and categoryID of type uint. It returns a category object if found and an error object.
func GetCategoryByName ¶
GetCategoryByName retrieves a category from the database by its name.
It takes in two parameters: db of type *gorm.DB and categoryName of type string. It returns a category object if found and an error object.
func GetPermissionByID ¶
GetPermissionByID retrieves a permission from the database by its id.
It takes in two parameters: db of type *gorm.DB and permissionID of type uint. It returns a permission object if found and an error object.
func GetPermissionByName ¶
func GetPermissionByName(db *gorm.DB, permissionName string) (permission models.Permission, err error)
GetPermissionByName retrieves a permission from the database by its name.
It takes in two parameters: db of type *gorm.DB and permissionName of type string. It returns a permission object if found and an error object.
func GetPermissionByUrl ¶
func GetPermissionByUrl(db *gorm.DB, permissionPath string) (permission models.Permission, err error)
GetPermissionByUrl retrieves a permission from the database by its url path.
It takes in two parameters: db of type *gorm.DB and permissionUrl of type string. It returns a permission object if found and an error object.
func GetPermissions ¶
func GetPermissions(db *gorm.DB) ([]models.Permission, error)
GetPermissions retrieves a list of permission names from the database.
It takes in a database parameter db of type *gorm.DB to query and retrieve all the permissions from the database. It returns a slice of string with the name of the permissions and an error object.
func GetPermissionsByCategory ¶
GetPermissionsByCategory retrieves the list permissions associated with a category.
It takes in two parameters: db of type *gorm.DB and categoryID of type uint. It returns a slice of permissions with the given category id and an error object.
func GetRoleByID ¶
GetRoleByID retrieves a role from the database with the specified id.
It takes in two parameters: db of type *gorm.DB and roleID of type uint. It returns a role object if found and an error object.
func GetRoleByName ¶
GetRoleByName retrieves a role from the database by its name.
It takes in two parameters: db of type *gorm.DB and roleName of type string. It returns a role object if found and an error object.
func GetRoles ¶
GetRoles retrieves a list of role names from the database.
It takes in a database parameter db of type *gorm.DB to query and retrieve all the roles from the database. It returns a slice of string with the name of the roles and an error object.
func GetUrlByID ¶
GetUrlByID retrieves an url from the database with the specified id.
It takes in two parameters: db of type *gorm.DB and urlID of type uint. It returns an url object if found and an error object.
func GetUrlByPath ¶
GetUrlByPath retrieves an url from the database by its path.
It takes in two parameters: db of type *gorm.DB and path of type string. It returns an url object if found and an error object.
func GetUrls ¶
GetUrls retrieves a list of urls from the database.
It takes in a database parameter db of type *gorm.DB to query and retrieve all the urls from the database. It returns a slice of url objects and an error object.
func GetUserRoles ¶
GetUserRoles retrieves the roles assigned to a user.
It takes in two parameters: db of type *gorm.DB and userID of type uint. It returns a slice of strings with the name of the roles and an error object.
func GetUserRolesUUID ¶
GetUserRolesUUID retrieves the roles assigned to a user.
It takes in two parameters: db of type *gorm.DB and userID of type uuid.UUID. It returns a slice of strings with the name of the roles and an error object.
func RevokePermission ¶
RevokePermission revokes a permission from a user role.
It takes in three parameters: db of type *gorm.DB, userID of type uint and permName of type string and returns an error object.
func RevokePermissionUUID ¶
RevokePermissionUUID revokes a permission from a user role.
It takes in three parameters: db of type *gorm.DB, userID of type uuid.UUID and permName of type string and returns an error object.
func RevokeRole ¶
RevokeRole revokes a role from a user.
It takes in three parameters: db of type *gorm.DB, userID of type uint and roleID of type uint and returns an error object.
func RevokeRolePermission ¶
RevokeRolePermission revokes a permission from a specified role.
It takes in three parameters: db of type *gorm.DB, roleID of type uint and permissionID of type uint and returns an error object.
func RevokeRoleUUID ¶
RevokeRole revokes a role from a user.
It takes in three parameters: db of type *gorm.DB, userID of type uuid.UUID and roleID of type uint and returns an error object.
func UpdateCategory ¶
UpdateCategory updates a category with the specified category id.
It takes in three parameters: db of type *gorm.DB, categoryID of type uint, categoryName of type string and returns an error object.
func UpdatePermission ¶
func UpdatePermission(db *gorm.DB, permissionID uint, permissionName string, description string, urlID uint) error
UpdatePermission updates an existing permission for the specified permission id with the given data.
It takes in four parameters: db of type *gorm.DB, permissionID of type uint and two string type, permissionName and description and returns an error object.
func UpdateRole ¶
UpdateRole updates an existing role in the database for the specified role id with the given role name.
It takes in three parameters: db of type *gorm.DB, roleID of type uint and roleName of type string and returns an error object.
Types ¶
This section is empty.