Checnging endpoints added needs docs

This commit is contained in:
Filip Izydorczyk 2020-12-18 15:49:46 +01:00
parent 5ef7c19ade
commit 300130af7e
1 changed files with 15 additions and 0 deletions

View File

@ -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<String> 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);
}
}