增加功能:App类增加Administrators角色默认全部授权
This commit is contained in:
parent
f8a8644bad
commit
2c009e0255
|
@ -20,7 +20,7 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
AppName = d.Value
|
||||
}).ToList();
|
||||
var role = RoleHelper.Retrieves().Cast<Role>().FirstOrDefault(r => r.Id == roleId);
|
||||
apps.ForEach(p => p.Checked = (role != null && role.Apps.Contains(p.Id)) ? "checked" : "");
|
||||
apps.ForEach(p => p.Checked = (role != null && (role.Apps.Contains(p.Id)) || role.RoleName.Equals("Administrators", StringComparison.OrdinalIgnoreCase)) ? "checked" : "");
|
||||
return apps;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,15 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<App> RetrievesByRoleId(string roleId)
|
||||
{
|
||||
var db = DbManager.Create();
|
||||
return db.Fetch<App>($"select d.Code as Id, d.Name as AppName, case ra.AppId when d.Code then 'checked' else '' end Checked from Dicts d left join RoleApp ra on d.Code = ra.AppId and ra.RoleId = @1 where d.Code > '0' and d.Category = @0", "应用程序", roleId);
|
||||
var ret = DbManager.Create().Fetch<App>($"select d.Code as Id, d.Name as AppName, case ra.AppId when d.Code then 'checked' else '' end Checked from Dicts d left join RoleApp ra on d.Code = ra.AppId and ra.RoleId = @1 where d.Code > '0' and d.Category = @0", "应用程序", roleId);
|
||||
|
||||
// 判断是否为Administrators
|
||||
var role = RoleHelper.Retrieves().FirstOrDefault(r => r.Id == roleId);
|
||||
if (role != null && role.RoleName.Equals("Administrators", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ret.ForEach(r => r.Checked = "checked");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue