public override async Task <GrpcResponse> GetDict(DictRequest request, ServerCallContext context) { var grpcResponse = new GrpcResponse(); var dict = await _dictAppService.GetAsync(request.Id); if (dict is not null) { var replyDict = _mapper.Map <DictReply>(dict); grpcResponse.Content = Any.Pack(replyDict); } grpcResponse.IsSuccessStatusCode = true; return(grpcResponse); }
public async Task TestGetByRequestAsync() { Stopwatch watch = new Stopwatch(); ApiClient client = new ApiClient("https://www.bing.com/"); DictRequest request = new DictRequest(); watch.Start(); var response = await client.GetAsync(request); watch.Stop(); //Debug.WriteLine(watch.ElapsedMilliseconds); Assert.IsNotNull(response.Content); }
public async Task <IActionResult> GetDictGrpcAsync() { var request = new DictRequest() { Id = RpcConsts.OrderStatusId }; var grpcResult = await _maintGrpcClient.GetDictAsync(request, GrpcClientConsts.BasicHeader); if (grpcResult.IsSuccessStatusCode && grpcResult.Content.Is(DictReply.Descriptor)) { var unpackResult = grpcResult.Content.Unpack <DictReply>(); return(Ok(unpackResult)); } return(NoContent()); }
public JsonResult List(DictRequest request) { request.sortKey = "Sort"; request.sortType = 0; IList <Dict> list = new List <Dict>(); var count = 0; if (!string.IsNullOrEmpty(request.Tid)) { list = _DictIService.GetList(request); count = _DictIService.GetCount(request); } Json reponse = new Json(); reponse.code = 200; reponse.total = count; reponse.data = list; return(Json(reponse)); }
public RequestParams GetWhere(DictRequest request) { if (request == null) { return(null); } RequestParams rp = new RequestParams(); //追加查询参数 if (!string.IsNullOrEmpty(request.Tid)) { rp.Params.Add(new Params() { key = "Tid", value = request.Tid, searchType = EnumBase.SearchType.Eq }); } //添加排序(多个排序条件,可以额外添加) if (!string.IsNullOrEmpty(request.sortKey)) { rp.Sort.Add(new Sort() { key = request.sortKey, searchType = (EnumBase.OrderType)request.sortType }); } else { rp.Sort = null; } //添加分页 if (request.pageIndex > 0) { rp.Paging.pageIndex = request.pageIndex; rp.Paging.pageSize = request.pageSize; } else { rp.Paging = null; } return(rp); }
/// <summary> /// 获取列表 /// </summary> /// <returns></returns> public IList <Dict> GetList(DictRequest request) { RequestParams rp = GetWhere(request); return(dao.GetList(rp)); }
/// <summary> /// 获取当前条件下的总记录 /// </summary> /// <returns></returns> public int GetCount(DictRequest request) { RequestParams rp = GetWhere(request); return(dao.GetCount(rp)); }