-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: [FN-118] 그룹 상세 조회 API 추가 #28
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
Conversation
Walkthrough그룹 상세 조회 GET 엔드포인트 추가, Group/GroupMember 엔티티에 소프트 삭제 도입(@SQLDelete/@SQLRestriction, deletedAt), 레포지토리 조회 메서드가 soft-delete를 반영하도록 변경, 서비스에 사용자/그룹/멤버십 검증 및 상세조회 로직·테스트 추가, GroupDetailResponse DTO 도입. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Controller as GroupController
participant Service as GroupService
participant URepo as UserProfileRepository
participant GRepo as GroupRepository
participant GMRepo as GroupMemberRepository
User->>Controller: GET /v1/groups/{groupId}
Controller->>Service: findGroupDetail(authPrincipal, groupId)
Service->>URepo: validateUser(authPrincipal)
URepo-->>Service: UserProfile
Service->>GRepo: findByIdAndDeletedAtIsNull(groupId)
GRepo-->>Service: Group or empty
Service->>GMRepo: existsByGroupIdAndUserId(groupId, userId)
GMRepo-->>Service: boolean
Service-->>Controller: GroupDetailResponse or throw
Controller-->>User: 200 OK (GroupDetailResponse) / Error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧬 Code Graph Analysis (1)src/test/java/project/flipnote/group/service/GroupServiceTest.java (2)
🔇 Additional comments (7)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
…into feat/find-group-detail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🔭 Outside diff range comments (1)
src/main/java/project/flipnote/group/entity/GroupMember.java (1)
29-53: deletedAt 필드가 누락됨GroupMember 엔티티에 소프트 삭제를 위한
@SQLDelete애노테이션은 추가되었지만, 실제deletedAt필드가 엔티티에 정의되어 있지 않습니다. Group 엔티티(Line 60-61)처럼deletedAt필드를 추가해야 합니다.다음과 같이 deletedAt 필드를 추가하세요:
private String imageUrl; + @Column(name = "deleted_at") + private LocalDateTime deletedAt; + @Builder또한 필요한 import도 추가해야 합니다:
import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLRestriction; + +import java.time.LocalDateTime;
🧹 Nitpick comments (8)
src/main/java/project/flipnote/group/entity/Group.java (1)
7-7: 사용되지 않는 import 제거 필요
@Where애노테이션이 import되어 있지만 실제로 사용되지 않습니다. 대신@SQLRestriction이 사용되고 있으므로 불필요한 import를 제거해야 합니다.import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLRestriction; -import org.hibernate.annotations.Where;src/main/java/project/flipnote/group/service/GroupService.java (5)
63-63: 오타:valiateGroup→validateGroup으로 수정 필요메서드명에 오타가 있습니다. 일관성을 위해
validateGroup으로 수정해야 합니다.-public Group valiateGroup(Long groupId) { +public Group validateGroup(Long groupId) {
56-58:validateGroupInUser메서드명 개선 제안메서드명이 의미를 명확하게 전달하지 못합니다.
isUserInGroup또는isMemberOfGroup과 같이 더 직관적인 이름을 사용하는 것이 좋겠습니다.-public boolean validateGroupInUser(UserProfile user, Long groupId) { - return groupMemberRepository.existsByGroup_idAndUser_id(groupId, user.getId()); +public boolean isUserInGroup(UserProfile user, Long groupId) { + return groupMemberRepository.existsByGroup_idAndUser_id(groupId, user.getId());
167-167: 메서드명 변경에 따른 호출부 수정 필요
validateGroupInUser를isUserInGroup으로 변경한다면, 이 부분도 함께 수정해야 합니다.-if (!validateGroupInUser(user, groupId)) { +if (!isUserInGroup(user, groupId)) {
44-51: 주석 스타일 통일 필요다른 메서드들과 달리 여러 줄 주석(
/* */)을 사용하고 있습니다. 일관성을 위해 한 줄 주석(//)으로 통일하는 것이 좋겠습니다.-/* -유저 정보 조회 - */ +// 유저 정보 조회 public UserProfile validateUser(AuthPrinciple authPrinciple) {
86-86: 메서드 파라미터 순서 일관성 검토
saveGroupOwner(group, user)메서드는 group을 먼저 받는 반면,validateGroupInUser(user, groupId)는 user를 먼저 받습니다. 파라미터 순서를 일관되게 유지하는 것이 좋습니다.src/test/java/project/flipnote/group/service/GroupServiceTest.java (2)
3-4: 중복된 assertion 라이브러리 importAssertJ와 JUnit의 assertion을 모두 import하고 있습니다. 일관성을 위해 하나로 통일하는 것이 좋겠습니다. AssertJ가 더 풍부한 API를 제공하므로 AssertJ로 통일을 권장합니다.
import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.*;이후 assertEquals 사용 부분도 AssertJ로 변경:
-assertEquals("그룹1", res.name()); +assertThat(res.name()).isEqualTo("그룹1");
73-75: 테스트 데이터 설정 명확화
AuthPrinciple생성 시 첫 번째 파라미터로1L을 사용하고 있는데, 이것이 무엇을 의미하는지 명확하지 않습니다. 의미를 명확하게 하기 위해 변수로 추출하거나 주석을 추가하는 것이 좋겠습니다.-authPrinciple = new AuthPrinciple(1L, userProfile.getId(), userProfile.getEmail(), AccountRole.USER, 1L); +// AuthPrinciple(accountId, userId, email, role, tokenVersion) +authPrinciple = new AuthPrinciple(1L, userProfile.getId(), userProfile.getEmail(), AccountRole.USER, 1L);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/main/java/project/flipnote/group/controller/GroupController.java(3 hunks)src/main/java/project/flipnote/group/entity/Group.java(3 hunks)src/main/java/project/flipnote/group/entity/GroupMember.java(2 hunks)src/main/java/project/flipnote/group/model/GroupDetailResponse.java(1 hunks)src/main/java/project/flipnote/group/repository/GroupRepository.java(1 hunks)src/main/java/project/flipnote/group/service/GroupService.java(4 hunks)src/test/java/project/flipnote/group/service/GroupServiceTest.java(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
src/main/java/project/flipnote/group/model/GroupDetailResponse.java (7)
src/main/java/project/flipnote/group/model/GroupCreateResponse.java (1)
GroupCreateResponse(3-9)src/main/java/project/flipnote/group/model/GroupInfoResponse.java (1)
GroupInfoResponse(3-9)src/main/java/project/flipnote/groupjoin/model/GroupJoinResponse.java (1)
GroupJoinResponse(5-11)src/main/java/project/flipnote/group/model/GroupMemberInfoResponse.java (1)
GroupMemberInfoResponse(3-9)src/main/java/project/flipnote/groupjoin/model/GroupJoinListResponse.java (1)
GroupJoinListResponse(7-13)src/main/java/project/flipnote/groupjoin/model/GroupJoinRespondResponse.java (1)
GroupJoinRespondResponse(3-9)src/main/java/project/flipnote/groupjoin/model/FindGroupJoinListMeResponse.java (1)
FindGroupJoinListMeResponse(7-13)
src/main/java/project/flipnote/group/entity/GroupMember.java (1)
src/main/java/project/flipnote/common/entity/SoftDeletableEntity.java (2)
SoftDeletableEntity(8-21)softDelete(14-16)
src/main/java/project/flipnote/group/entity/Group.java (1)
src/main/java/project/flipnote/common/entity/SoftDeletableEntity.java (2)
SoftDeletableEntity(8-21)softDelete(14-16)
src/test/java/project/flipnote/group/service/GroupServiceTest.java (1)
src/test/java/project/flipnote/fixture/UserFixture.java (1)
UserFixture(7-26)
🔇 Additional comments (13)
src/main/java/project/flipnote/group/entity/GroupMember.java (2)
3-4: 올바른 Hibernate 소프트 삭제 애노테이션 추가GroupMember 엔티티에 소프트 삭제 기능이 올바르게 추가되었습니다.
@SQLDelete와@SQLRestriction애노테이션을 통해 실제 삭제가 아닌deleted_at컬럼을 업데이트하는 방식으로 구현되어 있습니다.
27-28: 일관성 있는 소프트 삭제 구현
@SQLDelete와@SQLRestriction애노테이션이 올바르게 적용되었습니다. Group 엔티티와 동일한 패턴으로 소프트 삭제가 구현되어 일관성이 유지됩니다.src/main/java/project/flipnote/group/entity/Group.java (3)
3-3: 필요한 import 추가됨소프트 삭제 기능을 위한 필요한 import들이 올바르게 추가되었습니다.
Also applies to: 5-7
30-31: 올바른 소프트 삭제 애노테이션 구현
@SQLDelete와@SQLRestriction애노테이션이 올바르게 적용되어 있습니다. 삭제 시 실제 레코드를 제거하지 않고deleted_at컬럼을 현재 시간으로 업데이트하며, 조회 시 삭제되지 않은 레코드만 반환합니다.
60-61: deletedAt 필드 추가소프트 삭제를 위한
deletedAt필드가 올바르게 추가되었습니다.@Column애노테이션을 통해 데이터베이스의deleted_at컬럼과 매핑됩니다.src/main/java/project/flipnote/group/repository/GroupRepository.java (1)
17-17: 소프트 삭제에 맞는 repository 메서드로 변경기존
findById메서드가findByIdAndDeletedAtIsNull로 변경되어 소프트 삭제된 그룹을 제외하고 조회할 수 있게 되었습니다. 이는 Group 엔티티의 소프트 삭제 구현과 일치합니다.src/main/java/project/flipnote/group/controller/GroupController.java (2)
6-7: 새로운 엔드포인트를 위한 import 추가그룹 상세 조회 API를 위한 필요한 import들이 올바르게 추가되었습니다.
Also applies to: 18-18
35-42: 그룹 상세 조회 API 엔드포인트 추가새로운 GET 엔드포인트가 올바르게 구현되었습니다.
@PathVariable을 통해 groupId를 받고, 인증된 사용자 정보를@AuthenticationPrincipal로 받아 서비스 계층에 전달합니다.src/main/java/project/flipnote/group/model/GroupDetailResponse.java (3)
8-27: 그룹 상세 정보를 위한 응답 DTO 정의그룹의 상세 정보를 담는 record가 올바르게 정의되었습니다. 필요한 모든 필드들이 포함되어 있고 타입도 적절합니다.
28-40: 정적 팩토리 메서드 구현Group 엔티티로부터 GroupDetailResponse를 생성하는 정적 팩토리 메서드가 올바르게 구현되었습니다. 다른 Response 클래스들과 일관된 패턴을 따르고 있습니다.
24-26: 필드명 일관성 확인 완료
BaseEntity(src/main/java/project/flipnote/common/entity/BaseEntity.java)에서createdAt과modifiedAt필드명이 GroupDetailResponse와 완전히 일치함을 확인했습니다. 추가 수정은 필요 없습니다.src/main/java/project/flipnote/group/service/GroupService.java (1)
158-172: 트랜잭션 읽기 전용 설정 확인
findGroupDetail메서드는 조회만 수행하므로 클래스 레벨의@Transactional(readOnly = true)설정이 적절합니다.src/test/java/project/flipnote/group/service/GroupServiceTest.java (1)
133-156: 테스트 메서드 네이밍 일관성
그룹_상세_조회_성공테스트는 잘 작성되었습니다. 검증 로직이 명확하고 필요한 모든 모의 객체 설정이 포함되어 있습니다.
📝 변경 내용
✅ 체크리스트
💬 기타 참고 사항
Summary by CodeRabbit