new endpoint testd
This commit is contained in:
@ -2,6 +2,7 @@ package com.plannaplan.controllers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.plannaplan.App;
|
||||
import com.plannaplan.entities.Groups;
|
||||
@ -60,18 +61,19 @@ public class GroupController {
|
||||
return new ResponseEntity<>(GroupsMappers.mapToGetCourseGroupsDefaultResponse(groups), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
||||
@PutMapping("/{id}/capacity")
|
||||
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
||||
@ApiOperation(value = "Change capacity of given group. You need to provide DEANERY token to be ale to change capacity")
|
||||
public ResponseEntity<String> updateCapacity(
|
||||
@PathVariable(name = "id", required = true) @ApiParam(value = "id of group to change capacity") Long id,
|
||||
@RequestParam(name = "newcapacity", required = true) Integer newcapacity) {
|
||||
final Groups group = this.groupService.getGroupById(id).get();
|
||||
if (group == null) {
|
||||
final Optional<Groups> group = this.groupService.getGroupById(id);
|
||||
if (group.isEmpty()) {
|
||||
return new ResponseEntity<>("Given group doens't exist", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
group.setCapacity(newcapacity);
|
||||
this.groupService.save(group);
|
||||
final Groups gr = group.get();
|
||||
gr.setCapacity(newcapacity);
|
||||
this.groupService.save(gr);
|
||||
return new ResponseEntity<>("Success", HttpStatus.OK);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user