From 7c457ce2325f78a4e3a4b0852da3b2e81b9b3a49 Mon Sep 17 00:00:00 2001 From: Filip Izydorczyk Date: Thu, 10 Dec 2020 16:19:58 +0100 Subject: [PATCH] Deanery response --- .../controllers/CommisionController.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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); }