0

我是 NGRX 数据的新手。我正在使用 GetWithQuery 从后端返回记录子集。GetWithQuery 依赖于查询参数,例如:

getWithQuery(queryParams: string | QueryParams | any): any {
  return this.http.get<ManufacturerListEntity[]>('https://localhost:5001/api/plan/manufacturers', 
    {params: queryParams}).pipe()
}

在服务器上使用如下:

[HttpGet]
public async Task<ActionResult<IEnumerable<ManufacturerDto>>> GetManufacturerList()
{
  string id = HttpContext.Request.Query["supplierId"].ToString();
  if (id == "null")
  {
     return BadRequest("Supplier Id may not be null");
  }
  ...

我宁愿消费这个:

[HttpGet("{supplierId}/manufacturers")]
  public async Task<ActionResult<IEnumerable<ManufacturerDto>>> GetManufacturersBySupplierId(Guid 
    supplierId)
  {
     var mfts = await _planModule.ExecuteQueryAsync(new GetManufacturersQuery(supplierId));
     return Ok(mfts);
  }

但我不知道如何让 NRGX Data 调用此端点:

return this.http.get<ManufacturerDto[]>(this.plan_suppliersApiUrl + '/' + supplierId + '/manufacturers')

或者像这样的端点:

return this.http.get<ProductDto[]>(this.plan_suppliersApiUrl + '/' + supplierId + '/manufacturers/' + manufacturerId + '/products)

NGRX 数据可以做到这一点吗?

谢谢。

4

0 回答 0