0
我已經設法安裝Apigility + Doctrine並返回單個實體(/ service/x_id)和集合(/ service)的結果,這個開箱即用修改。Apigility + Doctrine:如何返回分頁集合
我現在處於根據URL參數返回過濾結果的階段。
我可以檢索url參數,我可以檢索過濾結果。爲此,我在自己的ResourceClass中擴展了fetch *()方法。它工作正常,但是這個結果沒有分頁,並且與其他響應(即開即用的響應)沒有相同的HAL/Json格式。我回國的getEntityManager('my.em.name')->getRepository(my.repo.name)->findBy($params)
的結果,它實際上是這樣的:
{
"_links":
{
"self":
{
"href": "http://api.local/service?startcode=7531"
}
},
"_embedded":
{
"objektprojectstart":
[
{
"oid": 14427,
"opsId": 3760,
"startcode": "7531",
"tid": 44798,
"_links":
{
"self":
{
"href": "http://studoraapi.local/service/3760"
}
}
},
{... more},
,這是什麼問題,正確的解決方案?謝謝!
答案以何種方式不一樣?請更具體地說明你所得到的迴應與你想要的迴應之間的差異。 – Wilt
格式不一樣,在適當的HAL響應中,您會看到總數,鏈接,頁面等,如下所示: '{「_links」:{「self」: {「href」:「 ...「}, 」first「:{」href「:」...「}, 」last「:{」href「:」...「}}, 」_embedded「:{ 」objektprojectstart 「: }, 」page_count「:1, 」page_size「:25,」{「oid」:14473,「opsId」:3791,「startcode」:「7531」,「tid」:44845, 「total_items」:1, 「page」:1 }'(抱歉格式)所以這個問題基本上是爲什麼發生這種情況,以及如何解決它,謝謝你的時間。 – repara2