Deanery response
This commit is contained in:
parent
f31a50aa06
commit
7c457ce232
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user