宿泊者は多くの予定を持つことができます。
現在、私が使用している下宿人の予約を取得するために
@RequestMapping(value = "/lodgers/{lodgerId}/appointments", method = RequestMethod.GET)
public Lodger getAppointmentsByLogderId(@PathVariable("lodgerId") long lodgerId) {
return lodgerService.getLodger(lodgerId);
}
日付の関数ですべてのユーザーのすべての予定を取得するには、さまざまな方法で実行できると考えています。
私の最初のアイデアは、これのための新しいリソースを作成することでした
@RequestMapping(value = "/appointments", method = RequestMethod.GET)
public List<Appointment> getAllAppointments(@RequestParam("startDate") Date startDate, @RequestParam("endDate") Date endDate) {
...
}
しかし、私はこの方法でもそれを行うことができると思います
@RequestMapping(value = "/lodgers/appointments", method = RequestMethod.GET)
public Lodger getAllLodgerAppointmentsByDate(@RequestParam("startDate") Date startDate, @RequestParam("endDate") Date endDate) {
...
}
創作も同じこと
Appointment is related to a lodger
@RequestMapping(value = "/lodgers/{lodgerId}appointments", method = RequestMethod.POST)
public Lodger createAppointment(@RequestParam("lodgerId")Long lodgerId, @RequestBody Appointment appointment) {
...
}
@RequestMapping(value = "/appointments/", method = RequestMethod.POST)
public Lodger createAppointment(@RequestBody Appointment appointment) {
...
}
ウィッチケースのほうがいい