Skip to content

[feature] #34 swagger 전용 Auth API 추가#76

Merged
heeejinin merged 21 commits intodevfrom
refactor/34-swagger-login
Jun 4, 2025
Merged

[feature] #34 swagger 전용 Auth API 추가#76
heeejinin merged 21 commits intodevfrom
refactor/34-swagger-login

Conversation

@heeejinin
Copy link
Copy Markdown
Collaborator

📌 PR 목적 및 내용

  • Swagger UI를 통해 직접 로그인 요청을 테스트할 수 있도록 로그인 API에 Swagger 문서 설정을 추가
  • 개발 및 테스트 환경에서 인증 API 테스트가 더 간편해지고 직관적으로 이루어지도록 개선

✏️ 변경 사항

  • Swagger Auth API 추가
  • 로그인 요청 시 필요한 DTO와 응답 추가
  • JWT 기반 로그인 흐름에 Swagger 문서가 자연스럽게 연결되도록 조정

📸 스크린샷 (선택사항)

  • 로그인 API Swagger 예시 화면 추가
image

✅ 체크리스트

  • 코드가 정상적으로 동작하나요?
  • 기존 코드와 충돌이 없나요?
  • 테스트를 통과했나요?
  • 문서 업데이트가 필요한가요?

🔗 관련 이슈 (선택사항)

@heeejinin heeejinin added this to the SPRINT 2주차 milestone Jun 4, 2025
@heeejinin heeejinin self-assigned this Jun 4, 2025
@heeejinin heeejinin added feature 기능 개발 Refactor 코드 리팩토링 labels Jun 4, 2025
@heeejinin heeejinin requested review from SangWJDev and jhroom and removed request for SangWJDev June 4, 2025 06:25
Comment on lines +45 to +50
var user = userRepository.findByEmail(request.getEmail())
.orElseThrow(() -> new CustomException(UserErrorCode.LOGIN_FAILED));

if (!passwordEncoder.matches(request.getPassword(), user.getPassword())) {
throw new CustomException(UserErrorCode.LOGIN_FAILED);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

이메일이 없는 경우와 비밀번호 불일치 모두 동일한 에러(UserErrorCode.LOGIN_FAILED)로 처리하고 있는데,
보안상 클라이언트에는 같은 에러를 주되, 내부 로그에는 정확한 실패 사유(이메일/비밀번호 구분)를 남기는건 어떨까요?? - 추후 유지보수에 유리할거같습니다.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

넵 로그로는 실패 사유 구분하도록 수정하겠습니다!


@Query("SELECT COUNT(r), AVG(r.rating) FROM Review r WHERE r.targetId = :targetId")
Object[] getReviewStatisticsByTargetId(@Param("targetId") Long targetId);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Object[]를 그대로 반환하지 말고, DTO로 매핑하거나 Optional로 감싸서 NullPointerException 위험을 줄이는건 어떨까요???

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

리뷰 저장 후 바로 리뷰 정보를 조회하는 쿼리라 null일 경우는 일부러 고려하지 않았는데, 그래도 체크하는 방향이 좋을까요?


@Column(name = "last_updated", nullable = false)
@LastModifiedDate
private LocalDateTime lastUpdated;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@LastModifiedDate가 동작하려면
클래스에 @EntityListeners(AuditingEntityListener.class)가 붙어있어야할거같습니당

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

넵!! 수정하겠습니다! 알려주셔서 감사합니다


@Column(name = "last_updated", nullable = false)
@LastModifiedDate
private LocalDateTime lastUpdated;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@LastModifiedDate가 동작하려면
클래스에 @EntityListeners(AuditingEntityListener.class)가 붙어있어야할거같습니당

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

헉 넵 수정하겠습니당

@heeejinin heeejinin merged commit 6c7c0c0 into dev Jun 4, 2025
1 check passed
heeejinin added a commit that referenced this pull request Jun 7, 2025
[refactor] #76 swagger login 코드리뷰 내용 수정
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 기능 개발 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants