Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/example/enjoy/dto/TrackProgressDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public class TrackProgressDto {

private List<CourseDto> completedCourses; // 이수한 과목 목록
private List<CourseDto> remainingCourses; // 이수해야 할 남은 과목 목록

private boolean hasUploadedHistory; // 트랙 업로드 여부
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ public interface StudentCourseRepository extends JpaRepository<StudentCourse, Lo

List<StudentCourse> findAllByStudentIdAndManualIsTrue(String studentId);

boolean existsByStudentId(String studentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ private StudentCourseStatus mapGradeToStatus(String grade) {
default -> throw new IllegalArgumentException("잘못된 등급값: " + grade);
};
}

public boolean hasUploadedHistory(String studentId) {
return studentCourseRepository.existsByStudentId(studentId);
}
}
11 changes: 6 additions & 5 deletions src/main/java/com/example/enjoy/service/TrackService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
public class TrackService {

private final TrackRepository trackRepository;
private final StudentCourseRepository studentCourseRepository; // 기존 기능
private final FavoriteCourseRepository favoriteCourseRepository;
private final UserRepository userRepository;
private final StudentCourseRepository studentCourseRepository;


//진척률 계산
public List<TrackProgressDto> calculateTrackProgress(String studentId) {
Set<String> completedCourseNames = getCompletedCourseNames(studentId); // 이수 과목명 목록

boolean hasUploaded = studentCourseRepository.existsByStudentId(studentId);
Set<String> completedCourseNames = getCompletedCourseNames(studentId); // 이수 과목명 목록
List<Track> allTracks = trackRepository.findAll();

return allTracks.stream().map(track -> {
Expand All @@ -59,7 +59,8 @@ public List<TrackProgressDto> calculateTrackProgress(String studentId) {
courses.size(),
completed.size() == courses.size(),
completed,
remaining
remaining,
hasUploaded
);
}).toList();
}
Expand Down
Loading