Skip to content
Snippets Groups Projects
Commit fa085849 authored by Diana Gulčíková's avatar Diana Gulčíková
Browse files

Merge branch 'milestone_2' into client_to_call_endpoints

# Conflicts:
#	common_library/src/main/java/cz/muni/pa165/common_library/dtos/DriverInsightDto.java
#	common_library/src/main/resources.mv.db
#	driver/src/main/java/cz/muni/pa165/driver/data/model/Driver.java
#	driver/src/main/java/cz/muni/pa165/driver/service/CarServiceImpl.java
parents aeb71058 c39085e3
No related branches found
No related tags found
2 merge requests!60Docker,!38Client to call endpoints
...@@ -18,7 +18,6 @@ public record DriverInsightDto(@NotNull Long id, ...@@ -18,7 +18,6 @@ public record DriverInsightDto(@NotNull Long id,
"Aggressiveness", "Aggressiveness",
"Consistency", "Consistency",
"Racecraft"}) "Racecraft"})
Map<String, Integer> characteristics Map<String, Integer> characteristics) {
) {
} }
No preview for this file type
package cz.muni.pa165.driver.data.model; package cz.muni.pa165.driver.data.model;
import jakarta.persistence.CascadeType;
import jakarta.persistence.CollectionTable; import jakarta.persistence.CollectionTable;
import jakarta.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
...@@ -8,8 +7,6 @@ import jakarta.persistence.FetchType; ...@@ -8,8 +7,6 @@ import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType; import jakarta.persistence.GenerationType;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.MapKeyColumn; import jakarta.persistence.MapKeyColumn;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Max;
......
package cz.muni.pa165.driver.rest; package cz.muni.pa165.driver.rest;
import cz.muni.pa165.common_library.dtos.DriverAddDto; import cz.muni.pa165.common_library.dtos.DriverAddDto;
import cz.muni.pa165.common_library.dtos.DriverCarDto;
import cz.muni.pa165.common_library.dtos.DriverInsightDto; import cz.muni.pa165.common_library.dtos.DriverInsightDto;
import cz.muni.pa165.common_library.dtos.DriverResponseDto; import cz.muni.pa165.common_library.dtos.DriverResponseDto;
import cz.muni.pa165.common_library.dtos.DriverUpdateDto; import cz.muni.pa165.common_library.dtos.DriverUpdateDto;
import cz.muni.pa165.driver.service.CarService;
import cz.muni.pa165.driver.service.DriverService; import cz.muni.pa165.driver.service.DriverService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -32,19 +31,25 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -32,19 +31,25 @@ import org.springframework.web.bind.annotation.RestController;
public class DriverController { public class DriverController {
private final DriverService driverService; private final DriverService driverService;
private final CarService carService;
@Autowired @Autowired
public DriverController(DriverService driverService, CarService carService) { public DriverController(DriverService driverService) {
this.driverService = driverService; this.driverService = driverService;
this.carService = carService;
} }
@Operation(summary = "Add a specific driver to the team") @Operation(summary = "Add a specific driver to the team")
@PostMapping(path = "/add", consumes = MediaType.APPLICATION_JSON_VALUE, @PostMapping(path = "/add", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DriverResponseDto> addDriver( public ResponseEntity<DriverResponseDto> addDriver(
@Valid @RequestBody DriverAddDto driverAddDto) { @Valid
@RequestBody
@Schema(example = "{\"name\":\"Fernando\", "
+ "\"surname\": \"Alonso\", "
+ "\"nationality\": \"Spanish\", "
+ "\"characteristics\" : {\"Experience\" : 1,"
+ " \"Aggressiveness\" : 1,"
+ " \"Consistency\" : 1,"
+ " \"Racecraft\" : 1 }}") DriverAddDto driverAddDto) {
return ResponseEntity.ok(driverService.addDriver(driverAddDto)); return ResponseEntity.ok(driverService.addDriver(driverAddDto));
} }
...@@ -56,20 +61,6 @@ public class DriverController { ...@@ -56,20 +61,6 @@ public class DriverController {
return ResponseEntity.ok(driverService.updateDriverById(id, driverUpdateDto)); return ResponseEntity.ok(driverService.updateDriverById(id, driverUpdateDto));
} }
@Operation(summary = "Makes a driver specified by his id a main driver of its car")
@PutMapping(path = "/set_main/id={id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DriverCarDto> setAsMainDriver(@PathVariable("id") Long id) {
return ResponseEntity.ok(carService.setAsMainDriver(id));
}
@Operation(summary = "Assign driver to a car.")
@PutMapping(path = "/assign/driverId={did}/carId={cid}",
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DriverCarDto> assignDriverToCar(@PathVariable("did") Long did,
@PathVariable("cid") Long cid) {
return ResponseEntity.ok(carService.assignDriverToCar(did, cid));
}
@Operation(summary = "Dismiss a driver specified by his id from the team") @Operation(summary = "Dismiss a driver specified by his id from the team")
@DeleteMapping(path = "/remove/id={id}", produces = MediaType.APPLICATION_JSON_VALUE) @DeleteMapping(path = "/remove/id={id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DriverResponseDto> removeDriverById(@PathVariable("id") Long id) { public ResponseEntity<DriverResponseDto> removeDriverById(@PathVariable("id") Long id) {
......
package cz.muni.pa165.driver.service;
import cz.muni.pa165.common_library.dtos.DriverCarDto;
/**
* Car service interface.
*/
public interface CarService {
/**
* Sets given driver as main driver of his corresponding car.
*
* @param driverId driver id
* @return dto of driver and car
*/
DriverCarDto setAsMainDriver(Long driverId);
/**
* Assign driver to a car.
*
* @param driverId driver id
* @param carId car id
* @return driver car dto response.
*/
DriverCarDto assignDriverToCar(Long driverId, Long carId);
}
package cz.muni.pa165.driver.service;
import cz.muni.pa165.common_library.dtos.DriverCarDto;
import org.springframework.stereotype.Service;
@Service
public class CarServiceImpl implements CarService{
@Override
public DriverCarDto setAsMainDriver(Long driverId) {
return null;
}
@Override
public DriverCarDto assignDriverToCar(Long driverId, Long carId) {
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment