[fix] UTC(Instant) 마이그레이션 + commentCount 버그 + 기타 수정#90
Conversation
Summary of ChangesHello @k3vin7, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 Pull Request는 애플리케이션의 시간 처리 방식을 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이 Pull Request는 전반적인 시간 처리 방식을 LocalDateTime에서 UTC 기반의 Instant로 마이그레이션하는 중요한 작업을 수행했습니다. 이와 함께 댓글 수 계산 버그, 관리자 계정 조회 방식 등 여러 중요한 수정이 포함되었습니다.
전체적으로 변경 사항은 매우 체계적이고 일관성 있게 적용되었습니다. 특히, Instant로의 마이그레이션은 애플리케이션의 시간 처리 안정성을 크게 향상시킬 것입니다. 버그 수정 사항들도 정확하며, 관련 테스트 케이스가 추가되어 코드의 신뢰성을 높였습니다.
한 가지 개선점을 제안합니다. UserService에서 관리자 계정을 조회할 때 하드코딩된 ID를 사용하는 대신, 설정 파일을 통해 이메일 주소 등으로 조회하도록 변경하면 더 유연하고 안정적인 코드가 될 것입니다.
훌륭한 기여에 감사드립니다!
| User admin = userRepository.findById(1L) | ||
| .orElseThrow(() -> new BusinessException(UserErrorStatus.ADMIN_NOT_FOUND)); |
There was a problem hiding this comment.
관리자 계정을 하드코딩된 ID 1L로 조회하는 것은 위험할 수 있습니다. 데이터베이스 환경에 따라 관리자 ID가 1이 아닐 수 있으며, 이는 예기치 않은 ADMIN_NOT_FOUND 오류를 발생시킬 수 있습니다.
ID 대신 이메일 주소와 같이 더 안정적인 속성으로 관리자를 조회하는 것을 고려해 보세요. 예를 들어, 설정 파일에 관리자 이메일을 정의하고 이를 사용하여 조회할 수 있습니다.
Example:
application.yml:
app:
admin:
email: admin@example.comUserService.java:
@Value("${app.admin.email}")
private String adminEmail;
// ... in withdraw()
User admin = userRepository.findByEmail(adminEmail)
.orElseThrow(() -> new BusinessException(UserErrorStatus.ADMIN_NOT_FOUND));
Summary
LocalDateTime→java.time.Instant전면 교체 (UTC 기반 시간 저장)commentCount감소 누락 버그 수정CommentResponseDto.childCommentCount삭제된 자식 댓글 포함 버그 수정UserService.withdraw()admin 조회 시getReferenceById→findById().orElseThrow()변경Changes
Bug Fixes
Post.decrementCommentCount()메서드 추가,CommentService.deleteComment()에서 호출getReferenceById(1L)→findById(1L).orElseThrow(ADMIN_NOT_FOUND)UTC 마이그레이션
BaseEntity,Post,Notice,User,SearchLog및 모든 DTO의LocalDateTime→InstantServerApplication에서 KST 강제 설정(TimeZone.setDefault) 제거spring.jpa.properties.hibernate.jdbc.time_zone: UTC추가spring.jackson.serialization.write-dates-as-timestamps: false추가PagingUtils커서 인코딩/디코딩Instant기반으로 교체Tests
CommentServiceTest: 댓글 삭제 시 commentCount 감소 검증 테스트 추가CommentServiceTest: 엔티티 생성 시createdAt이 UTC Instant로 저장되는지 검증 테스트 추가UserServiceTest:WithdrawTest클래스 추가 (탈퇴 성공 / 존재하지 않는 유저 예외)