diff --git a/src/main/java/com/ripple/BE/learning/controller/ConceptController.java b/src/main/java/com/ripple/BE/learning/controller/ConceptController.java new file mode 100644 index 0000000..673a5aa --- /dev/null +++ b/src/main/java/com/ripple/BE/learning/controller/ConceptController.java @@ -0,0 +1,48 @@ +package com.ripple.BE.learning.controller; + +import com.ripple.BE.global.dto.response.ApiResponse; +import com.ripple.BE.learning.dto.ConceptListDTO; +import com.ripple.BE.learning.dto.response.ConceptListResponse; +import com.ripple.BE.learning.service.ConceptService; +import com.ripple.BE.user.domain.CustomUserDetails; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/api/v1/learning") +@Tag(name = "Learning", description = "학습 API") +public class ConceptController { + + private final ConceptService conceptService; + + @Operation(summary = "개념 학습 세트 조회", description = "개념 학습 세트를 조회합니다.") + @GetMapping("/{learningSetId}/concepts") + public ResponseEntity> getConcepts( + final @PathVariable("learningSetId") long learningSetId) { + + ConceptListDTO conceptListDTO = conceptService.getConcepts(learningSetId); + + return ResponseEntity.status(HttpStatus.OK) + .body(ApiResponse.from(ConceptListResponse.toConceptListResponse(conceptListDTO))); + } + + @Operation(summary = "개념 학습 완료 처리", description = "개념 학습을 완료 처리합니다.") + @PostMapping("/{learningSetId}/concepts/complete") + public ResponseEntity> completeConcept( + final @AuthenticationPrincipal CustomUserDetails currentUser, + final @PathVariable("learningSetId") long learningSetId) { + + conceptService.completeConceptLearning(currentUser.getId(), learningSetId); + return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.EMPTY_RESPONSE); + } +} diff --git a/src/main/java/com/ripple/BE/learning/controller/LearningController.java b/src/main/java/com/ripple/BE/learning/controller/LearningController.java index f18fb49..818a3a6 100644 --- a/src/main/java/com/ripple/BE/learning/controller/LearningController.java +++ b/src/main/java/com/ripple/BE/learning/controller/LearningController.java @@ -1,14 +1,11 @@ package com.ripple.BE.learning.controller; import com.ripple.BE.global.dto.response.ApiResponse; -import com.ripple.BE.learning.dto.ConceptListDTO; import com.ripple.BE.learning.dto.LearningSetCompleteListDTO; import com.ripple.BE.learning.dto.ProgressDTO; import com.ripple.BE.learning.dto.request.LearningSetRequest; -import com.ripple.BE.learning.dto.response.ConceptListResponse; import com.ripple.BE.learning.dto.response.LearningSetPreviewListResponse; import com.ripple.BE.learning.dto.response.LearningSetProgressResponse; -import com.ripple.BE.learning.service.ConceptService; import com.ripple.BE.learning.service.LearningAdminService; import com.ripple.BE.learning.service.LearningSetService; import com.ripple.BE.user.domain.CustomUserDetails; @@ -20,7 +17,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -34,7 +30,6 @@ public class LearningController { private final LearningSetService learningSetService; private final LearningAdminService learningAdminService; - private final ConceptService conceptService; @Operation(summary = "학습 세트 생성", description = "엑셀 파일로부터 학습 세트를 생성합니다.") @PostMapping("/excel") @@ -73,25 +68,4 @@ public ResponseEntity> getLearningSetProgress( ApiResponse.from( LearningSetProgressResponse.toLearningSetProgressResponse(progressDTO))); } - - @Operation(summary = "개념 학습 세트 조회", description = "개념 학습 세트를 조회합니다.") - @GetMapping("/{learningSetId}/concepts") - public ResponseEntity> getConcepts( - final @PathVariable("learningSetId") long learningSetId) { - - ConceptListDTO conceptListDTO = conceptService.getConcepts(learningSetId); - - return ResponseEntity.status(HttpStatus.OK) - .body(ApiResponse.from(ConceptListResponse.toConceptListResponse(conceptListDTO))); - } - - @Operation(summary = "개념 학습 완료 처리", description = "개념 학습을 완료 처리합니다.") - @PostMapping("/{learningSetId}/concepts/complete") - public ResponseEntity> completeConcept( - final @AuthenticationPrincipal CustomUserDetails currentUser, - final @PathVariable("learningSetId") long learningSetId) { - - conceptService.completeConceptLearning(currentUser.getId(), learningSetId); - return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.EMPTY_RESPONSE); - } }