Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDING-113] 지원자 수 조회 API 구현 #263

Merged
merged 2 commits into from
Feb 13, 2025
Merged

Conversation

Seooooo24
Copy link
Collaborator

@Seooooo24 Seooooo24 commented Feb 13, 2025

🚀 작업 내용

지원자 수 조회 API 구현하였습니다.

🤔 고민했던 내용

💬 리뷰 중점사항

FormStatisticService의 getTotalApplicationCountByForm() 메서드 사용하였습니다.

Summary by CodeRabbit

  • 새로운 기능
    • 특정 양식에 대한 응모 건수를 조회할 수 있는 기능이 추가되었습니다.
    • 사용자 인증 정보를 활용하여 요청 시 최신 통계 데이터를 정확하게 제공하며, 응모 현황을 손쉽게 확인할 수 있습니다.

Copy link

coderabbitai bot commented Feb 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

이번 PR은 폼 신청 개수를 조회하는 새로운 기능을 추가합니다. API, 컨트롤러, 서비스 및 DTO 레이어에 관련 메서드와 레코드를 도입하여 특정 폼 ID에 대한 신청 개수를 반환할 수 있도록 변경되었습니다. API 인터페이스와 컨트롤러에서 해당 메서드를 추가하고, 서비스 계층에서는 통계 서비스를 활용하여 데이터 조회 및 응답 객체 생성을 구현하였습니다.

Changes

파일 변경 요약
src/.../api/UserFormApplicationApi.java
src/.../controller/UserFormApplicationController.java
새 메서드 getNumberOfFormApplication 추가 및 REST API 구현 (폼 ID와 인증 정보를 받아 신청 개수를 조회)
src/.../controller/dto/response/FormApplicationCountResponse.java
src/.../service/dto/query/FormApplicationCountQuery.java
새로운 record FormApplicationCountResponseFormApplicationCountQuery 추가. 각각 빌더 패턴 및 정적 팩토리 메서드(from) 구현
src/.../service/FacadeUserFormApplicationService.java
src/.../service/FacadeUserFormApplicationServiceImpl.java
인터페이스에 새로운 메서드 getFormApplicationCount 추가 및 구현, FormStatisticService 필드 도입하여 폼 신청 개수 조회 로직 구현

Sequence Diagram(s)

sequenceDiagram
    participant U as 사용자
    participant A as API
    participant C as Controller
    participant S as Service
    participant F as FormStatisticService

    U->>A: getNumberOfFormApplication(formId)
    A->>C: getNumberOfFormApplication(formId, principalDetails)
    C->>S: getFormApplicationCount(formId)
    S->>F: getTotalApplicationCountByForm(formId)
    F-->>S: 폼 신청 개수 반환
    S-->>C: FormApplicationCountQuery 전달
    C-->>A: FormApplicationCountResponse 생성 (from Query)
    A-->>U: 응답 전송 (폼 신청 개수)
Loading

Possibly related PRs

  • [DDING-106] 사용자 폼지 상세 조회 API 구현 #253: PR의 주요 변경 사항은 UserFormApplicationApiUserFormApplicationControllergetNumberOfFormApplication 메서드를 추가하는 것으로, 이는 UserFormApiUserFormController에서 데이터 조회를 위한 유사한 패턴을 따릅니다.

Suggested labels

✨기능, D-0

Suggested reviewers

  • wonjunYou
  • 5uhwann
  • KoSeonJe

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f06313 and f3b3bce.

📒 Files selected for processing (3)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/api/UserFormApplicationApi.java (2 hunks)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeUserFormApplicationServiceImpl.java (3 hunks)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/dto/query/FormApplicationCountQuery.java (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Seooooo24 Seooooo24 added the D-3 label Feb 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeUserFormApplicationServiceImpl.java (1)

45-49: 서비스 구현이 깔끔하며, 트랜잭션 관리가 적절합니다.

다만, 폼이 존재하지 않을 경우의 예외 처리를 명시적으로 처리하면 좋을 것 같습니다.

다음과 같이 예외 처리를 추가하는 것을 제안드립니다:

 @Override
 public FormApplicationCountQuery getFormApplicationCount(Long formId) {
     Form form = formService.getById(formId);
+    if (!form.isActive()) {
+        throw new BusinessException(ErrorCode.FORM_NOT_ACTIVE);
+    }
     return FormApplicationCountQuery.of(formStatisticService.getTotalApplicationCountByForm(form));
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae1314b and 3f06313.

📒 Files selected for processing (6)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/api/UserFormApplicationApi.java (2 hunks)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/controller/UserFormApplicationController.java (2 hunks)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/controller/dto/response/FormApplicationCountResponse.java (1 hunks)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeUserFormApplicationService.java (1 hunks)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeUserFormApplicationServiceImpl.java (3 hunks)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/dto/query/FormApplicationCountQuery.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and analyze
🔇 Additional comments (6)
src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/dto/query/FormApplicationCountQuery.java (1)

5-14: 구현이 깔끔하고 적절합니다!

불변성을 보장하는 record 타입과 빌더 패턴을 사용한 구현이 매우 적절합니다. 정적 팩토리 메서드를 통한 인스턴스 생성 방식도 가독성이 좋습니다.

src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeUserFormApplicationService.java (1)

10-10: 인터페이스 설계가 명확합니다!

메서드 시그니처가 명확하고 일관된 패턴을 따르고 있습니다.

src/main/java/ddingdong/ddingdongBE/domain/formapplication/controller/dto/response/FormApplicationCountResponse.java (1)

6-16: 응답 DTO 설계가 적절합니다!

내부 DTO(FormApplicationCountQuery)와 외부 응답 DTO의 분리가 잘 되어있고, 변환 메서드도 깔끔하게 구현되어 있습니다.

src/main/java/ddingdong/ddingdongBE/domain/formapplication/controller/UserFormApplicationController.java (1)

26-30: 인증 검증 로직이 누락된 것 같습니다.

principalDetails 파라미터가 메서드 내에서 사용되지 않고 있습니다. 폼 조회에 대한 권한 검증이 필요한지 확인해 주세요.

다음 사항들을 확인해 주시기 바랍니다:

  1. 폼 조회 시 사용자 권한 검증이 필요한지 여부
  2. 필요하다면 권한 검증 로직 추가
  3. 불필요하다면 principalDetails 파라미터 제거 고려
src/main/java/ddingdong/ddingdongBE/domain/formapplication/api/UserFormApplicationApi.java (1)

29-37: API 구조와 문서화가 잘 되어있습니다!

OpenAPI 어노테이션을 통한 API 문서화가 명확하게 되어 있으며, RESTful한 엔드포인트 설계가 잘 되어있습니다.

src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeUserFormApplicationServiceImpl.java (1)

30-30: 의존성 주입이 잘 되어있습니다.

FormStatisticService를 final 필드로 선언하여 불변성을 보장하고 있습니다.

Copy link
Collaborator

@KoSeonJe KoSeonJe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코멘트 변경해주시고 머지하면 될 것 같아요~

@ApiResponse(responseCode = "200", description = "지원자 수 조회 성공",
content = @Content(schema = @Schema(implementation = FormApplicationCountResponse.class)))
@ResponseStatus(HttpStatus.OK)
@GetMapping("/forms/{formId}/applications")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url 더 구체적으로 작성해주면 좋을 것 같아요. 아래와 같이?

Suggested change
@GetMapping("/forms/{formId}/applications")
@GetMapping("/forms/{formId}/applications/count")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

졸습니다! 반영하였습니다.

public record FormApplicationCountQuery(
int formApplicationCount
) {
public static FormApplicationCountQuery of(int formApplicationCount) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from으로 바꾸면 좋을 것 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다. 감사합니다!

@Seooooo24 Seooooo24 merged commit eac921a into develop Feb 13, 2025
1 of 2 checks passed
@Seooooo24 Seooooo24 deleted the feature/DDING-113 branch February 13, 2025 16:51
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants