|
|
|
@ -226,17 +226,17 @@ public class SysRoleService : ISysRoleService
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
@ -266,21 +266,21 @@ public class SysRoleService : ISysRoleService
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|