diff --git a/src/main/java/com/careerzip/controller/AdminController.java b/src/main/java/com/careerzip/controller/AdminController.java index e30d4cd..2760a51 100644 --- a/src/main/java/com/careerzip/controller/AdminController.java +++ b/src/main/java/com/careerzip/controller/AdminController.java @@ -34,6 +34,12 @@ public ApiResponse findArchive(@PathVariable Long archiveI return ApiResponse.success(archive); } + @GetMapping("/questionpapers") + public ApiResponse> findAllQuestionPapers() { + List questionPapers = adminService.findAllQuestionPapers(); + return ApiResponse.success(questionPapers); + } + @GetMapping("/news-letter/campaigns") public ApiResponse findAllCampaigns() { CampaignsResponse campaigns = newsLetterService.findAllCampaigns(); diff --git a/src/main/java/com/careerzip/domain/questionpaper/repository/QuestionPaperRepository.java b/src/main/java/com/careerzip/domain/questionpaper/repository/QuestionPaperRepository.java index 6c6073d..74e0033 100644 --- a/src/main/java/com/careerzip/domain/questionpaper/repository/QuestionPaperRepository.java +++ b/src/main/java/com/careerzip/domain/questionpaper/repository/QuestionPaperRepository.java @@ -3,9 +3,12 @@ import com.careerzip.domain.questionpaper.entity.QuestionPaper; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; import java.util.Optional; public interface QuestionPaperRepository extends JpaRepository, QuestionPaperRepositoryCustom { Optional findLatest(); + + List findAllByOrderByIdDesc(); } diff --git a/src/main/java/com/careerzip/global/admin/service/AdminService.java b/src/main/java/com/careerzip/global/admin/service/AdminService.java index 0f0db7d..73c2f10 100644 --- a/src/main/java/com/careerzip/global/admin/service/AdminService.java +++ b/src/main/java/com/careerzip/global/admin/service/AdminService.java @@ -25,7 +25,6 @@ import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; -import java.time.LocalDate; import java.util.List; import java.util.Set; @@ -57,7 +56,7 @@ public AdminArchiveResponse findArchiveBy(Long archiveId) { } public List findAllQuestionPapers() { - List questionPapers = questionPaperRepository.findAll(); + List questionPapers = questionPaperRepository.findAllByOrderByIdDesc(); return AdminQuestionPaperDetail.listOf(questionPapers); } } diff --git a/src/main/java/com/careerzip/security/admin/AdminSecurityConfig.java b/src/main/java/com/careerzip/security/admin/AdminSecurityConfig.java index 87eae55..ad590e1 100644 --- a/src/main/java/com/careerzip/security/admin/AdminSecurityConfig.java +++ b/src/main/java/com/careerzip/security/admin/AdminSecurityConfig.java @@ -61,6 +61,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers("/admin/news-letter/campaigns/reminders").permitAll() .antMatchers("/admin/news-letter/campaigns/main/contacts").permitAll() .antMatchers("/admin/news-letter/contacts/not-archived").permitAll() + .antMatchers("/admin/questionpapers").permitAll() .antMatchers("/admin/**").hasRole(ADMIN.name()) .anyRequest().authenticated();