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
22 changes: 6 additions & 16 deletions src/main/java/com/example/enjoy/controller/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,25 @@

import com.example.enjoy.dto.TrackProgressDto;
import com.example.enjoy.service.TrackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "홈 컨트롤러", description = "메인 화면 API")
@RestController
@RequiredArgsConstructor
public class HomeController {

private final TrackService trackService;

@Operation(summary = "트랙 진행률 조회", description = "현재 학생의 전체 트랙 진행률을 조회합니다.")
@GetMapping("/home")
public String showMyProgress(Model model) { // 1. Model 객체를 파라미터로 추가
public List<TrackProgressDto> showMyProgress() {
// TODO: 추후 Spring Security 등과 연동하여 실제 로그인한 사용자 ID를 가져와야 함
String currentStudentId = "1"; // 2. 테스트용 임시 학생 ID 사용

// 3. 학생의 이수 현황을 계산하는 새로운 서비스 메서드 호출
List<TrackProgressDto> progressData = trackService.calculateTrackProgress(currentStudentId);

// 4. 조회된 데이터를 "progressData"라는 이름으로 모델에 추가
//model.addAttribute("progressData", progressData);

// 5. 데이터를 표시할 뷰(html)의 이름을 반환
return "home";
public List<TrackProgressDto> getProgress() {
// 1. 반환 타입을 List<TrackProgressDto>로 변경
String currentStudentId = "1";
// 2. 서비스 호출 후 데이터를 바로 반환
return trackService.calculateTrackProgress(currentStudentId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ public ResponseEntity<Void> updateCourseStatus(
userService.updateCourseStatus(studentId, courseName, newStatus);
return ResponseEntity.ok().build();
}
}

Loading