组织数据读取权限完成

This commit is contained in:
XM-GO
2023-09-15 15:13:39 +08:00
parent b5ee2a54b9
commit 6630ebdb02
37 changed files with 717 additions and 59 deletions

View File

@@ -17,6 +17,7 @@ type (
Delete(roleId []int64)
GetRoleMeunId(data entity.SysRole) []int64
GetRoleOrganizationId(data entity.SysRole) []int64
FindOrganizationsByRoleId(roleId int64) (entity.SysRole, error)
}
sysRoleModel struct {
@@ -130,3 +131,14 @@ func (m *sysRoleModel) GetRoleOrganizationId(data entity.SysRole) []int64 {
}
return organizationIds
}
func (m *sysRoleModel) FindOrganizationsByRoleId(roleId int64) (entity.SysRole, error) {
var roleData entity.SysRole
err := global.Db.Table(m.table).
Select("sys_roles.data_scope, GROUP_CONCAT(sys_role_organizations.organization_id) as org").
Joins("LEFT JOIN sys_role_organizations ON sys_roles.role_id = sys_role_organizations.role_id").
Where("sys_roles.role_id = ?", roleId).
Group("sys_roles.role_id").
First(&roleData).Error
return roleData, err
}