Deanery response

This commit is contained in:
Filip Izydorczyk 2020-12-10 16:19:58 +01:00
parent f31a50aa06
commit 7c457ce232
1 changed files with 11 additions and 3 deletions

View File

@ -117,11 +117,19 @@ public class CommisionController extends TokenBasedController {
@PreAuthorize("hasRole('ROLE_DEANERY')")
@GetMapping("/user/{id}")
@ApiOperation("Return list of commisions for given user. To be able to access this data u need to provide DEANERY token")
public ResponseEntity<List<CommisionResponse>> getCommision(@PathVariable(name = "id") Long userId)
public ResponseEntity<List<? extends CommisionResponse>> getCommision(@PathVariable(name = "id") Long userId,
@RequestParam(name = "groups", defaultValue = "false") @ApiParam(value = "Boolean if we want to display wiht commision's group ids") Boolean groups)
throws UserNotFoundException {
User user = this.userService.getById(userId).orElseThrow(() -> new NullPointerException());
List<CommisionResponse> result = CommisionResponseMappers
.mapToResponse(this.commisionService.getUsersCommisions(user));
List<? extends CommisionResponse> result;
if (!groups) {
result = CommisionResponseMappers.mapToResponse(this.commisionService.getUsersCommisions(user));
} else {
result = CommisionResponseMappers
.mapToResponseWithGroups(this.commisionService.getUsersCommisions(user));
}
return new ResponseEntity<>(result, HttpStatus.OK);
}