-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: [FN-307] 그룹 내 유저 조회 API 추가 #7
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package flipnote.group.adapter.in.web; | ||
|
|
||
| public class InvitationController { | ||
| //todo 가인 신청 요청 | ||
|
|
||
| //todo 그룹 내 가입 신청한 리스트 조회 | ||
|
|
||
| //todo 가입신청 응답 | ||
|
|
||
| //todo 가입신청 삭제 | ||
|
|
||
| //todo 내가 신청한 가입신청 리스트 조회 | ||
|
|
||
| //todo 초대 | ||
|
|
||
| //todo 그룹 멤버 추방 | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,44 @@ | ||
| package flipnote.group.adapter.in.web; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestHeader; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import flipnote.group.api.dto.response.FindGroupMemberResponseDto; | ||
| import flipnote.group.application.port.in.FindGroupMemberUseCase; | ||
| import flipnote.group.application.port.in.command.FindGroupMemberCommand; | ||
| import flipnote.group.application.port.in.result.FindGroupMemberResult; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/v1/groups/{groupId}") | ||
| public class MemberController { | ||
| //todo 가인 신청 요청 | ||
|
|
||
| //todo 그룹 내 가입 신청한 리스트 조회 | ||
|
|
||
| //todo 가입신청 응답 | ||
|
|
||
| //todo 가입신청 삭제 | ||
|
|
||
| //todo 내가 신청한 가입신청 리스트 조회 | ||
|
|
||
| //todo 초대 | ||
| private final FindGroupMemberUseCase findGroupMemberUseCase; | ||
|
|
||
| /** | ||
| * 그룹 내 멤버 전체 조회 | ||
| * @param userId | ||
| * @param groupId | ||
| * @return | ||
| */ | ||
| @GetMapping("/members") | ||
| public ResponseEntity<FindGroupMemberResponseDto> findGroupMembers( | ||
| @RequestHeader("X-USER-ID") Long userId, | ||
| @PathVariable("groupId") Long groupId) { | ||
|
|
||
| FindGroupMemberCommand cmd = new FindGroupMemberCommand(userId, groupId); | ||
|
|
||
| FindGroupMemberResult result = findGroupMemberUseCase.findGroupMember(cmd); | ||
|
|
||
| FindGroupMemberResponseDto res = FindGroupMemberResponseDto.from(result); | ||
|
|
||
| //todo 그룹 멤버 추방 | ||
| return ResponseEntity.ok(res); | ||
| } | ||
|
|
||
| //todo 하위 권한 수정 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,56 @@ | ||
| package flipnote.group.adapter.out.persistence.mapper; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import flipnote.group.adapter.out.entity.GroupMemberEntity; | ||
| import flipnote.group.adapter.out.entity.RoleEntity; | ||
| import flipnote.group.domain.model.member.GroupMember; | ||
| import flipnote.group.domain.model.member.GroupMemberRole; | ||
| import flipnote.group.domain.model.member.MemberInfo; | ||
| import lombok.AccessLevel; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Component | ||
| @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public class GroupMemberMapper { | ||
| public static GroupMemberEntity create(Long groupId, Long userId, Long roleId) { | ||
| return GroupMemberEntity.create(groupId, userId, roleId); | ||
| public static GroupMemberEntity create(Long groupId, Long userId, RoleEntity role) { | ||
| return GroupMemberEntity.create(groupId, userId, role); | ||
| } | ||
|
|
||
| public static GroupMember toDomain(GroupMemberEntity entity) { | ||
|
|
||
| if (entity == null) { | ||
| return null; | ||
| } | ||
|
|
||
| return GroupMember.builder() | ||
| .id(entity.getId()) | ||
| .groupId(entity.getGroupId()) | ||
| .role(entity.getRole()) | ||
| .build(); | ||
| } | ||
|
|
||
| /** | ||
| * 그룹 멤버 정보 전체 조회 | ||
| * @param entities | ||
| * @return | ||
| */ | ||
| public static List<MemberInfo> toMemberInfo(List<GroupMemberEntity> entities) { | ||
| if (entities == null || entities.isEmpty()) { | ||
| return Collections.emptyList(); | ||
| } | ||
|
|
||
| return entities.stream() | ||
| .map(entity -> MemberInfo.builder() | ||
| .userId(entity.getUserId()) | ||
| .role(entity.getRole().getRole()) | ||
| .build() | ||
| ) | ||
| .toList(); | ||
|
Comment on lines
+47
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 50의 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package flipnote.group.api.dto.response; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import flipnote.group.application.port.in.result.FindGroupMemberResult; | ||
| import flipnote.group.domain.model.member.MemberInfo; | ||
|
|
||
| public record FindGroupMemberResponseDto( | ||
| List<MemberInfo> memberInfoList | ||
| ) { | ||
|
|
||
| public static FindGroupMemberResponseDto from(FindGroupMemberResult result) { | ||
| return new FindGroupMemberResponseDto(result.memberInfoList()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package flipnote.group.application.port.in; | ||
|
|
||
| import flipnote.group.application.port.in.command.FindGroupMemberCommand; | ||
| import flipnote.group.application.port.in.result.FindGroupMemberResult; | ||
|
|
||
| public interface FindGroupMemberUseCase { | ||
| FindGroupMemberResult findGroupMember(FindGroupMemberCommand cmd); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package flipnote.group.application.port.in.command; | ||
|
|
||
| public record FindGroupMemberCommand( | ||
| Long userId, | ||
| Long groupId | ||
| ) { | ||
| } |
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.
toDomain()에서userId매핑이 누락되었습니다 — 도메인 객체의userId가 항상null이 됩니다.GroupMemberEntity에는userId필드가 있고,GroupMember도메인 모델에도userId필드가 있지만, 빌더에서.userId(entity.getUserId())호출이 빠져 있습니다.🐛 수정 제안
return GroupMember.builder() .id(entity.getId()) .groupId(entity.getGroupId()) + .userId(entity.getUserId()) .role(entity.getRole()) .build();📝 Committable suggestion
🤖 Prompt for AI Agents