diff --git a/restservice/src/main/java/com/plannaplan/controllers/GroupController.java b/restservice/src/main/java/com/plannaplan/controllers/GroupController.java index 42d2742..3424c95 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/GroupController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/GroupController.java @@ -13,9 +13,11 @@ import com.plannaplan.services.GroupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -57,4 +59,17 @@ public class GroupController { } return new ResponseEntity<>(GroupsMappers.mapToGetCourseGroupsDefaultResponse(groups), HttpStatus.OK); } + + @PreAuthorize("hasRole('ROLE_DEANERY')") + @PutMapping("/{id}/capacity") + public ResponseEntity updateCapacity(@PathVariable(name = "id") Long id, + @RequestParam(name = "newcapacity") int newcapacity) { + final Groups group = this.groupService.getGroupById(id).get(); + if (group == null) { + return new ResponseEntity<>("Given group doens't exist", HttpStatus.NOT_FOUND); + } + group.setCapacity(newcapacity); + this.groupService.save(group); + return new ResponseEntity<>("Success", HttpStatus.OK); + } } \ No newline at end of file