|
@@ -119,7 +119,10 @@ public class CourseService {
|
|
|
|
|
|
|
|
public List<CourseVO> getTeacherCourses(Long teacherId) {
|
|
public List<CourseVO> getTeacherCourses(Long teacherId) {
|
|
|
List<Course> courses = courseRepository.findCoursesByTeacherId(teacherId);
|
|
List<Course> courses = courseRepository.findCoursesByTeacherId(teacherId);
|
|
|
- return courses.stream().map(courseMapper::courseToCourseVO).collect(Collectors.toList());
|
|
|
|
|
|
|
+ return courses.stream()
|
|
|
|
|
+ .filter(course -> !course.getState().equals(ObjectState.DELETED))
|
|
|
|
|
+ .map(courseMapper::courseToCourseVO)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<CourseVO> getStudentCourses(Long studentId) {
|
|
public List<CourseVO> getStudentCourses(Long studentId) {
|
|
@@ -127,6 +130,7 @@ public class CourseService {
|
|
|
Optional<Course> course = courseRepository.findById(37L);
|
|
Optional<Course> course = courseRepository.findById(37L);
|
|
|
return courseSelections.stream()
|
|
return courseSelections.stream()
|
|
|
.map(courseSelection -> courseMapper.courseToCourseVO(courseRepository.findById(courseSelection.getCourseId()).get()))
|
|
.map(courseSelection -> courseMapper.courseToCourseVO(courseRepository.findById(courseSelection.getCourseId()).get()))
|
|
|
|
|
+ .filter(courseVO -> !courseVO.getState().equals(ObjectState.DELETED))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -140,8 +144,8 @@ public class CourseService {
|
|
|
return optionalCourse.map(courseMapper::courseToCourseVO).orElse(null);
|
|
return optionalCourse.map(courseMapper::courseToCourseVO).orElse(null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public Boolean checkCourseNameUnique(String name){
|
|
|
|
|
|
|
+ public Boolean checkCourseNameUnique(Long id, String name){
|
|
|
Optional<Course> optionalCourse = courseRepository.findCourseByName(name);
|
|
Optional<Course> optionalCourse = courseRepository.findCourseByName(name);
|
|
|
- return !optionalCourse.isPresent();
|
|
|
|
|
|
|
+ return !(optionalCourse.isPresent() && !optionalCourse.get().getId().equals(id));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|