|
@@ -2,15 +2,12 @@ package pl.sudra.controller;
|
|
|
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-//import pl.sudra.domain.Bill;
|
|
|
|
|
-//import pl.sudra.domain.Reservation;
|
|
|
|
|
import pl.sudra.domain.Bill;
|
|
import pl.sudra.domain.Bill;
|
|
|
import pl.sudra.domain.Reservation;
|
|
import pl.sudra.domain.Reservation;
|
|
|
import pl.sudra.repository.UserRepository;
|
|
import pl.sudra.repository.UserRepository;
|
|
|
import pl.sudra.service.BillService;
|
|
import pl.sudra.service.BillService;
|
|
|
import pl.sudra.service.BoatService;
|
|
import pl.sudra.service.BoatService;
|
|
|
import pl.sudra.service.ReservationService;
|
|
import pl.sudra.service.ReservationService;
|
|
|
-import pl.sudra.service.UserService;
|
|
|
|
|
|
|
|
|
|
import java.sql.Date;
|
|
import java.sql.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -31,30 +28,12 @@ public class ReservationController {
|
|
|
this.userRepository = userRepository;
|
|
this.userRepository = userRepository;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(
|
|
|
|
|
- value = "/generateReservations",
|
|
|
|
|
- method = RequestMethod.GET,
|
|
|
|
|
- produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
- public void generateReservations(@RequestParam("n") int n) {
|
|
|
|
|
- System.out.println("Generation of reservations");
|
|
|
|
|
- this.reservationService.generateReservations(n);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@RequestMapping(
|
|
@RequestMapping(
|
|
|
value = "/createReservation",
|
|
value = "/createReservation",
|
|
|
method = RequestMethod.POST,
|
|
method = RequestMethod.POST,
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public void createReservation(@RequestBody Reservation reservation) {
|
|
public void createReservation(@RequestBody Reservation reservation) {
|
|
|
System.out.println("Creating reservation");
|
|
System.out.println("Creating reservation");
|
|
|
-// Bill bill = new Bill();
|
|
|
|
|
-
|
|
|
|
|
-// bill.setReservation(reservation);
|
|
|
|
|
-// System.out.println(reservation.getBoatId());
|
|
|
|
|
-// bill.setTotalCost(
|
|
|
|
|
-// this.boatService.getBoat(reservation.getBoatId()).getCost()
|
|
|
|
|
-// * (reservation.getEndHour() - reservation.getStartHour()));
|
|
|
|
|
-// bill.setIssueDate(new java.sql.Date());
|
|
|
|
|
-// bill.setStatus(false);
|
|
|
|
|
Bill bill = new Bill(
|
|
Bill bill = new Bill(
|
|
|
reservation,
|
|
reservation,
|
|
|
"Pending",
|
|
"Pending",
|
|
@@ -76,7 +55,7 @@ public class ReservationController {
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public List<Reservation> findReservations(@RequestParam("boat_id") Long boat_id,
|
|
public List<Reservation> findReservations(@RequestParam("boat_id") Long boat_id,
|
|
|
@RequestParam("date") Date date) {
|
|
@RequestParam("date") Date date) {
|
|
|
- System.out.println("Looking for reservations");
|
|
|
|
|
|
|
+ System.out.println("Looking for reservations by boat id and date");
|
|
|
return this.reservationService.findReservations(boat_id, date);
|
|
return this.reservationService.findReservations(boat_id, date);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -85,7 +64,7 @@ public class ReservationController {
|
|
|
method = RequestMethod.GET,
|
|
method = RequestMethod.GET,
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public List<Reservation> findReservationsOfUsername(@RequestParam("user_id") Long user_id) {
|
|
public List<Reservation> findReservationsOfUsername(@RequestParam("user_id") Long user_id) {
|
|
|
- System.out.println("Looking for reservations");
|
|
|
|
|
|
|
+ System.out.println("Looking for reservations by user id");
|
|
|
return this.reservationService.findReservationsByUserId(user_id);
|
|
return this.reservationService.findReservationsByUserId(user_id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -94,6 +73,7 @@ public class ReservationController {
|
|
|
method = RequestMethod.GET,
|
|
method = RequestMethod.GET,
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public List<Reservation> findAllReservations() {
|
|
public List<Reservation> findAllReservations() {
|
|
|
|
|
+ System.out.println("Getting all reservations");
|
|
|
return this.reservationService.getReservations();
|
|
return this.reservationService.getReservations();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|