Deanery response
This commit is contained in:
parent
f31a50aa06
commit
7c457ce232
@ -117,11 +117,19 @@ public class CommisionController extends TokenBasedController {
|
|||||||
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
||||||
@GetMapping("/user/{id}")
|
@GetMapping("/user/{id}")
|
||||||
@ApiOperation("Return list of commisions for given user. To be able to access this data u need to provide DEANERY token")
|
@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 {
|
throws UserNotFoundException {
|
||||||
User user = this.userService.getById(userId).orElseThrow(() -> new NullPointerException());
|
User user = this.userService.getById(userId).orElseThrow(() -> new NullPointerException());
|
||||||
List<CommisionResponse> result = CommisionResponseMappers
|
List<? extends CommisionResponse> result;
|
||||||
.mapToResponse(this.commisionService.getUsersCommisions(user));
|
|
||||||
|
if (!groups) {
|
||||||
|
result = CommisionResponseMappers.mapToResponse(this.commisionService.getUsersCommisions(user));
|
||||||
|
} else {
|
||||||
|
result = CommisionResponseMappers
|
||||||
|
.mapToResponseWithGroups(this.commisionService.getUsersCommisions(user));
|
||||||
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user