/// <summary> /// 获取应用所有的角色 /// </summary> /// <param name="appid"></param> /// <param name="kw"></param> /// <returns></returns> public ActionResult GetAll(string appid, string kw) { var where = string.IsNullOrEmpty(appid) ? (Expression <Func <Role, bool> >)(g => true) : (g => g.ClientApp.Any(a => a.AppId.Equals(appid))); List <int> ids = RoleBll.LoadEntitiesNoTracking <RoleOutputDto>(where).Select(g => g.Id).ToList(); List <RoleOutputDto> list = new List <RoleOutputDto>(); ids.ForEach(g => { var raw = RoleBll.GetSelfAndChildrenByParentId(g); var temp = string.IsNullOrEmpty(kw) ? raw.ToList() : raw.Where(u => u.RoleName.Contains(kw)).ToList(); list.AddRange(temp); }); return(ResultData(list.DistinctBy(u => u.Id))); }