public async Task <IList <AccountEntity> > Query(AccountQueryModel model) { var paging = model.Paging(); var query = Db.Find(m => m.Deleted == false && m.Type == model.Type); query.WhereIf(model.UserName.NotNull(), m => m.UserName.Contains(model.UserName)); query.WhereIf(model.Name.NotNull(), m => m.Name.Contains(model.Name)); query.WhereIf(model.Phone.NotNull(), m => m.Phone == model.Phone); query.WhereIf(model.Email.NotNull(), m => m.Email == model.Email); if (!paging.OrderBy.Any()) { query.OrderByDescending(m => m.Id); } var list = await query.PaginationAsync(paging); model.TotalCount = paging.TotalCount; return(list); }
public async Task <IResultModel> Query(AccountQueryModel model) { var result = new QueryResultModel <AccountQueryResultModel>(); var paging = model.Paging(); var list = await _accountRepository.Query(paging, model.UserName, model.Name, model.Phone, model.Email); result.Rows = _mapper.Map <List <AccountQueryResultModel> >(list); result.Total = paging.TotalCount; Parallel.ForEach(result.Rows, async item => { var roles = await _accountRoleRepository.QueryRole(item.Id); item.Roles = roles.Select(r => new OptionResultModel { Label = r.Name, Value = r.Id }).ToList(); }); return(ResultModel.Success(result)); }
public async Task <QueryResultModel <AccountEntity> > Query(AccountQueryModel model) { var paging = model.Paging(); var query = dbSet.AsQueryable(); if (model.status != null) { query = query.Where(a => a.Status == model.status); } if (!model.keyword.IsNull()) { query = query.Where(a => a.LoginName.Contains(model.keyword) || a.Phone.Contains(model.keyword) || a.RealName.Contains(model.keyword)); } if (!paging.OrderBy.Any()) { query = query.OrderByDescending(m => m.CreatedTime); } return(await query.PaginationGetResult(paging)); }
public async Task <IList <AccountEntity> > Query(AccountQueryModel model) { var paging = model.Paging(); var query = Db.Find(); query.WhereNotNull(model.Type, m => m.Type == model.Type.Value); query.WhereNotNull(model.UserName, m => m.UserName.Contains(model.UserName)); query.WhereNotNull(model.Name, m => m.Name.Contains(model.Name)); query.WhereNotNull(model.Phone, m => m.Phone == model.Phone); query.WhereNotNull(model.Email, m => m.Email == model.Email); var joinQuery = query.LeftJoin <TenantEntity>((x, y) => x.TenantId == y.Id); if (!paging.OrderBy.Any()) { joinQuery.OrderByDescending((x, y) => x.Id); } //不适用租户过滤功能 var list = await joinQuery.NotFilterTenant().PaginationAsync(paging); model.TotalCount = paging.TotalCount; return(list); }