diff --git a/src/main/java/org/cotato/csquiz/api/education/controller/EducationController.java b/src/main/java/org/cotato/csquiz/api/education/controller/EducationController.java index 8a807bfc..f06cee8c 100644 --- a/src/main/java/org/cotato/csquiz/api/education/controller/EducationController.java +++ b/src/main/java/org/cotato/csquiz/api/education/controller/EducationController.java @@ -1,5 +1,6 @@ package org.cotato.csquiz.api.education.controller; +import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; import java.util.List; import lombok.RequiredArgsConstructor; @@ -7,6 +8,7 @@ import org.cotato.csquiz.api.education.dto.AllEducationResponse; import org.cotato.csquiz.api.education.dto.CreateEducationRequest; import org.cotato.csquiz.api.education.dto.CreateEducationResponse; +import org.cotato.csquiz.api.education.dto.EducationCountResponse; import org.cotato.csquiz.api.education.dto.EducationIdOfQuizResponse; import org.cotato.csquiz.api.education.dto.FindEducationStatusResponse; import org.cotato.csquiz.api.education.dto.UpdateEducationRequest; @@ -90,4 +92,10 @@ public ResponseEntity calculateWinner(@RequestParam("educationId") Long ed kingMemberService.calculateWinner(educationId); return ResponseEntity.noContent().build(); } + + @Operation(summary = "교육 및 퀴즈 수 조회 API") + @GetMapping("/counts") + public ResponseEntity getEducationCounts() { + return ResponseEntity.ok().body(educationService.getEducationCounts()); + } } diff --git a/src/main/java/org/cotato/csquiz/api/education/dto/EducationCountResponse.java b/src/main/java/org/cotato/csquiz/api/education/dto/EducationCountResponse.java new file mode 100644 index 00000000..5921c0d0 --- /dev/null +++ b/src/main/java/org/cotato/csquiz/api/education/dto/EducationCountResponse.java @@ -0,0 +1,14 @@ +package org.cotato.csquiz.api.education.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; +import lombok.Builder; + +@Builder +public record EducationCountResponse( + @Schema(description = "전체 교육 수", requiredMode = RequiredMode.REQUIRED) + Long educationCount, + @Schema(description = "전체 퀴즈 수", requiredMode = RequiredMode.REQUIRED) + Long quizCount +) { +} diff --git a/src/main/java/org/cotato/csquiz/common/config/SecurityConfig.java b/src/main/java/org/cotato/csquiz/common/config/SecurityConfig.java index 81c079cd..d5c0f6c6 100644 --- a/src/main/java/org/cotato/csquiz/common/config/SecurityConfig.java +++ b/src/main/java/org/cotato/csquiz/common/config/SecurityConfig.java @@ -39,7 +39,8 @@ public class SecurityConfig { "/v2/api/projects/**", "/v2/api/policies", "/v2/api/events/**", - "/v2/api/random-quizzes/**" + "/v2/api/random-quizzes/**", + "/v1/api/education/counts" }; private final JwtTokenProvider jwtTokenProvider; diff --git a/src/main/java/org/cotato/csquiz/common/config/filter/JwtAuthorizationFilter.java b/src/main/java/org/cotato/csquiz/common/config/filter/JwtAuthorizationFilter.java index c028bbab..ef78bf43 100644 --- a/src/main/java/org/cotato/csquiz/common/config/filter/JwtAuthorizationFilter.java +++ b/src/main/java/org/cotato/csquiz/common/config/filter/JwtAuthorizationFilter.java @@ -40,7 +40,8 @@ public class JwtAuthorizationFilter extends OncePerRequestFilter { "/v2/api/policies", "/v2/api/events/**", "/v2/api/projects/**", - "/v2/api/random-quizzes/**" + "/v2/api/random-quizzes/**", + "/v1/api/education/counts" }; private final JwtTokenProvider jwtTokenProvider; diff --git a/src/main/java/org/cotato/csquiz/domain/education/service/EducationService.java b/src/main/java/org/cotato/csquiz/domain/education/service/EducationService.java index abe5744a..c4e84b1f 100644 --- a/src/main/java/org/cotato/csquiz/domain/education/service/EducationService.java +++ b/src/main/java/org/cotato/csquiz/domain/education/service/EducationService.java @@ -8,6 +8,7 @@ import org.cotato.csquiz.api.education.dto.AllEducationResponse; import org.cotato.csquiz.api.education.dto.CreateEducationRequest; import org.cotato.csquiz.api.education.dto.CreateEducationResponse; +import org.cotato.csquiz.api.education.dto.EducationCountResponse; import org.cotato.csquiz.api.education.dto.EducationIdOfQuizResponse; import org.cotato.csquiz.api.education.dto.FindEducationStatusResponse; import org.cotato.csquiz.api.education.dto.UpdateEducationRequest; @@ -142,5 +143,12 @@ public EducationIdOfQuizResponse findEducationIdOfQuizId(Long quizId) { public List findAllEducationByGenerationId(Long generationId) { return educationRepository.findAllByGenerationId(generationId); } + + public EducationCountResponse getEducationCounts() { + return EducationCountResponse.builder() + .educationCount(educationRepository.count()) + .quizCount(quizRepository.count()) + .build(); + } }