Added some endpoints not protected
This commit is contained in:
@ -5,6 +5,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.plannaplan.App;
|
||||
import com.plannaplan.Controller;
|
||||
import com.plannaplan.models.ConfigData;
|
||||
|
||||
@ -12,11 +13,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/api/" + App.API_VERSION + "/configurator")
|
||||
public class ConfigController {
|
||||
|
||||
@Autowired
|
||||
|
@ -5,6 +5,7 @@ import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.App;
|
||||
import com.plannaplan.entities.Course;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.services.CourseService;
|
||||
@ -15,38 +16,40 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/api/" + App.API_VERSION + "/courses")
|
||||
public class CoursesController {
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
|
||||
@GetMapping("/getCourses")
|
||||
public ResponseEntity<List<Dictionary<String,Object>>> getMethodName() {
|
||||
public ResponseEntity<List<Dictionary<String, Object>>> getMethodName() {
|
||||
List<Course> courses = this.courseService.getAllCourses();
|
||||
List<Dictionary<String,Object>> response = new ArrayList<>();
|
||||
for(Course c : courses){
|
||||
List<Dictionary<String, Object>> response = new ArrayList<>();
|
||||
for (Course c : courses) {
|
||||
Dictionary<String, Object> element = new Hashtable<>();
|
||||
element.put("id", c.getId());
|
||||
element.put("name",c.getName());
|
||||
element.put("name", c.getName());
|
||||
response.add(element);
|
||||
}
|
||||
|
||||
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getCoursesWithGroups")
|
||||
public ResponseEntity<List<Dictionary<String,Object>>> getCoursesWithGroups() {
|
||||
public ResponseEntity<List<Dictionary<String, Object>>> getCoursesWithGroups() {
|
||||
List<Course> courses = this.courseService.getAllCourses();
|
||||
List<Dictionary<String,Object>> response = new ArrayList<>();
|
||||
for(Course c : courses){
|
||||
List<Dictionary<String, Object>> response = new ArrayList<>();
|
||||
for (Course c : courses) {
|
||||
Dictionary<String, Object> element = new Hashtable<>();
|
||||
element.put("id", c.getId());
|
||||
element.put("name",c.getName());
|
||||
List<Dictionary<String,Object>> groups = new ArrayList<>();
|
||||
for(Groups g : c.getGroups()){
|
||||
Dictionary<String,Object> group = new Hashtable<>();
|
||||
element.put("name", c.getName());
|
||||
List<Dictionary<String, Object>> groups = new ArrayList<>();
|
||||
for (Groups g : c.getGroups()) {
|
||||
Dictionary<String, Object> group = new Hashtable<>();
|
||||
group.put("id", g.getId());
|
||||
group.put("day", g.getDay().label);
|
||||
group.put("time", g.getTimeString());
|
||||
@ -55,11 +58,11 @@ public class CoursesController {
|
||||
group.put("type", g.getType());
|
||||
groups.add(group);
|
||||
}
|
||||
|
||||
|
||||
element.put("groups", groups);
|
||||
response.add(element);
|
||||
}
|
||||
|
||||
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.App;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.services.GroupService;
|
||||
|
||||
@ -13,21 +14,23 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/api/" + App.API_VERSION + "/groups")
|
||||
public class GroupController {
|
||||
@Autowired
|
||||
private GroupService groupService;
|
||||
|
||||
@GetMapping("/getCourseGroups")
|
||||
public ResponseEntity<List<Dictionary<String, Object>>> getCourses(@RequestParam("id") Long id, @RequestParam(name="capacity", defaultValue="true") Boolean capacity){
|
||||
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<Dictionary<String, Object>> response = new ArrayList<>();
|
||||
|
||||
|
||||
for (Groups g : groups) {
|
||||
Dictionary<String, Object> group = new Hashtable<>();
|
||||
group.put("id", g.getId());
|
||||
@ -37,7 +40,7 @@ public class GroupController {
|
||||
group.put("room", g.getRoom());
|
||||
if (capacity) {
|
||||
group.put("capacity", g.getCapacity());
|
||||
}
|
||||
}
|
||||
group.put("type", g.getType());
|
||||
|
||||
response.add(group);
|
||||
|
Reference in New Issue
Block a user