/// <summary> /// 列表数据 /// </summary> /// <param name="search"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <LayerTableJson> LayuiTableListAsync(SearchUserRequest search, CancellationToken cancellationToken) { var response = new LayerTableJson(); var entity = _userStore.IQueryableListAsync().Where(y => !y.IsDeleted); if (!string.IsNullOrWhiteSpace(search.RoleName)) { // entity = entity.Where(y=>y.listRole.Contains(search.RoleName)); } if (!string.IsNullOrWhiteSpace(search.PhoneNumber)) { entity = entity.Where(y => y.PhoneNumber.Contains(search.PhoneNumber)); } if (!string.IsNullOrWhiteSpace(search.TrueName)) { entity = entity.Where(y => y.TrueName.Contains(search.TrueName)); } if (!string.IsNullOrWhiteSpace(search.UserName)) { entity = entity.Where(y => y.UserName.Contains(search.UserName)); } response.Count = await entity.CountAsync(y => y.Id != null, cancellationToken); var list = await entity.Skip(((search.Page ?? 0) - 1) *search.Limit ?? 0).Take(search.Limit ?? 0).ToListAsync(cancellationToken); var result = _mapper.Map <List <UserListResponse> >(list); result.ForEach(y => { // 改成同步方法才不会报错 y.RoleName = GetRoleName(y.Id); }); response.Data = result; return(response); }
public async Task <LayerTableJson> ProductList([FromBody] LayuiTableRequest search) { var response = new LayerTableJson() { }; try { response = await _prodoctManager.LayuiProductListAsync(search, HttpContext.RequestAborted); } catch (Exception e) { response.Code = 500; response.Msg = "商品列表查询失败,请重试"; _logger.LogInformation($"商品列表查询失败异常:{JsonHelper.ToJson(e)}"); } return(response); }
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(SearchPermissionRequest search, CancellationToken cancellationToken) { var response = new LayerTableJson() { }; var entity = _permissionStore.IQueryableListAsync().Where(y => !y.IsDeleted);; if (!string.IsNullOrWhiteSpace(search.Name)) { entity = entity.Where(y => y.Name == search.Name); } if (!string.IsNullOrWhiteSpace(search.Code)) { entity = entity.Where(y => y.Code == search.Code); } response.Count = await entity.CountAsync(cancellationToken); var list = await entity.Skip(((search.Page ?? 0) - 1) *search.Limit ?? 0).Take(search.Limit ?? 0).ToListAsync(cancellationToken); response.Data = list; return(response); }
/// <summary> /// 兼容Layui表格数据结构得商品列表 /// </summary> /// <param name="search"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <LayerTableJson> LayuiProductListAsync(LayuiTableRequest search, CancellationToken cancellationToken) { var response = new LayerTableJson() { }; var entity = _ProductStore.IQueryableListAsync(); if (!string.IsNullOrWhiteSpace(search.Name)) { entity = entity.Where(y => y.Title.Contains(search.Name)); } if (!string.IsNullOrWhiteSpace(search.CateId)) { entity = entity.Where(y => y.CateId == search.CateId); } 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 data = _mapper.Map <List <ProductListResponse> >(list); var img = await _filesStore.IQueryableListAsync().Where(y => data.Select(pro => pro.Id).Contains(y.ProductId) && !y.IsDeleted).ToListAsync(cancellationToken); data.ForEach(item => { if (img.Where(y => y.ProductId == item.Id).Any()) { item.Files = img.Select(y => y.Url).ToList(); } else { item.Files = new List <string>() { }; } }); response.Data = data; 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); }