Added new /config/tours, tests
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
@ -82,6 +82,28 @@ public class ConfigController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(path = "/config/tours")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@ApiOperation("Set tours dates. To call you need to provide ADMIN token")
|
||||
public ResponseEntity<String> configToursApp(
|
||||
@RequestParam("firstTourBegin") @DateTimeFormat(pattern = "dd.MM.yyyy") @ApiParam(value = "Date when first tour begin in format dd.MM.yyyy") Date firstTourBegin,
|
||||
@RequestParam("firstTourEnd") @DateTimeFormat(pattern = "dd.MM.yyyy") @ApiParam(value = "Date when first tour ends in format dd.MM.yyyy") Date firstTourEnd,
|
||||
@RequestParam("secondTourBegin") @DateTimeFormat(pattern = "dd.MM.yyyy") @ApiParam(value = "Date when second tour begin in format dd.MM.yyyy") Date secondTourBegin,
|
||||
@RequestParam("secondTourEnd") @DateTimeFormat(pattern = "dd.MM.yyyy") @ApiParam(value = "Date when second tour ends in format dd.MM.yyyy") Date secondTourEnd) {
|
||||
if (!(firstTourBegin.before(firstTourEnd)
|
||||
&& (firstTourEnd.before(secondTourBegin) || firstTourEnd.equals(secondTourBegin))
|
||||
&& secondTourBegin.before(secondTourEnd))) {
|
||||
return new ResponseEntity<>("Bad dates", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
final TourData firstTour = new TourData(firstTourBegin, firstTourEnd);
|
||||
final TourData secondTour = new TourData(secondTourBegin, secondTourEnd);
|
||||
|
||||
this.contrl.saveTours(firstTour, secondTour);
|
||||
return new ResponseEntity<>("Sucess", HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping(path = "/config/courses", consumes = { "multipart/form-data" })
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@ApiOperation("Imports data to system. To call you need to provide ADMIN token")
|
||||
|
Reference in New Issue
Block a user