Documentation
¶
Index ¶
- Variables
- func AuthandPermission(permission *PermissionConfig) error
- func Difference(a, b []int) (diff []int)
- type Action
- type Config
- type CreatePermissions
- type Filter
- type LoginCheck
- type MenuMod
- type ModelStruct
- func (as ModelStruct) CheckModuleExists(modulename string, DB *gorm.DB, tenantid int) (tblmod Tblmodule, err error)
- func (as ModelStruct) CheckModulePemissionExists(moduleid int, permissions Action, DB *gorm.DB, tenantid int) (tblmod TblModulePermission, err error)
- func (as ModelStruct) CheckPermissionIdExist(roleid int, permissionid []int, DB *gorm.DB, tenantid int) (roleperm []TblRolePermission, err error)
- func (as ModelStruct) CheckPermissionIdNotExist(roleid int, permissionid []int, DB *gorm.DB, tenantid int) (roleperm []TblRolePermission, err error)
- func (as ModelStruct) CheckRoleExists(role *TblRole, id int, name string, DB *gorm.DB, tenantid int) error
- func (as ModelStruct) Checkrolespermission(user *tbluser, id int, ids []int, DB *gorm.DB, tenantid int) error
- func (as ModelStruct) CreateModulePermission(modpermission *TblModulePermission, DB *gorm.DB) (modper *TblModulePermission, err error)
- func (as ModelStruct) CreateRolePermission(roleper *[]TblRolePermission, DB *gorm.DB) error
- func (as ModelStruct) DeleteModulePermissioninEntries(id string, DB *gorm.DB, tenantid int) (tblmodper TblModulePermission, err error)
- func (as ModelStruct) DeleteRolePermissionById(roleid int, DB *gorm.DB, tenantid int) (roleper []TblRolePermission, err error)
- func (as ModelStruct) Deleterolepermission(id int, DB *gorm.DB, tenantid int) (TblRolePermission TblRolePermission, err error)
- func (as ModelStruct) GetAllModules(limit, offset, id int, filter Filter, DB *gorm.DB, tenantid int) (mod []Tblmodule, count int64)
- func (as ModelStruct) GetAllParentModule(DB *gorm.DB, tenantid int) (modules []TblModule, err error)
- func (as ModelStruct) GetAllParentModules1(DB *gorm.DB, tenantid int) (mod []Tblmodule, err error)
- func (as ModelStruct) GetAllRoles(limit, offset int, filter Filter, getalldata bool, DB *gorm.DB, tenantid int, ...) (role []Tblrole, rolecount int64, err error)
- func (as ModelStruct) GetAllSubModule(moduleid int, DB *gorm.DB, tenantid int) (modules []TblModule, err error)
- func (as ModelStruct) GetAllSubModules(ids []int, DB *gorm.DB, tenantid int) (mod []Tblmodule, err error)
- func (as ModelStruct) GetIdByRouteName(id string, DB *gorm.DB, tenantid int) (tblmodper TblModulePermission, err error)
- func (as ModelStruct) GetModulePermissions(modid int, ids []int, DB *gorm.DB, tenantid int) (permission []TblModulePermission, err error)
- func (as ModelStruct) GetPermissionId(roleid int, DB *gorm.DB, tenantid int) (perm []TblRolePermission, err error)
- func (as ModelStruct) GetRoleById(id int, DB *gorm.DB, tenantid int) (role Tblrole, err error)
- func (as ModelStruct) GetRoleByName(role *[]TblRole, DB *gorm.DB, tenantid int) error
- func (as ModelStruct) GetRoleBySlug(slug string, DB *gorm.DB, tenantid int) (role TblRole, err error)
- func (as ModelStruct) GetRolesData(roles *[]Tblrole, DB *gorm.DB, tenantid int64) error
- func (as ModelStruct) MultiSelectDeleteRolePermissionById(roleper *[]TblRolePermission, roleids []int, roleid int, DB *gorm.DB, ...) error
- func (as ModelStruct) MultiSelectRoleDelete(role *TblRole, ids []int, id int, DB *gorm.DB, tenantid int) error
- func (as ModelStruct) MultiSelectRoleIsActive(role *TblRole, id []int, val int, DB *gorm.DB, tenantid int) error
- func (as ModelStruct) RoleCreate(role *Tblrole, DB *gorm.DB) error
- func (as ModelStruct) RoleDelete(id int, DB *gorm.DB, tenantid int) error
- func (as ModelStruct) RoleId(id int, DB *gorm.DB) (user int, err error)
- func (as ModelStruct) RoleIsActive(role *TblRole, id, val int, DB *gorm.DB, tenantid int) error
- func (as ModelStruct) RoleUpdate(role *Tblrole, DB *gorm.DB, tenantid int) error
- type MultiPermissin
- type Permission
- type PermissionConfig
- func (RoleConf *PermissionConfig) CheckRoleAlreadyExists(roleid int, rolename string, tenantid int) (bool, error)
- func (permission *PermissionConfig) CreatePermission(Perm MultiPermissin) error
- func (permission *PermissionConfig) CreatePermission1(permissions CreatePermissions) error
- func (RoleConf *PermissionConfig) CreateRole(rolec RoleCreation, status int) (Tblrole, error)
- func (permission *PermissionConfig) CreateUpdatePermission(Perm MultiPermissin) error
- func (RoleConf *PermissionConfig) DeleteRole(roleids []int, roleid int, tenantid int) (bool, error)
- func (permission *PermissionConfig) GetPermissionDetailsById(roleid int, tenantid int) (rolepermissionid []int, err error)
- func (RoleConf *PermissionConfig) GetRoleById(roleid int, tenantid int) (tblrol Tblrole, err error)
- func (RoleConf *PermissionConfig) GetRoleByName(tenantid int) (tblrole []TblRole, err error)
- func (RoleConf *PermissionConfig) GetRoleBySlug(slug string, tenantid int) (role TblRole, err error)
- func (RoleConf *PermissionConfig) GetRoleids(loginid int) (user int)
- func (RoleConf *PermissionConfig) MultiSelectRoleStatus(roleid []int, status int, userid int, tenantid int) (err error)
- func (permission *PermissionConfig) PermissionList(tenantid int) (menu []MenuMod, err error)
- func (permission *PermissionConfig) PermissionListRoleId(limit, offset, roleid int, filter Filter, tenantid int) (Module []Tblmodule, count int64, err error)
- func (RoleConf *PermissionConfig) RoleList(rolelist Rolelist, tenantid int, isactive bool) (roles []Tblrole, rolecount int64, err error)
- func (RoleConf *PermissionConfig) RoleStatus(roleid int, status int, userid int, tenantid int) (err error)
- func (RoleConf *PermissionConfig) Rolescheckusers(roleid int, roleids []int, tenantid int) (bool, error)
- func (RoleConf *PermissionConfig) UpdateRole(rolec RoleCreation, roleid int, tenantid int) (updaterole Tblrole, err error)
- type RoleCreation
- type Rolelist
- type SubModule
- type TblModule
- type TblModulePermission
- type TblRole
- type TblRolePermission
- type Tblmodule
- type Tblrole
- type Type
- type URL
Constants ¶
This section is empty.
Variables ¶
var ( ErrorAuthentication = errors.New("auth enabled not initialised") ErrorAuthorization = errors.New("permissions enabled not initialised") Error500Status = errors.New("internal server error") Error403 = errors.New("unauthorized") Error404 = errors.New("not found") ErrorModuleNotFound = errors.New("modulename not found") ErrorModulePermissionNotFound = errors.New("module permission not found") ErrorRoleNameEmpty = errors.New("role name is empty") ErrorInvalidroleid = errors.New("invalid roleid cannot delete") TenantId, _ = strconv.Atoi(os.Getenv("Tenant_ID")) )
Functions ¶
func AuthandPermission ¶
func AuthandPermission(permission *PermissionConfig) error
Types ¶
type Config ¶
type Config struct { AuthEnable bool PermissionEnable bool Authenticate *auth.Auth DataBaseType Type DB *gorm.DB }
In Default superadmin or roleid 1 have all permissions
type CreatePermissions ¶
type LoginCheck ¶
type MenuMod ¶
type MenuMod struct { Id int ModuleName string IconPath string Routes []URL // this is for single menu multiple permissions arr HrefRoute URL Route string //this is for a tag href route SubModule []SubModule // this is for submodules // FullAccessPermission bool EmptyCheck bool //this is flg for mainmenu hide if submodule is empty TenantId int }
type ModelStruct ¶
Just Group the all model using this struct
var AS ModelStruct
func (ModelStruct) CheckModuleExists ¶
func (ModelStruct) CheckModulePemissionExists ¶
func (as ModelStruct) CheckModulePemissionExists(moduleid int, permissions Action, DB *gorm.DB, tenantid int) (tblmod TblModulePermission, err error)
func (ModelStruct) CheckPermissionIdExist ¶
func (as ModelStruct) CheckPermissionIdExist(roleid int, permissionid []int, DB *gorm.DB, tenantid int) (roleperm []TblRolePermission, err error)
func (ModelStruct) CheckPermissionIdNotExist ¶
func (as ModelStruct) CheckPermissionIdNotExist(roleid int, permissionid []int, DB *gorm.DB, tenantid int) (roleperm []TblRolePermission, err error)
func (ModelStruct) CheckRoleExists ¶
func (as ModelStruct) CheckRoleExists(role *TblRole, id int, name string, DB *gorm.DB, tenantid int) error
Check role
func (ModelStruct) Checkrolespermission ¶ added in v0.0.19
func (ModelStruct) CreateModulePermission ¶
func (as ModelStruct) CreateModulePermission(modpermission *TblModulePermission, DB *gorm.DB) (modper *TblModulePermission, err error)
create json module permission
func (ModelStruct) CreateRolePermission ¶
func (as ModelStruct) CreateRolePermission(roleper *[]TblRolePermission, DB *gorm.DB) error
bulk creation
func (ModelStruct) DeleteModulePermissioninEntries ¶
func (as ModelStruct) DeleteModulePermissioninEntries(id string, DB *gorm.DB, tenantid int) (tblmodper TblModulePermission, err error)
func (ModelStruct) DeleteRolePermissionById ¶
func (as ModelStruct) DeleteRolePermissionById(roleid int, DB *gorm.DB, tenantid int) (roleper []TblRolePermission, err error)
func (ModelStruct) Deleterolepermission ¶
func (as ModelStruct) Deleterolepermission(id int, DB *gorm.DB, tenantid int) (TblRolePermission TblRolePermission, err error)
Delete Role Permission by id
func (ModelStruct) GetAllModules ¶
func (as ModelStruct) GetAllModules(limit, offset, id int, filter Filter, DB *gorm.DB, tenantid int) (mod []Tblmodule, count int64)
This is for assign permission
func (ModelStruct) GetAllParentModule ¶
func (ModelStruct) GetAllParentModules1 ¶
func (ModelStruct) GetAllRoles ¶
func (as ModelStruct) GetAllRoles(limit, offset int, filter Filter, getalldata bool, DB *gorm.DB, tenantid int, active bool) (role []Tblrole, rolecount int64, err error)
Get all roles list with limit and offset
func (ModelStruct) GetAllSubModule ¶
func (ModelStruct) GetAllSubModules ¶
func (ModelStruct) GetIdByRouteName ¶
func (as ModelStruct) GetIdByRouteName(id string, DB *gorm.DB, tenantid int) (tblmodper TblModulePermission, err error)
Get Id by RouteName
func (ModelStruct) GetModulePermissions ¶
func (as ModelStruct) GetModulePermissions(modid int, ids []int, DB *gorm.DB, tenantid int) (permission []TblModulePermission, err error)
func (ModelStruct) GetPermissionId ¶
func (as ModelStruct) GetPermissionId(roleid int, DB *gorm.DB, tenantid int) (perm []TblRolePermission, err error)
Get PermissionId By RoleId
func (ModelStruct) GetRoleById ¶
Get role by id
func (ModelStruct) GetRoleByName ¶ added in v0.0.6
func (ModelStruct) GetRoleBySlug ¶ added in v0.0.11
func (as ModelStruct) GetRoleBySlug(slug string, DB *gorm.DB, tenantid int) (role TblRole, err error)
get role by slugname
func (ModelStruct) GetRolesData ¶
func (ModelStruct) MultiSelectDeleteRolePermissionById ¶
func (as ModelStruct) MultiSelectDeleteRolePermissionById(roleper *[]TblRolePermission, roleids []int, roleid int, DB *gorm.DB, tenantid int) error
delete multiple permission
func (ModelStruct) MultiSelectRoleDelete ¶
func (as ModelStruct) MultiSelectRoleDelete(role *TblRole, ids []int, id int, DB *gorm.DB, tenantid int) error
delete multiple roles
func (ModelStruct) MultiSelectRoleIsActive ¶
func (as ModelStruct) MultiSelectRoleIsActive(role *TblRole, id []int, val int, DB *gorm.DB, tenantid int) error
update selected role status
func (ModelStruct) RoleCreate ¶
func (as ModelStruct) RoleCreate(role *Tblrole, DB *gorm.DB) error
Roels Insert
func (ModelStruct) RoleDelete ¶
Delete the role data
func (ModelStruct) RoleIsActive ¶
update role status
func (ModelStruct) RoleUpdate ¶
type MultiPermissin ¶
type Permission ¶
type PermissionConfig ¶
type PermissionConfig struct { AuthEnable bool PermissionEnable bool Authenticate *auth.Auth DB *gorm.DB DataBaseType Type AuthFlg bool PermissionFlg bool UserId int DataAccess int }
func (*PermissionConfig) CheckRoleAlreadyExists ¶
func (RoleConf *PermissionConfig) CheckRoleAlreadyExists(roleid int, rolename string, tenantid int) (bool, error)
Check Role Already Exists
func (*PermissionConfig) CreatePermission ¶
func (permission *PermissionConfig) CreatePermission(Perm MultiPermissin) error
create permission
func (*PermissionConfig) CreatePermission1 ¶
func (permission *PermissionConfig) CreatePermission1(permissions CreatePermissions) error
create permission
func (*PermissionConfig) CreateRole ¶
func (RoleConf *PermissionConfig) CreateRole(rolec RoleCreation, status int) (Tblrole, error)
function used to create a role
func (*PermissionConfig) CreateUpdatePermission ¶
func (permission *PermissionConfig) CreateUpdatePermission(Perm MultiPermissin) error
update permission
func (*PermissionConfig) DeleteRole ¶
delete seleted role
func (*PermissionConfig) GetPermissionDetailsById ¶
func (permission *PermissionConfig) GetPermissionDetailsById(roleid int, tenantid int) (rolepermissionid []int, err error)
permission List
func (*PermissionConfig) GetRoleById ¶
func (RoleConf *PermissionConfig) GetRoleById(roleid int, tenantid int) (tblrol Tblrole, err error)
get role by id
func (*PermissionConfig) GetRoleByName ¶ added in v0.0.6
func (RoleConf *PermissionConfig) GetRoleByName(tenantid int) (tblrole []TblRole, err error)
function used to retrieve a particular role by using role Name
func (*PermissionConfig) GetRoleBySlug ¶ added in v0.0.11
func (RoleConf *PermissionConfig) GetRoleBySlug(slug string, tenantid int) (role TblRole, err error)
get role by slugname
func (*PermissionConfig) GetRoleids ¶ added in v0.0.13
func (RoleConf *PermissionConfig) GetRoleids(loginid int) (user int)
get roleid using user table
func (*PermissionConfig) MultiSelectRoleStatus ¶
func (RoleConf *PermissionConfig) MultiSelectRoleStatus(roleid []int, status int, userid int, tenantid int) (err error)
update selected role status
func (*PermissionConfig) PermissionList ¶
func (permission *PermissionConfig) PermissionList(tenantid int) (menu []MenuMod, err error)
func (*PermissionConfig) PermissionListRoleId ¶
func (permission *PermissionConfig) PermissionListRoleId(limit, offset, roleid int, filter Filter, tenantid int) (Module []Tblmodule, count int64, err error)
permission List
func (*PermissionConfig) RoleList ¶
func (RoleConf *PermissionConfig) RoleList(rolelist Rolelist, tenantid int, isactive bool) (roles []Tblrole, rolecount int64, err error)
role list
func (*PermissionConfig) RoleStatus ¶
func (RoleConf *PermissionConfig) RoleStatus(roleid int, status int, userid int, tenantid int) (err error)
change role status 0-inactive, 1-active
func (*PermissionConfig) Rolescheckusers ¶ added in v0.0.19
func (*PermissionConfig) UpdateRole ¶
func (RoleConf *PermissionConfig) UpdateRole(rolec RoleCreation, roleid int, tenantid int) (updaterole Tblrole, err error)
function used to update role
type RoleCreation ¶
type TblModule ¶
type TblModule struct { Id int `gorm:"column:id"` ModuleName string `gorm:"column:module_name"` IsActive int `gorm:"column:is_active"` DefaultModule int `gorm:"column:default_module"` ParentId int `gorm:"column:parent_id"` IconPath string `gorm:"column:icon_path"` AssignPermission int `gorm:"column:assign_permission"` Description string `gorm:"column:description"` OrderIndex int `gorm:"column:order_index"` CreatedBy int `gorm:"column:created_by"` CreatedOn time.Time `gorm:"column:created_on"` MenuType string `gorm:"column:menu_type"` GroupFlg int `gorm:"column:group_flg"` TenantId int `gorm:"column:tenant_id"` }
type TblModulePermission ¶
type TblModulePermission struct { Id int `gorm:"column:id"` RouteName string `gorm:"column:route_name"` DisplayName string `gorm:"column:display_name"` SlugName string `gorm:"column:slug_name"` Description string `gorm:"column:description"` ModuleId int `gorm:"column:module_id"` CreatedBy int `gorm:"column:created_by"` CreatedOn time.Time `gorm:"column:created_on;DEFAULT:NULL"` CreatedDate string `gorm:"-:all"` ModifiedBy int `gorm:"DEFAULT:NULL"` ModifiedOn time.Time `gorm:"column:modified_by;DEFAULT:NULL"` ModuleName string `gorm:"-:migration;<-:false"` FullAccessPermission int `gorm:"column:full_access_permission"` ParentId int `gorm:"column:parent_id"` AssignPermission int `gorm:"column:assign_permission"` BreadcrumbName string `gorm:"column:breadcrumb_name"` TblRolePermission []TblRolePermission `gorm:"-:migration;<-:false; foreignKey:PermissionId"` OrderIndex int `gorm:"column:order_index"` TenantId int `gorm:"column:tenant_id"` }
type TblRole ¶
type TblRole struct { Id int `gorm:"column:id"` Name string `gorm:"column:name"` Description string `gorm:"column:description"` Slug string `gorm:"column:slug"` IsActive int `gorm:"column:is_active"` IsDeleted int `gorm:"column:is_deleted"` CreatedOn time.Time `gorm:"column:created_on"` CreatedBy int `gorm:"column:created_by"` ModifiedOn time.Time `gorm:"column:modified_on"` ModifiedBy int `gorm:"column:modified_by"` TenantId int `gorm:"column:tenant_id;DEFAULT:NULL"` }
type TblRolePermission ¶
type TblRolePermission struct { Id int `gorm:"column:id"` RoleId int `gorm:"column:role_id"` PermissionId int `gorm:"column:permission_id"` CreatedBy int `gorm:"column:created_by"` CreatedOn time.Time `gorm:"column:created_on;DEFAULT:NULL"` CreatedDate string `gorm:"-:migration;<-:false"` TenantId int `gorm:"column:tenant_id;DEFAULT:NULL"` }
type Tblmodule ¶
type Tblmodule struct { Id int `gorm:"column:id"` ModuleName string `gorm:"column:module_name"` IsActive int `gorm:"column:is_active"` CreatedBy int `gorm:"column:created_by"` CreatedOn time.Time `gorm:"column:created_on;DEFAULT:NULL"` CreatedDate string `gorm:"-:migration;<-:false"` DefaultModule int `gorm:"column:default_module"` ParentId int `gorm:"column:parent_id"` IconPath string `gorm:"column:icon_path"` TblModulePermission []TblModulePermission `gorm:"-:migration;<-:false; foreignKey:ModuleId"` Description string `gorm:"column:description"` OrderIndex int `gorm:"column:order_index"` TenantId int `gorm:"column:tenant_id"` }
type Tblrole ¶
type Tblrole struct { Id int `gorm:"column:id"` Name string `gorm:"column:name"` Description string `gorm:"column:description"` Slug string `gorm:"column:slug"` IsActive int `gorm:"column:is_active"` IsDeleted int `gorm:"column:is_deleted"` CreatedOn time.Time `gorm:"column:created_on"` CreatedBy int `gorm:"column:created_by"` ModifiedOn time.Time `gorm:"column:modified_on;DEFAULT:NULL"` ModifiedBy int `gorm:"column:modified_by;DEFAULT:NULL"` CreatedDate string `gorm:"-:migration;<-:false"` User []tbluser `gorm:"-"` TenantId int `gorm:"column:tenant_id;DEFAULT:NULL"` }