API's met returns van objecten
This commit is contained in:
@@ -37,12 +37,15 @@ public class AppointmentResource {
|
||||
return appointmentService.getAppointmentsByDate(start, companyId);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/recent/{id}")
|
||||
public Appointment getMostRecentAppointment(@PathParam("id") Long userId) {
|
||||
return appointmentService.getMostRecentByUserId(userId);
|
||||
}
|
||||
|
||||
//TODO: Deze werkend maken
|
||||
|
||||
// @GET
|
||||
// @Produces(MediaType.APPLICATION_JSON)
|
||||
// @Path("/recent/{id}")
|
||||
// public Appointment getMostRecentAppointment(@PathParam("id") Long userId) {
|
||||
// return appointmentService.getMostRecentByUserId(userId);
|
||||
// }
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@@ -56,8 +59,7 @@ public class AppointmentResource {
|
||||
public Response addAppointment(Appointment appointment) {
|
||||
JsonNumber companyIdJson = jwt.getClaim("company_id");
|
||||
Long companyId = companyIdJson.longValue();
|
||||
appointmentService.add(appointment, companyId);
|
||||
return Response.ok().build();
|
||||
return Response.ok(appointmentService.add(appointment, companyId)).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -70,7 +72,6 @@ public class AppointmentResource {
|
||||
@PUT
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response updateAppointment(Appointment appointment) {
|
||||
appointmentService.update(appointment);
|
||||
return Response.ok().build();
|
||||
return Response.ok(appointmentService.update(appointment)).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public class CustomerResource {
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response addCustomer(Customer customer) {
|
||||
customerService.addCustomer(customer);
|
||||
return Response.ok().build();
|
||||
return Response.ok(customerService.addCustomer(customer)).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,12 @@ public class AppointmentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void add(Appointment appointment, Long companyId) {
|
||||
public Appointment add(Appointment appointment, Long companyId) {
|
||||
Company company = companyRepository.findById(companyId);
|
||||
appointment.setCompany(company);
|
||||
appointmentRepository.persist(appointment);
|
||||
emailService.stuurBevestiging(appointment);
|
||||
return appointment;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -59,7 +60,7 @@ public class AppointmentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void update(Appointment appointment) {
|
||||
public Appointment update(Appointment appointment) {
|
||||
Appointment appointmentToUpdate = appointmentRepository.findById(appointment.getId());
|
||||
appointmentToUpdate.setTitle(appointment.getTitle());
|
||||
appointmentToUpdate.setStartDate(appointment.getStartDate());
|
||||
@@ -72,6 +73,7 @@ public class AppointmentService {
|
||||
appointmentToUpdate.setDurationInMinutes(appointment.getDurationInMinutes());
|
||||
appointmentRepository.persist(appointmentToUpdate);
|
||||
emailService.stuurBewerking(appointmentToUpdate);
|
||||
return appointmentToUpdate;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -28,7 +28,8 @@ public class CustomerService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addCustomer(Customer customer) {
|
||||
public Customer addCustomer(Customer customer) {
|
||||
customerRepository.persist(customer);
|
||||
return customer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user