API's met returns van objecten
Some checks failed
Docker Image CI / build-and-push (push) Failing after 20s
Docker Image CI / deploy (push) Has been skipped

This commit is contained in:
2025-03-22 16:55:46 +01:00
parent 2a50edc41d
commit 40f983980d
4 changed files with 18 additions and 15 deletions

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -28,7 +28,8 @@ public class CustomerService {
}
@Transactional
public void addCustomer(Customer customer) {
public Customer addCustomer(Customer customer) {
customerRepository.persist(customer);
return customer;
}
}