/// <summary> /// 获取角色归属的所有应用 /// </summary> /// <param name="id"></param> /// <param name="page"></param> /// <param name="size"></param> /// <param name="kw"></param> /// <returns></returns> public ActionResult MyApps(int id, int page = 1, int size = 10, string kw = "") { Expression <Func <ClientApp, bool> > where; Expression <Func <ClientApp, bool> > where2; if (!string.IsNullOrEmpty(kw)) { where = u => u.Roles.All(c => c.Id != id) && (u.AppName.Contains(kw) || u.AppId.Contains(kw)); where2 = u => u.Roles.Any(c => c.Id == id) && (u.AppName.Contains(kw) || u.AppId.Contains(kw)); } else { where = u => u.Roles.All(c => c.Id != id); where2 = u => u.Roles.Any(c => c.Id == id); } List <ClientAppOutputDto> not = ClientAppBll.LoadPageEntities <string, ClientAppOutputDto>(page, size, out int total1, where, u => u.AppName, false).ToList(); //不属于该角色 List <ClientAppOutputDto> my = ClientAppBll.LoadPageEntities <string, ClientAppOutputDto>(page, size, out int total2, where2, u => u.AppName, false).ToList(); //属于该角色 return(PageResult(new { my, not }, size, total1 >= total2 ? total1 : total2)); }