public async Task <LayerTableJson> LayuiTableList([FromBody] SearchRoleRequest search) { var response = new LayerTableJson(); if (search.Page == 0) { throw new ZCustomizeException(ResponseCodeEnum.ModelStateInvalid, "本接口仅支持页数从1开始"); } try { response = await _roleManager.LayuiTableListAsync(search, HttpContext.RequestAborted); } catch (Exception e) { response.Code = 500; response.Msg = "用户列表查询失败,请重试"; _logger.LogInformation($"用户列表查询失败异常:{JsonHelper.ToJson(e)}"); } return(response); }
/// <summary> /// 列表数据 /// </summary> /// <param name="search"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <LayerTableJson> LayuiTableListAsync(SearchRoleRequest search, CancellationToken cancellationToken = default(CancellationToken)) { var response = new LayerTableJson() { }; var entity = _roleStore.IQueryableListAsync().Where(y => !y.IsDeleted); if (!string.IsNullOrWhiteSpace(search.Name)) { entity = entity.Where(y => y.Name.Contains(search.Name)); } response.Count = await entity.CountAsync(cancellationToken); var list = await entity.Skip(((search.Page ?? 0) - 1) *search.Limit ?? 0).Take(search.Limit ?? 0).ToListAsync(cancellationToken); var info = _mapper.Map <List <RoleListResponse> >(list); info.ForEach(item => { item.AuthorizeName = GetAuthorizeName(item.Id); }); response.Data = info; return(response); }