|
@@ -15,7 +15,6 @@ import cn.seecoder.seecoderportalserver.service.Impl.CoderService;
|
|
|
import cn.seecoder.seecoderportalserver.service.Impl.EvalService;
|
|
import cn.seecoder.seecoderportalserver.service.Impl.EvalService;
|
|
|
import cn.seecoder.seecoderportalserver.service.Impl.HelperService;
|
|
import cn.seecoder.seecoderportalserver.service.Impl.HelperService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import io.swagger.models.auth.In;
|
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -97,7 +96,10 @@ public class CourseService {
|
|
|
|
|
|
|
|
public List<CourseVO> getAllCourses() {
|
|
public List<CourseVO> getAllCourses() {
|
|
|
List<Course> courses = courseRepository.findAll();
|
|
List<Course> courses = courseRepository.findAll();
|
|
|
- List<CourseVO> courseVOs = courses.stream().map(courseMapper::courseToCourseVO).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<CourseVO> courseVOs = courses.stream()
|
|
|
|
|
+ .filter(course -> course.getCourseState().equals(CourseState.NORMAL))
|
|
|
|
|
+ .map(courseMapper::courseToCourseVO)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
return courseVOs;
|
|
return courseVOs;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -110,10 +112,7 @@ public class CourseService {
|
|
|
public List<CourseVO> getStudentCourses(Long studentId) {
|
|
public List<CourseVO> getStudentCourses(Long studentId) {
|
|
|
List<CourseSelection> courseSelections = courseSelectionRepository.findCourseSelectionsByUserId(studentId);
|
|
List<CourseSelection> courseSelections = courseSelectionRepository.findCourseSelectionsByUserId(studentId);
|
|
|
List<CourseVO> courseVOs = courseSelections.stream()
|
|
List<CourseVO> courseVOs = courseSelections.stream()
|
|
|
- .map(courseSelection -> courseMapper
|
|
|
|
|
- .courseToCourseVO(courseRepository
|
|
|
|
|
- .findById(courseSelection.getCourseId())
|
|
|
|
|
- .get()))
|
|
|
|
|
|
|
+ .map(courseSelection -> courseMapper.courseToCourseVO(courseRepository.findById(courseSelection.getCourseId()).get()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
return courseVOs;
|
|
return courseVOs;
|
|
|
}
|
|
}
|