/// <summary> /// 获取用户组分页数据 /// </summary> /// <param name="appid">appid</param> /// <param name="page"></param> /// <param name="size"></param> /// <returns></returns> public ActionResult PageData(string appid, int page = 1, int size = 10) { var where = string.IsNullOrEmpty(appid) ? (Expression <Func <UserGroup, bool> >)(g => true) : (g => g.ClientApp.Any(a => a.AppId.Equals(appid))); List <int> ids = UserGroupBll.LoadPageEntitiesNoTracking <int, UserGroupOutputDto>(page, size, out int total, where, a => a.Id, false).Select(g => g.Id).ToList(); List <UserGroupOutputDto> list = new List <UserGroupOutputDto>(); ids.ForEach(g => { List <UserGroupOutputDto> temp = UserGroupBll.GetSelfAndChildrenByParentId(g).ToList(); list.AddRange(temp); }); return(PageResult(list.DistinctBy(u => u.Id), size, total)); }
/// <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 <UserGroup, bool> >)(g => true) : (g => g.ClientApp.Any(a => a.AppId.Equals(appid))); UserGroupBll.LoadEntitiesNoTracking <UserGroupOutputDto>(where); List <int> ids = UserGroupBll.LoadEntitiesNoTracking <UserGroupOutputDto>(where).Select(g => g.Id).ToList(); List <UserGroupOutputDto> list = new List <UserGroupOutputDto>(); ids.ForEach(g => { var raw = UserGroupBll.GetSelfAndChildrenByParentId(g); var temp = string.IsNullOrEmpty(kw) ? raw.ToList() : raw.Where(u => u.GroupName.Contains(kw)).ToList(); list.AddRange(temp); }); return(ResultData(list.DistinctBy(u => u.Id))); }