/// <summary> /// 获取Manuscript的分页列表信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <PagedResultDto <ManuscriptListDto> > GetPagedManuscripts(GetManuscriptsInput input) { var query = _manuscriptRepository.GetAll() .WhereIf(!string.IsNullOrEmpty(input.Title), m => m.Title.Contains(input.Title)) .WhereIf(!string.IsNullOrEmpty(input.Name), m => m.UserName.Contains(input.Name)) .WhereIf(!string.IsNullOrEmpty(input.Phone), m => m.Phone.Contains(input.Phone)) .WhereIf(input.Status.HasValue, m => m.Status == input.Status); //TODO:根据传入的参数添加过滤条件 var manuscriptCount = await query.CountAsync(); var manuscripts = await query .OrderBy(m => m.Status) .ThenByDescending(m => m.CreationTime) .ThenBy(input.Sorting) .PageBy(input) .ToListAsync(); //var manuscriptListDtos = ObjectMapper.Map<List <ManuscriptListDto>>(manuscripts); var manuscriptListDtos = manuscripts.MapTo <List <ManuscriptListDto> >(); return(new PagedResultDto <ManuscriptListDto>( manuscriptCount, manuscriptListDtos )); }
private async Task <List <ManuscriptListDto> > GetManuscriptsAsync(GetManuscriptsInput input) { //var mid = UserManager.GetControlEmployeeId(); var query = _manuscriptRepository.GetAll() .WhereIf(!string.IsNullOrEmpty(input.Title), m => m.Title.Contains(input.Title)) .WhereIf(!string.IsNullOrEmpty(input.Name), m => m.UserName.Contains(input.Name)) .WhereIf(!string.IsNullOrEmpty(input.Phone), m => m.Phone.Contains(input.Phone)) .WhereIf(input.Status.HasValue, m => m.Status == input.Status);; var manuscripts = await query.ToListAsync(); var manuscriptDtos = manuscripts.MapTo <List <ManuscriptListDto> >(); return(manuscriptDtos); }
public async Task <APIResultDto> ExportManuscriptsExcel(GetManuscriptsInput input) { try { var exportData = await GetManuscriptsAsync(input); var result = new APIResultDto(); result.Code = 0; result.Data = SaveManuscriptsExcel("投稿管理.xlsx", exportData); return(result); } catch (Exception ex) { Logger.ErrorFormat("ExportPostInfoExcel errormsg:{0} Exception:{1}", ex.Message, ex); return(new APIResultDto() { Code = 901, Msg = "网络忙... 请待会重试!" }); } }