/// <summary> /// 查询我的带看 /// </summary> /// <param name="id">Id</param> /// <param name="cancellationToken">验证</param> /// <returns></returns> public virtual async Task <PagingResponseMessage <BeltLookResponse> > SelectMyCustomer(string id, MyBeltLookCondition condition, CancellationToken cancellationToken = default(CancellationToken)) { var reponse = new PagingResponseMessage <BeltLookResponse>(); var list = new List <BeltLookResponse>(); var q = _ibeltLookStore.BeltLookAll().Where(x => !x.IsDeleted).Where(x => x.UserId == id); reponse.TotalCount = await q.CountAsync(); if (condition != null) { if (condition.mark == 1) { q = q.Where(x => x.BeltState == BeltLookState.WaitLook); } else if (condition.mark == 2) { q = q.Where(x => x.BeltState == BeltLookState.WaitDeal); } else if (condition.mark == 3) { q = q.Where(x => x.BeltState == BeltLookState.EndDeal); } else if (condition.mark == 4) { q = q.Where(x => x.BeltState == BeltLookState.Cancel); } } q = q.OrderByDescending(x => x.BeltTime).Skip(condition.pageIndex * condition.pageSize).Take(condition.pageSize); var result = await q.ToListAsync(); list.AddRange(_mapper.Map <List <BeltLookResponse> >(result)); reponse.PageIndex = condition.pageIndex; reponse.PageSize = condition.pageSize; reponse.Extension = list; return(reponse); }
public async Task <PagingResponseMessage <BeltLookResponse> > GetMyBeltLook(UserInfo user, [FromBody] MyBeltLookCondition condition) { Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起请求根据条件获取我的带看信息(GetMyBeltLook):\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : "")); var response = new PagingResponseMessage <BeltLookResponse>(); if (condition == null) { response.Code = ResponseCodeDefines.ArgumentNullError; response.Message = "参数出错"; Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})根据条件获取我的带看信息(GetMyBeltLook)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : "")); return(response); } try { response = await _beltLookManager.SelectMyCustomer(user.Id, condition, HttpContext.RequestAborted); } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})根据条件获取我的带看信息(GetMyBeltLook)请求失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : "")); } return(response); }