initial commit

This commit is contained in:
2025-03-04 21:21:35 +01:00
commit 882bc0f26b
34 changed files with 2442 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
package nl.veenm.paypoint.resource;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import nl.veenm.paypoint.domain.Appointment;
import nl.veenm.paypoint.service.AppointmentService;
import java.util.List;
@Path("/api/appointments")
@RolesAllowed({"ADMIN", "USER"})
public class AppointmentResource {
@Inject
AppointmentService appointmentService;
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Appointment> getAppointments() {
return appointmentService.getAllAppointments();
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/date")
public List<Appointment> getAppointmentsByDate(@QueryParam("start") String start) {
return appointmentService.getAppointmentsByDate(start);
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/recent/{id}")
public Appointment getMostRecentAppointment(@PathParam("id") Long userId) {
return appointmentService.getMostRecentByUserId(userId);
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
public Appointment getAppointmentById(@PathParam("id") Long id) {
return appointmentService.getAppointment(id);
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response addAppointment(Appointment appointment) {
System.out.println(appointment);
appointmentService.add(appointment);
return Response.ok().build();
}
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public Response deleteAppointment(@QueryParam("id") Long id) {
appointmentService.delete(id);
return Response.ok().build();
}
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public Response updateAppointment(Appointment appointment) {
appointmentService.update(appointment);
return Response.ok().build();
}
}