Correction of groups endpoint
This commit is contained in:
parent
2e40e33545
commit
e8ebcd3517
@ -30,6 +30,10 @@ public class Groups {
|
||||
public Groups() {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Lecturer getLecturer() {
|
||||
return lecturer;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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<List<Groups>> getCourses(@RequestParam("id") Long id) {
|
||||
return new ResponseEntity<>(this.groupService.getGroupsByCourse(id), HttpStatus.OK);
|
||||
public ResponseEntity<List<Dictionary<String, Object>>> getCourses(@RequestParam("id") Long id) {
|
||||
List<Groups> groups = this.groupService.getGroupsByCourse(id);
|
||||
List<Dictionary<String, Object>> response = new ArrayList<>();
|
||||
|
||||
for (Groups g : groups) {
|
||||
Dictionary<String, Object> 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user