Skip to content

[Feat] 이메일 중복 확인 API#24

Merged
yeonju73 merged 5 commits intomainfrom
feat/#23/check-email
Jul 24, 2025
Merged

[Feat] 이메일 중복 확인 API#24
yeonju73 merged 5 commits intomainfrom
feat/#23/check-email

Conversation

@chaeyuuu
Copy link
Copy Markdown
Contributor

@chaeyuuu chaeyuuu commented Jul 24, 2025

💻 Related Issue

closed #23


🚀 Work Description

  • 이메일 중복 여부 확인 api 작성 완료
스크린샷 2025-07-24 16 53 00 - 이메일이 존재하면 true 스크린샷 2025-07-24 16 53 10 - 존재하지 않다면 false 반환

🙇🏻‍♀️ To Reviewer

  • GlobalExceptionHandler 에 유효성 검사 확인관련 코드 추가하였습니다. 유효성 로직에 어긋나는 경우 5000 에러가 아닌 4000 에러가 뜨도록 하였습니다.

➕ Next

  • ocr 연동

Summary by CodeRabbit

  • 신규 기능

    • 이메일 중복 여부를 확인하는 API 엔드포인트가 추가되었습니다.
    • 이메일 중복 확인 요청 및 응답을 위한 새로운 데이터 전송 객체(DTO)가 도입되었습니다.
  • 버그 수정

    • 이메일 형식이 올바르지 않을 경우와 잘못된 요청에 대해 더 구체적인 에러 메시지가 제공됩니다.
  • 문서화

    • 이메일 중복 확인 실패에 대한 Swagger 응답 설명이 추가되었습니다.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 24, 2025

"""

Walkthrough

이메일 중복 확인 기능이 추가되었습니다. 신규 요청/응답 DTO, 서비스 메서드, API 엔드포인트가 도입되었으며, 관련 에러 코드와 성공 코드, 스웨거 문서, 예외 처리 로직이 확장되었습니다. 기존 코드에는 경미한 포맷팅 변경만 발생했습니다.

Changes

파일/그룹 변경 요약
.../auth/api/AuthApi.java 이메일 중복 확인용 POST /api/auth/register/check-email 엔드포인트 추가, 관련 DTO import 및 포맷팅 조정
.../auth/application/AuthService.java checkEmailDuplicated 서비스 메서드 추가 및 DTO import 정리
.../user/dto/request/CheckEmailDuplicatedRequest.java 이메일 중복 확인 요청 DTO 신설, 이메일 형식 및 NotBlank 검증 추가
.../user/dto/response/CheckEmailDuplicatedResponse.java 이메일 중복 여부 반환용 응답 DTO 신설, Lombok 적용
.../global/common/codes/ErrorCode.java INVALID_REQUEST, INVALID_EMAIL_TYPE 에러 코드 추가
.../global/common/codes/SuccessCode.java CHECK_EMAIL_DUPLICATED 성공 코드 추가, 기존 코드 구두점 수정
.../global/config/swagger/SwaggerResponseDescription.java 이메일 중복 실패용 Swagger 응답 설명 상수 추가
.../global/exception/GlobalExceptionHandler.java MethodArgumentNotValidException용 예외 처리 메서드 추가, 이메일 형식 오류 구분 처리

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AuthApi
    participant AuthService
    participant UserRepository

    Client->>AuthApi: POST /api/auth/register/check-email (CheckEmailDuplicatedRequest)
    AuthApi->>AuthService: checkEmailDuplicated(request)
    AuthService->>UserRepository: existsByEmail(email)
    UserRepository-->>AuthService: boolean (존재 여부)
    AuthService-->>AuthApi: CheckEmailDuplicatedResponse
    AuthApi-->>Client: BaseResponse<CheckEmailDuplicatedResponse> (성공/실패 코드 포함)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Suggested labels

🐼 채유, 🚀 Feature

Suggested reviewers

  • yeonju73

Poem

🐰
이메일 중복, 이제 걱정 마세요
새 API가 토끼처럼 빠르게 확인해요
올바른 형식, 중복 여부도 척척!
에러와 성공 코드도 깔끔하게 정리
오늘도 개발자는 한숨 돌리네
Hop, hop! 코드가 더 안전해졌어요
🥕
"""

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14ff8d4 and 3711f2e.

📒 Files selected for processing (1)
  • src/main/java/com/blockguard/server/domain/auth/application/AuthService.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/blockguard/server/domain/auth/application/AuthService.java
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#23/check-email

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (3)
src/main/java/com/blockguard/server/domain/auth/application/AuthService.java (1)

55-60: 메서드 구현이 올바르지만 매개변수명 개선이 필요합니다.

이메일 중복 체크 로직은 올바르게 구현되었습니다. 하지만 매개변수명과 클래스명이 동일하여 가독성이 떨어집니다.

매개변수명을 개선하여 가독성을 향상시킬 수 있습니다:

-public CheckEmailDuplicatedResponse checkEmailDuplicated(CheckEmailDuplicatedRequest CheckEmailDuplicatedRequest) {
-    boolean isDuplicated = userRepository.findByEmail(CheckEmailDuplicatedRequest.getEmail()).isPresent();
+public CheckEmailDuplicatedResponse checkEmailDuplicated(CheckEmailDuplicatedRequest request) {
+    boolean isDuplicated = userRepository.findByEmail(request.getEmail()).isPresent();
src/main/java/com/blockguard/server/global/exception/GlobalExceptionHandler.java (1)

26-44: 유효성 검사 예외 처리가 잘 구현되었지만 개선 가능합니다.

유효성 검사 예외를 적절히 처리하고 이메일 형식과 일반 유효성 검사를 구분하여 처리하는 로직이 좋습니다. 다만 하드코딩된 문자열 비교 부분을 개선할 수 있습니다.

하드코딩된 문자열 대신 상수를 사용하도록 개선하는 것을 고려해보세요:

+    private static final String EMAIL_FORMAT_ERROR_KEYWORD = "이메일 형식";
+
     @ExceptionHandler(MethodArgumentNotValidException.class)
     protected ResponseEntity<ErrorResponse> handleValidationException(MethodArgumentNotValidException ex) {
         String message = ex.getBindingResult().getFieldErrors().stream()
                 .findFirst()
                 .map(DefaultMessageSourceResolvable::getDefaultMessage)
                 .orElse("유효성 검사에 실패했습니다.");

         log.warn("[ValidationException] message: {}", message);

-        if (message.contains("이메일 형식")) {
+        if (message.contains(EMAIL_FORMAT_ERROR_KEYWORD)) {
             return ResponseEntity
                     .status(ErrorCode.INVALID_EMAIL_TYPE.getStatus())
                     .body(ErrorResponse.of(ErrorCode.INVALID_EMAIL_TYPE));
         }
src/main/java/com/blockguard/server/domain/auth/api/AuthApi.java (1)

4-4: 와일드카드 import 사용을 재고해보세요.

와일드카드 import import com.blockguard.server.domain.user.dto.request.*;는 코드의 명확성을 떨어뜨릴 수 있습니다. 특히 사용되는 클래스가 명확하지 않을 때 가독성이 저하됩니다.

명시적인 import를 사용하는 것을 고려해보세요:

-import com.blockguard.server.domain.user.dto.request.*;
+import com.blockguard.server.domain.user.dto.request.CheckEmailDuplicatedRequest;
+import com.blockguard.server.domain.user.dto.request.FindEmailRequest;
+import com.blockguard.server.domain.user.dto.request.FindPasswordRequest;
+import com.blockguard.server.domain.user.dto.request.LoginRequest;
+import com.blockguard.server.domain.user.dto.request.RegisterRequest;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d36208 and 14ff8d4.

📒 Files selected for processing (8)
  • src/main/java/com/blockguard/server/domain/auth/api/AuthApi.java (3 hunks)
  • src/main/java/com/blockguard/server/domain/auth/application/AuthService.java (3 hunks)
  • src/main/java/com/blockguard/server/domain/user/dto/request/CheckEmailDuplicatedRequest.java (1 hunks)
  • src/main/java/com/blockguard/server/domain/user/dto/response/CheckEmailDuplicatedResponse.java (1 hunks)
  • src/main/java/com/blockguard/server/global/common/codes/ErrorCode.java (2 hunks)
  • src/main/java/com/blockguard/server/global/common/codes/SuccessCode.java (1 hunks)
  • src/main/java/com/blockguard/server/global/config/swagger/SwaggerResponseDescription.java (1 hunks)
  • src/main/java/com/blockguard/server/global/exception/GlobalExceptionHandler.java (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
src/main/java/com/blockguard/server/global/exception/GlobalExceptionHandler.java (2)
src/main/java/com/blockguard/server/global/exception/BusinessExceptionHandler.java (1)
  • BusinessExceptionHandler (7-12)
src/main/java/com/blockguard/server/global/config/resolver/CurrentUserArgumentResolver.java (1)
  • CurrentUserArgumentResolver (15-41)
src/main/java/com/blockguard/server/domain/user/dto/response/CheckEmailDuplicatedResponse.java (5)
src/main/java/com/blockguard/server/domain/auth/domain/JwtToken.java (1)
  • Builder (8-16)
src/main/java/com/blockguard/server/domain/user/dto/request/CheckEmailDuplicatedRequest.java (1)
  • Getter (8-14)
src/main/java/com/blockguard/server/domain/user/dto/response/FindEmailResponse.java (1)
  • FindEmailResponse (8-14)
src/main/java/com/blockguard/server/domain/user/dto/response/RegisterResponse.java (1)
  • RegisterResponse (7-12)
src/main/java/com/blockguard/server/domain/user/dto/response/LoginResponse.java (1)
  • LoginResponse (8-14)
src/main/java/com/blockguard/server/global/config/swagger/SwaggerResponseDescription.java (2)
src/main/java/com/blockguard/server/global/config/swagger/CustomExceptionDescription.java (1)
  • CustomExceptionDescription (8-12)
src/main/java/com/blockguard/server/global/config/swagger/SwaggerConfig.java (4)
  • SwaggerConfig (28-139)
  • generateErrorCodeResponseExample (80-98)
  • addGlobalErrorResponses (124-138)
  • getSwaggerExample (102-108)
src/main/java/com/blockguard/server/domain/auth/api/AuthApi.java (2)
src/main/java/com/blockguard/server/domain/user/dto/request/FindEmailRequest.java (1)
  • FindEmailRequest (13-28)
src/main/java/com/blockguard/server/domain/user/dto/response/FindEmailResponse.java (1)
  • FindEmailResponse (8-14)
🔇 Additional comments (10)
src/main/java/com/blockguard/server/global/config/swagger/SwaggerResponseDescription.java (2)

61-61: 문법 수정이 올바르게 적용되었습니다.

새로운 enum 상수 추가를 위해 기존 마지막 상수에 쉼표를 추가한 것은 적절합니다.


63-65: 이메일 중복 체크 실패 케이스 추가가 적절합니다.

새로운 API 엔드포인트에 대한 Swagger 문서화가 올바르게 구현되었습니다. INVALID_EMAIL_TYPE 에러코드를 사용하여 이메일 형식 검증 실패를 명확히 나타내고 있습니다.

src/main/java/com/blockguard/server/global/common/codes/SuccessCode.java (1)

24-25: 새로운 성공 코드 추가가 적절하게 구현되었습니다.

기존 enum 구조와 일관성을 유지하며, 적절한 HTTP 상태 코드(OK)와 순차적인 코드 번호(2014)를 사용했습니다. 메시지도 명확하고 일관된 한국어 표현을 사용하고 있습니다.

src/main/java/com/blockguard/server/domain/auth/application/AuthService.java (1)

6-8: Import 구조 개선이 적절합니다.

wildcard import 사용으로 코드가 간결해졌고, 새로운 response DTO import도 올바르게 추가되었습니다.

src/main/java/com/blockguard/server/domain/user/dto/response/CheckEmailDuplicatedResponse.java (1)

1-14: DTO 구조가 적절하게 설계되었습니다.

단일 boolean 필드로 이메일 중복 여부를 명확하게 표현하고 있으며, 다른 response DTO들과 동일한 Lombok 어노테이션 패턴을 사용하여 일관성을 유지하고 있습니다.

src/main/java/com/blockguard/server/domain/user/dto/request/CheckEmailDuplicatedRequest.java (1)

1-14: 요청 DTO가 올바르게 설계되었습니다.

이메일 검증을 위한 적절한 어노테이션(@Email, @NotBlank)을 사용하고 있으며, 필요한 Lombok 어노테이션도 적절히 적용되어 있습니다. 구조가 간단하고 목적에 부합합니다.

src/main/java/com/blockguard/server/global/common/codes/ErrorCode.java (2)

11-11: 새로운 에러 코드 추가가 적절합니다.

일반적인 유효성 검사 실패를 위한 INVALID_REQUEST 에러 코드가 적절하게 추가되었습니다. 4000번 코드 사용과 명확한 한국어 메시지가 좋습니다.


28-28: 이메일 형식 전용 에러 코드 추가가 좋습니다.

이메일 형식 검증을 위한 전용 에러 코드 INVALID_EMAIL_TYPE이 추가되어 더 세분화된 에러 처리가 가능해졌습니다. 코드 번호 4025도 적절히 할당되었습니다.

src/main/java/com/blockguard/server/global/exception/GlobalExceptionHandler.java (1)

6-8: 필요한 import가 적절히 추가되었습니다.

DefaultMessageSourceResolvableMethodArgumentNotValidException import가 새로운 기능에 필요한 것들로 적절히 추가되었습니다.

src/main/java/com/blockguard/server/domain/auth/api/AuthApi.java (1)

58-58: 코드 포맷팅 개선이 좋습니다.

기존 메서드들의 포맷팅이 일관성 있게 개선되었습니다.

Also applies to: 66-66

Comment thread src/main/java/com/blockguard/server/domain/auth/api/AuthApi.java
@chaeyuuu chaeyuuu changed the title Feat/#23/check email [Feat] 이메일 중복 확인 API Jul 24, 2025
@yeonju73 yeonju73 merged commit 8f83d69 into main Jul 24, 2025
1 check passed
@chaeyuuu chaeyuuu deleted the feat/#23/check-email branch July 25, 2025 07:14
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.

[Feat] 이메일 중복 API

2 participants