diff --git a/src/main/java/com/smunity/petition/domain/question/controller/QuestionController.java b/src/main/java/com/smunity/petition/domain/question/controller/QuestionController.java index 82cd822..9b9ec4b 100644 --- a/src/main/java/com/smunity/petition/domain/question/controller/QuestionController.java +++ b/src/main/java/com/smunity/petition/domain/question/controller/QuestionController.java @@ -5,9 +5,11 @@ import com.smunity.petition.domain.question.dto.QuestionResponseDto; import com.smunity.petition.domain.question.service.QuestionService; import com.smunity.petition.global.common.ApiResponse; +import jdk.jfr.Frequency; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PageableDefault; import org.springframework.web.bind.annotation.*; @RequiredArgsConstructor @@ -16,11 +18,15 @@ public class QuestionController { private final QuestionService questionService; - @GetMapping + /* @GetMapping public ApiResponse> list(Pageable pageable) { return ApiResponse.onSuccess(questionService.getQuestion(pageable)); } - +*/ + @GetMapping + public ApiResponse> list(@PageableDefault Pageable pageable){ + return ApiResponse.onSuccess(questionService.getQuestion(pageable)); + } @GetMapping("/{id}") public ApiResponse read(@PathVariable Long id) { diff --git a/src/main/java/com/smunity/petition/domain/question/service/QuestionService.java b/src/main/java/com/smunity/petition/domain/question/service/QuestionService.java index d78f7b2..e6b6e25 100644 --- a/src/main/java/com/smunity/petition/domain/question/service/QuestionService.java +++ b/src/main/java/com/smunity/petition/domain/question/service/QuestionService.java @@ -22,12 +22,19 @@ public class QuestionService { private final QuestionRepository questionRepository; private final UserRepository userRepository; - public Page getQuestion(Pageable pageable) { + /*public Page getQuestion(Pageable pageable) { + Page questions = questionRepository.findAll(pageable); + return questions.map(QuestionListDto::from); + }*/ + + public Page getQuestion(Pageable pageable){ Page questions = questionRepository.findAll(pageable); return questions.map(QuestionListDto::from); } + + public QuestionResponseDto getQuestionById(Long id) { Question QuestionEntity = questionRepository.findById(id).orElseThrow( () -> new GeneralException(ErrorCode.QUESTION_NOT_FOUND));