Skip to content

Commit

Permalink
[COT-142] Feature: 교육 및 문제 수 반환 API (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
Youthhing committed Jan 21, 2025
1 parent 05b56b2 commit b10e60b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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;
import lombok.extern.slf4j.Slf4j;
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;
Expand Down Expand Up @@ -90,4 +92,10 @@ public ResponseEntity<Void> calculateWinner(@RequestParam("educationId") Long ed
kingMemberService.calculateWinner(educationId);
return ResponseEntity.noContent().build();
}

@Operation(summary = "교육 및 퀴즈 수 조회 API")
@GetMapping("/counts")
public ResponseEntity<EducationCountResponse> getEducationCounts() {
return ResponseEntity.ok().body(educationService.getEducationCounts());
}
}
Original file line number Diff line number Diff line change
@@ -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
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -142,5 +143,12 @@ public EducationIdOfQuizResponse findEducationIdOfQuizId(Long quizId) {
public List<Education> findAllEducationByGenerationId(Long generationId) {
return educationRepository.findAllByGenerationId(generationId);
}

public EducationCountResponse getEducationCounts() {
return EducationCountResponse.builder()
.educationCount(educationRepository.count())
.quizCount(quizRepository.count())
.build();
}
}

0 comments on commit b10e60b

Please sign in to comment.