From 80121137b33e4d3decfd1a5f03a624d029a56cb2 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Wed, 14 Aug 2024 11:59:01 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EA=B7=B8=EB=A3=B9=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=BF=BC=EB=A6=AC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/GroupQueryRepositoryImpl.java | 69 +++++++++---------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepositoryImpl.java index 1972fc22..c477f6ee 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepositoryImpl.java @@ -12,7 +12,6 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; @@ -85,54 +84,48 @@ public List getTotalGroupMemberCount(final List groupIds) { .fetch(); } - /** - * 사용자를 제외한 그룹원 정보와 그룹의 상세정보를 반환한다. - * - * @param groupId 상세정보를 찾을 그룹 아이디 - * @param memberId 사용자 아이디 - * @return 그룹의 상세정보({@code memberId} 제외 그룹원) - */ @Override - public Optional findGroupDetailByGroupIdAndMemberIdExcludeMemberId(final Long groupId, + public Optional findGroupDetailByGroupIdAndMemberIdExcludeMemberId( + final Long groupId, final Long memberId) { - GroupDetailDto groupDetailDtoIncludeMe = - jpaQueryFactory - .selectFrom(group) - .join(memberGroup).on(memberGroup.group.eq(group), - memberGroup.deletedAt.isNull()) - .join(member).on(member.eq(memberGroup.member), - member.deletedAt.isNull()) - .where(group.id.eq(groupId)) - .transform( - groupBy(group.id).as( - Projections.constructor( - GroupDetailDto.class, - group.groupName, - group.groupDescription, - group.groupProfileUrl, - group.createdAt, - Expressions.asBoolean(Boolean.FALSE), - list( - Projections.constructor( - GroupMemberDto.class, - member.id, - member.profileUrl, - member.nickname, - member.tag, - memberGroup.isOwner - ) + GroupDetailDto groupDetailDtoIncludeMe = jpaQueryFactory + .selectFrom(group) + .join(memberGroup).on(memberGroup.group.eq(group), + memberGroup.deletedAt.isNull()) + .join(member).on(member.eq(memberGroup.member), + member.deletedAt.isNull()) + .where(group.id.eq(groupId)) + .transform( + groupBy(group.id).as( + Projections.constructor( + GroupDetailDto.class, + group.groupName, + group.groupDescription, + group.groupProfileUrl, + group.createdAt, + Expressions.asBoolean(Boolean.FALSE), + list( + Projections.constructor( + GroupMemberDto.class, + member.id, + member.profileUrl, + member.nickname, + member.tag, + memberGroup.isOwner ) ) ) ) - .get(groupId); + ) + .get(groupId); - if (Objects.isNull(groupDetailDtoIncludeMe)) { + if (groupDetailDtoIncludeMe == null) { return Optional.empty(); } boolean isOwner = false; - List groupMemberDtosExcludeMe = new ArrayList<>(); + List groupMemberDtosExcludeMe = new ArrayList<>( + groupDetailDtoIncludeMe.members().size()); for (GroupMemberDto dto : groupDetailDtoIncludeMe.members()) { if (!dto.memberId().equals(memberId)) { groupMemberDtosExcludeMe.add(dto);