Added optional capacity

This commit is contained in:
Marcin Woźniak 2020-08-19 16:37:24 +02:00
parent 14314ba7ab
commit 4dd9324777

View File

@ -23,10 +23,11 @@ public class GroupController {
private GroupService groupService; private GroupService groupService;
@GetMapping("/getCourseGroups") @GetMapping("/getCourseGroups")
public ResponseEntity<List<Dictionary<String, Object>>> getCourses(@RequestParam("id") Long id) { public ResponseEntity<List<Dictionary<String, Object>>> getCourses(@RequestParam("id") Long id, @RequestParam(name="capacity", defaultValue="true") Boolean capacity){
List<Groups> groups = this.groupService.getGroupsByCourse(id); List<Groups> groups = this.groupService.getGroupsByCourse(id);
List<Dictionary<String, Object>> response = new ArrayList<>(); List<Dictionary<String, Object>> response = new ArrayList<>();
for (Groups g : groups) { for (Groups g : groups) {
Dictionary<String, Object> group = new Hashtable<>(); Dictionary<String, Object> group = new Hashtable<>();
group.put("id", g.getId()); group.put("id", g.getId());
@ -34,7 +35,9 @@ public class GroupController {
group.put("time", g.getTimeString()); group.put("time", g.getTimeString());
group.put("lecturer", g.getLecturer().toString()); group.put("lecturer", g.getLecturer().toString());
group.put("room", g.getRoom()); group.put("room", g.getRoom());
group.put("capacity", g.getCapacity()); if (capacity) {
group.put("capacity", g.getCapacity());
}
group.put("type", g.getType()); group.put("type", g.getType());
response.add(group); response.add(group);