public List <RoleDto> GetListPaged(int startPage, int pageSize, out int rowCount) { //IQueryable<Role> tu = _repository.LoadPageList(startPage, pageSize, out rowCount, null, it => it.Code); //List<Role> il = tu.ToList(); //il.ForEach(it => it.CreateUser = _userrepository.Get(it.CreateUserId)); //return Mapper.Map<List<RoleDto>>(il); var res = new List <RoleDto>(); var key = CacheKeyName.RoleKey; if (_cacheService.Cached.Exists(key)) { rowCount = (int)_cacheService.Cached.SortedSetLength(key); res = _cacheService.Cached.SortedSetRangeByRank <RoleDto>(key, startPage == 1 ? 0 : (startPage - 1) * pageSize, (startPage) * pageSize - 1); } else { List <RoleDto> rlist = GetAllList(); res = _pagedHelper.Paged <RoleDto>(rlist, startPage, pageSize, out rowCount); } for (int i = 0; i < res.Count; i++) //此处不用foreach,要改变元素值 { User tuser = _userrepository.Get(res[i].CreateUserId); if (tuser != null) { res[i].CreateUserId = tuser.Id; res[i].CreateUserName = tuser.UserName; } } return(res); }
/// <summary> /// 根据父级Id获取子级列表 /// </summary> /// <param name="parentId">父级Id</param> /// <param name="startPage">起始页</param> /// <param name="pageSize">页面大小</param> /// <param name="rowCount">数据总数</param> /// <returns></returns> public List <DepartmentDto> GetChildrenByParent(Guid parentId, int startPage, int pageSize, out int rowCount) { List <DepartmentDto> rlist = GetAllList().Where(x => x.ParentId == parentId).ToList(); return(_pagedHelper.Paged <DepartmentDto>(rlist, startPage, pageSize, out rowCount)); //return Mapper.Map<List<DepartmentDto>>(_repository.LoadPageList(startPage, pageSize, out rowCount, it => it.ParentId == parentId, it => it.Code)); }
//[Obsolete] //public List<UserDto> GetAllList() //{ // return _cacheService.Cached.GetSortList<UserDto>(() => { // return Mapper.Map<List<UserDto>>(_repositoryRead.GetAllList(it => it.Id != Guid.Empty).OrderBy(it => it.UserName)); // }, CacheKeyName.UserKey); // // return Mapper.Map<List<UserDto>>(_repositoryRead.GetAllList(it => it.Id != Guid.Empty).OrderBy(it => it.UserName)); //} public List <UserDto> GetChildrenByDepartment(Guid DepartmentId, int startPage, int pageSize, out int rowCount) { var res = new List <UserDto>(); var key = $"{CacheKeyName.UserKey}{DepartmentId}"; if (_cacheService.Cached.Exists(key)) { rowCount = (int)_cacheService.Cached.SortedSetLength(key); res = _cacheService.Cached.SortedSetRangeByRank <UserDto>(key, startPage == 1 ? 0 : (startPage - 1) * pageSize, (startPage) * pageSize - 1); } else { List <UserDto> rlist = _cacheService.Cached.GetSortList <UserDto>(() => { return(Mapper.Map <List <UserDto> >(_repositoryRead.GetUserIndexList(it => it.DepartmentId == DepartmentId).OrderBy(it => it.UserName))); }, key); res = _pagedHelper.Paged(rlist, startPage, pageSize, out rowCount); } for (int i = 0; i < res.Count; i++) //此处不用foreach,要改变元素值 { res[i] = _cacheService.Cached.Get(() => { return(Mapper.Map <UserDto>(_repositoryReadFactory.CreateRepository <User, IUserRepositoryRead>(res[i].Id.ToString()).Get(res[i].Id))); }, $"{CacheKeyName.UserKey}{res[i].Id}"); if (res[i].CreateUserId != null) { User tuser = _cacheService.Cached.Get(() => { return(_repositoryReadFactory.CreateRepository <User, IUserRepositoryRead>(res[i].CreateUserId.ToString()).Get(res[i].CreateUserId)); }, $"{CacheKeyName.UserKey}{res[i].CreateUserId}"); if (tuser != null) { res[i].CreateUserName = tuser.UserName; } } } return(res); //IQueryable<User> tu = _repositoryRead.LoadPageList(startPage, pageSize, out rowCount, it => it.DepartmentId == DepartmentId, it => it.UserName); //List<User> il = tu.ToList(); //il.ForEach(it => it.CreateUser = _repositoryRead.Get(it.CreateUserId)); //return Mapper.Map<List<UserDto>>(il); }
public List <MenuDto> GetMenusByParent(Guid parentId, int startPage, int pageSize, out int rowCount) { List <MenuDto> rlist = GetAllList().Where(x => x.ParentId == parentId).ToList(); return(_pagedHelper.Paged <MenuDto>(rlist, startPage, pageSize, out rowCount)); //var menus = _menuRepository.LoadPageList(startPage, pageSize, out rowCount, it => it.ParentId == parentId, it => it.SerialNumber); //return Mapper.Map<List<MenuDto>>(menus); }
public List <UserDto> GetChildrenByDepartment(int startPage, int pageSize, out int rowCount) { List <UserDto> rlist = GetAllList(); return(_pagedHelper.Paged(rlist, startPage, pageSize, out rowCount , (x) => { for (int i = 0; i < x.Count; i++) //此处不用foreach,要改变元素值 { x[i] = _cacheService.Cached.Get(() => { return Mapper.Map <UserDto>(_repositoryReadFactory.CreateRepository <User, IUserRepositoryRead>(x[i].Id.ToString()).Get(x[i].Id)); }, $"{CacheKeyName.CRMUserKey}{x[i].Id}"); } ; return x; })); }