rest design for object related

35 views Asked by At

A lodger can have many reference and a reference is only associated to one lodger

I created a method to search reference related to a lodgerId

@RequestMapping(value = "/lodgers/{lodgerId}/references", method = RequestMethod.GET)
public Reference getReferenceByUserId(@PathVariable("lodgerId") long lodgerId) {
    return referenceService.getReferenceByLodgerId(lodgerId);
}

In term of design, it's it better to put it in the rest controller related to lodger or reference

1

There are 1 answers

0
Sarfaraz Khan On

If you are using any orm,JPA,etc then getting the references for a particular lodger becomes a very natural choice to be put into the controller related to lodger and operation related a particular reference in reference controller. Even if you are not using any any of the mention framework the above set up seems very obvious.