0

我有公司/部门的 REST 服务。包含部门的公司。

我已经为公司和部门编写了 CRUD 服务,但是当我检索具有 id 的公司时,我希望公司对象应该进行嵌套的 REST API 调用并以分层方式显示该公司的所有部门。

像这样的东西:

<company>
    <companyId> 1001 </companyId>
    <companyName>company name</companyName>
    <departments>
        <depaId>1111</depId>
        <depName>dep name1</depName>
        <depaId>2222</depId>
        <depName>dep name2</depName>
    </departments> 
</company>

如果有人对 REST 嵌套调用有一些想法,请告诉我。

4

1 回答 1

0

Are departments shared between companies? by that, I mean is one company's marketing department basically the same thing as another company's, or are they seperate concepts? If the former, what you have are simply two resource collections. You should treat them as such, and link from the company to the departments.

<company>
    <link rel="department" href="/departments/5" />
    ...
</company>
于 2012-11-24T12:47:33.447 回答