Courses Controller getCourses Mapping
This commit is contained in:
@ -8,6 +8,8 @@ import java.util.List;
|
||||
import com.plannaplan.App;
|
||||
import com.plannaplan.entities.Course;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.responses.mappers.CoursesResponseMappers;
|
||||
import com.plannaplan.responses.models.CoursesResponse;
|
||||
import com.plannaplan.services.CourseService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -26,16 +28,9 @@ public class CoursesController {
|
||||
private CourseService courseService;
|
||||
|
||||
@GetMapping("/getCourses")
|
||||
public ResponseEntity<List<Dictionary<String, Object>>> getMethodName() {
|
||||
public ResponseEntity<List<CoursesResponse>> getMethodName() {
|
||||
List<Course> courses = this.courseService.getAllCourses();
|
||||
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());
|
||||
response.add(element);
|
||||
}
|
||||
|
||||
List<CoursesResponse> response = CoursesResponseMappers.mapCoursesListToCoursesResponseList(courses);
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user