Class CarController

java.lang.Object
com.Server.controller.CarController

@RequestMapping("/car")
@RestController
@CrossOrigin
public class CarController
extends java.lang.Object
CarController is use to supports operations about database table Car.
Since:
2020-04-27.
Version:
2.0.
Author:
Krystian Cwioro Kamil Bieniasz Damian Mierzynski.
  • Field Summary

    Fields
    Modifier and Type Field Description
    private CarService carServiceImpl
    carService operation on database table Car
    private LocalizationService localizationServiceImpl
    LocationService operation on database table Localization
    private static org.slf4j.Logger logger
    Logger use to logger on server.
    private ReservationService reservationServiceImpl
    ReservationService operation on database table reservation
  • Constructor Summary

    Constructors
    Constructor Description
    CarController​(CarService carServiceImpl, ReservationService reservationServiceImpl, LocalizationService localizationServiceImpl)
    Constructor
  • Method Summary

    Modifier and Type Method Description
    org.springframework.http.ResponseEntity<?> addCar​(@Valid CarRequest carRequest)
    This method add car.
    org.springframework.http.ResponseEntity<?> deleteCar​(int id)
    This method delete car.
    org.springframework.http.ResponseEntity<?> editCar​(int id, CarRequest carRequest)
    This method edit car.
    org.springframework.http.ResponseEntity<?> getCar​(int id)
    This method get car about id.
    org.springframework.http.ResponseEntity<java.util.List<CarResponse>> showCarAll()
    This method get all car.
    org.springframework.http.ResponseEntity<?> showCarLocalization​(java.lang.String city)
    This method get car about localization This method use endpoint /car/get-car-localization.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      private static final org.slf4j.Logger logger
      Logger use to logger on server.
    • carServiceImpl

      private final CarService carServiceImpl
      carService operation on database table Car
    • reservationServiceImpl

      private final ReservationService reservationServiceImpl
      ReservationService operation on database table reservation
    • localizationServiceImpl

      private final LocalizationService localizationServiceImpl
      LocationService operation on database table Localization
  • Constructor Details

  • Method Details

    • addCar

      @PostMapping("/add-car") public org.springframework.http.ResponseEntity<?> addCar​(@Valid @RequestBody @Valid CarRequest carRequest) throws WrongDataException
      This method add car. This method use endpoint /car/addcar.
      Parameters:
      carRequest - data new car.
      Returns:
      Data added new car Http.Status 200 or 400.
      Throws:
      WrongDataException - when localization not exist
    • showCarAll

      @GetMapping("/show-car-all") public org.springframework.http.ResponseEntity<java.util.List<CarResponse>> showCarAll()
      This method get all car. This method use endpoint /car/show-car-all.
      Returns:
      List all Car Http.Status 200 or 400.
    • showCarLocalization

      @ResponseBody @GetMapping("/get-car-localization") public org.springframework.http.ResponseEntity<?> showCarLocalization​(@RequestParam java.lang.String city)
      This method get car about localization This method use endpoint /car/get-car-localization.
      Parameters:
      city - name city.
      Returns:
      List all Car Http.Status 200 or 400.
      Throws:
      WrongDataException - when localization not exist
    • deleteCar

      @PreAuthorize("hasRole(\'ADMIN\')") @DeleteMapping("/delete-car") public org.springframework.http.ResponseEntity<?> deleteCar​(@RequestParam int id)
      This method delete car. This method use endpoint /car/delete-car.
      Parameters:
      id - id car on delete
      Returns:
      Http.Status 200 or 400.
    • getCar

      @ResponseBody @GetMapping("/get-car") public org.springframework.http.ResponseEntity<?> getCar​(@RequestParam int id) throws WrongDataException
      This method get car about id. This method use endpoint /car/get-car.
      Parameters:
      id - id car.
      Returns:
      data car Http.Status 200 or 400..
      Throws:
      WrongDataException - when localization not exist
    • editCar

      @PreAuthorize("hasRole(\'ADMIN\')") @PutMapping("/edit-car") public org.springframework.http.ResponseEntity<?> editCar​(@RequestParam int id, @RequestBody CarRequest carRequest)
      This method edit car. This method use endpoint /car/edit-car.
      Parameters:
      carRequest - new data car.
      Returns:
      Http.Status 200 or 400..
      Throws:
      WrongDataException - when localization not exist