|
|
|
@ -218,25 +218,25 @@ public class SysRoleService : ISysRoleService
|
|
|
|
|
IEnumerable<long?> delPermissions = existPermissions.AsQueryable().Except(model.PermissionIds);
|
|
|
|
|
if (delPermissions.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
db.Updateable<SysRolePermission>()
|
|
|
|
|
.SetColumns(it => it.IsPermission == 0)//SetColumns是可以叠加的 写2个就2个字段赋值
|
|
|
|
|
db.Deleteable<SysRolePermission>()
|
|
|
|
|
//.SetColumns(it => it.IsPermission == 0)//SetColumns是可以叠加的 写2个就2个字段赋值
|
|
|
|
|
.Where(it => it.RoleId == model.RoleId && delPermissions.Contains(it.PermissionId))
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
IEnumerable<long?> addPermissions = model.PermissionIds.AsQueryable().Except(existPermissions);
|
|
|
|
|
if (addPermissions.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
var existNoPermissions = db.Queryable<SysRolePermission>().Where(x => x.RoleId == model.RoleId && x.IsPermission == 0).Select(n => n.PermissionId).ToArray();
|
|
|
|
|
IEnumerable<long?> updatePermissions = existNoPermissions.AsQueryable().Except(addPermissions);
|
|
|
|
|
if (updatePermissions.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
db.Updateable<SysRolePermission>()
|
|
|
|
|
.SetColumns(it => it.IsPermission == 1)
|
|
|
|
|
.Where(it => it.RoleId == model.RoleId && updatePermissions.Contains(it.PermissionId))
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
IEnumerable<long?> addRolePermissions = addPermissions.AsQueryable().Except(existNoPermissions);
|
|
|
|
|
foreach (var item in addRolePermissions)
|
|
|
|
|
//var existNoPermissions = db.Queryable<SysRolePermission>().Where(x => x.RoleId == model.RoleId && x.IsPermission == 0).Select(n => n.PermissionId).ToArray();
|
|
|
|
|
//IEnumerable<long?> updatePermissions = existNoPermissions.AsQueryable().Except(addPermissions);
|
|
|
|
|
//if (updatePermissions.Count() > 0)
|
|
|
|
|
//{
|
|
|
|
|
// db.Updateable<SysRolePermission>()
|
|
|
|
|
// .SetColumns(it => it.IsPermission == 1)
|
|
|
|
|
// .Where(it => it.RoleId == model.RoleId && updatePermissions.Contains(it.PermissionId))
|
|
|
|
|
// .ExecuteCommand();
|
|
|
|
|
//}
|
|
|
|
|
//IEnumerable<long?> addRolePermissions = addPermissions.AsQueryable().Except(existNoPermissions);
|
|
|
|
|
foreach (var item in addPermissions)
|
|
|
|
|
{
|
|
|
|
|
var permission = new SysRolePermission
|
|
|
|
|
{
|
|
|
|
@ -258,29 +258,29 @@ public class SysRoleService : ISysRoleService
|
|
|
|
|
IEnumerable<long?> delPermissions = existPermissions.AsQueryable().Except(model.PermissionIds);
|
|
|
|
|
if (delPermissions.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
db.Updateable<SysRolePermission>()
|
|
|
|
|
.SetColumns(it => it.IsPermission == 0)//SetColumns是可以叠加的 写2个就2个字段赋值
|
|
|
|
|
.Where(it => it.RoleId == model.RoleId && delPermissions.Contains(it.PermissionId))
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
db.Deleteable<SysRolePermission>()
|
|
|
|
|
//.SetColumns(it => it.IsPermission == 0)//SetColumns是可以叠加的 写2个就2个字段赋值
|
|
|
|
|
.Where(it => it.RoleId == model.RoleId && delPermissions.Contains(it.PermissionId))
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
IEnumerable<long?> addPermissions = model.PermissionIds.AsQueryable().Except(existPermissions);
|
|
|
|
|
if (addPermissions.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
var existNoPermissions = db.Queryable<SysRolePermission>().Where(x => x.RoleId == model.RoleId && x.IsPermission == 0).Select(n => n.PermissionId).ToArray();
|
|
|
|
|
IEnumerable<long?> updatePermissions = existNoPermissions.AsQueryable().Except(addPermissions);
|
|
|
|
|
if (updatePermissions.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
db.Updateable<SysRolePermission>()
|
|
|
|
|
.SetColumns(it => it.IsPermission == 1)
|
|
|
|
|
.Where(it => it.RoleId == model.RoleId && updatePermissions.Contains(it.PermissionId))
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
IEnumerable<long?> addRolePermissions = addPermissions.AsQueryable().Except(existNoPermissions);
|
|
|
|
|
//var existNoPermissions = db.Queryable<SysRolePermission>().Where(x => x.RoleId == model.RoleId && x.IsPermission == 0).Select(n => n.PermissionId).ToArray();
|
|
|
|
|
//IEnumerable<long?> updatePermissions = existNoPermissions.AsQueryable().Except(addPermissions);
|
|
|
|
|
//if (updatePermissions.Count() > 0)
|
|
|
|
|
//{
|
|
|
|
|
// db.Updateable<SysRolePermission>()
|
|
|
|
|
// .SetColumns(it => it.IsPermission == 1)
|
|
|
|
|
// .Where(it => it.RoleId == model.RoleId && updatePermissions.Contains(it.PermissionId))
|
|
|
|
|
// .ExecuteCommand();
|
|
|
|
|
//}
|
|
|
|
|
//IEnumerable<long?> addRolePermissions = addPermissions.AsQueryable().Except(existNoPermissions);
|
|
|
|
|
|
|
|
|
|
#region 租户模块权限检测
|
|
|
|
|
|
|
|
|
|
var tenant = db.Queryable<SysTenant>().Where(x => x.Id == long.Parse(user.TenantId)).First();
|
|
|
|
|
foreach (var item in addRolePermissions)
|
|
|
|
|
foreach (var item in addPermissions)
|
|
|
|
|
{
|
|
|
|
|
var per = db.Queryable<SysPermission>().Where(x => x.Id == item)
|
|
|
|
|
.First();
|
|
|
|
@ -322,7 +322,7 @@ public class SysRoleService : ISysRoleService
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
foreach (var item in addRolePermissions)
|
|
|
|
|
foreach (var item in addPermissions)
|
|
|
|
|
{
|
|
|
|
|
var permission = new SysRolePermission
|
|
|
|
|
{
|
|
|
|
|