diff --git a/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java b/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java index ba5b603..b009fea 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java @@ -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> getCommision(@PathVariable(name = "id") Long userId) + public ResponseEntity> 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 result = CommisionResponseMappers - .mapToResponse(this.commisionService.getUsersCommisions(user)); + List result; + + if (!groups) { + result = CommisionResponseMappers.mapToResponse(this.commisionService.getUsersCommisions(user)); + } else { + result = CommisionResponseMappers + .mapToResponseWithGroups(this.commisionService.getUsersCommisions(user)); + } + return new ResponseEntity<>(result, HttpStatus.OK); }