diff --git a/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java b/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java index 016a6f2..eac95c6 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java +++ b/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java @@ -30,6 +30,10 @@ public class Groups { public Groups() { } + public Long getId() { + return this.id; + } + public Lecturer getLecturer() { return lecturer; } diff --git a/buisnesslogic/src/main/java/com/plannaplan/entities/Lecturer.java b/buisnesslogic/src/main/java/com/plannaplan/entities/Lecturer.java index a227302..68501cd 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/entities/Lecturer.java +++ b/buisnesslogic/src/main/java/com/plannaplan/entities/Lecturer.java @@ -47,4 +47,9 @@ public class Lecturer { public Lecturer() { } + @Override + public String toString() { + return String.format("%s %s %s", this.title, this.name, this.surname); + } + } \ No newline at end of file diff --git a/restservice/src/main/java/com/plannaplan/controllers/GroupController.java b/restservice/src/main/java/com/plannaplan/controllers/GroupController.java index 09790bc..bb61c45 100644 --- a/restservice/src/main/java/com/plannaplan/controllers/GroupController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/GroupController.java @@ -1,5 +1,9 @@ package com.plannaplan.controllers; +import java.security.acl.Group; +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.List; import com.plannaplan.entities.Groups; @@ -20,7 +24,23 @@ public class GroupController { private GroupService groupService; @GetMapping("/getCourseGroups") - public ResponseEntity> getCourses(@RequestParam("id") Long id) { - return new ResponseEntity<>(this.groupService.getGroupsByCourse(id), HttpStatus.OK); + public ResponseEntity>> getCourses(@RequestParam("id") Long id) { + List groups = this.groupService.getGroupsByCourse(id); + List> response = new ArrayList<>(); + + for (Groups g : groups) { + Dictionary group = new Hashtable<>(); + group.put("id", g.getId()); + group.put("day", g.getDay().label + 1); + group.put("time", String.format("%o.%o", g.getTime() / 60, g.getTime() % 60)); + group.put("lecturer", g.getLecturer().toString()); + group.put("room", g.getRoom()); + group.put("capacity", g.getCapacity()); + group.put("type", g.getType()); + + response.add(group); + } + + return new ResponseEntity<>(response, HttpStatus.OK); } } \ No newline at end of file