1

一个房客可以有很多约会。

目前为我使用的房客预约

@RequestMapping(value = "/lodgers/{lodgerId}/appointments", method = RequestMethod.GET)
public Lodger getAppointmentsByLogderId(@PathVariable("lodgerId") long lodgerId) {
    return lodgerService.getLodger(lodgerId);
}

为了让所有用户根据日期获得所有约会,我认为我们可以通过多种方式进行。

我的第一个想法是为此在 AppointmentController RestController 中创建一个新的资源

@RequestMapping(value = "/appointments", method = RequestMethod.GET)
public List<Appointment> getAllAppointments(@RequestParam("startDate") Date startDate, @RequestParam("endDate") Date endDate) {
    ...
}

但我也可以这样做,我认为在 LodgerController RestController

@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) {
    ...
}

女巫案更好

4

0 回答 0