Moved CoursesResponse To Abstract
This commit is contained in:
@ -9,7 +9,7 @@ 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.responses.models.GetCoursesResponse;
|
||||
import com.plannaplan.services.CourseService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -28,9 +28,9 @@ public class CoursesController {
|
||||
private CourseService courseService;
|
||||
|
||||
@GetMapping("/getCourses")
|
||||
public ResponseEntity<List<CoursesResponse>> getMethodName() {
|
||||
public ResponseEntity<List<GetCoursesResponse>> getMethodName() {
|
||||
List<Course> courses = this.courseService.getAllCourses();
|
||||
List<CoursesResponse> response = CoursesResponseMappers.mapCoursesListToCoursesResponseList(courses);
|
||||
List<GetCoursesResponse> response = CoursesResponseMappers.mapCoursesListToCoursesResponseList(courses);
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,10 @@ import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.plannaplan.entities.Course;
|
||||
import com.plannaplan.responses.models.CoursesResponse;
|
||||
import com.plannaplan.responses.models.GetCoursesResponse;
|
||||
|
||||
public class CoursesResponseMappers {
|
||||
public static final List<CoursesResponse> mapCoursesListToCoursesResponseList(List<Course> courses) {
|
||||
return courses.stream().filter(Objects::nonNull).map(CoursesResponse::new).collect(Collectors.toList());
|
||||
public static final List<GetCoursesResponse> mapCoursesListToCoursesResponseList(List<Course> courses) {
|
||||
return courses.stream().filter(Objects::nonNull).map(GetCoursesResponse::new).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.plannaplan.responses.models;
|
||||
|
||||
import com.plannaplan.entities.Course;
|
||||
|
||||
public class CoursesResponse {
|
||||
public abstract class CoursesResponse {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.plannaplan.responses.models;
|
||||
|
||||
import com.plannaplan.entities.Course;
|
||||
|
||||
public class GetCoursesResponse extends CoursesResponse {
|
||||
|
||||
public GetCoursesResponse(Course course) {
|
||||
super(course);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user