Commision with grouos response
This commit is contained in:
@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@ -96,10 +97,20 @@ public class CommisionController extends TokenBasedController {
|
||||
|
||||
@GetMapping("/user")
|
||||
@ApiOperation("Return list of user all commisions (history of schedules)")
|
||||
public ResponseEntity<List<CommisionResponse>> getAlCommisions() throws UserNotFoundException {
|
||||
public ResponseEntity<List<? extends CommisionResponse>> getAlCommisions(
|
||||
@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.getCurrentUser().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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user