From ec350b46d53d55a37c1f7c5cc7dd69079a6c928b Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Tue, 4 Jun 2024 21:37:50 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix=20:=20=EA=B7=B8=EB=A3=B9=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=20=EC=9A=94=EC=B2=AD=20=EC=A0=84=20=EC=B9=98=EA=B5=AC?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=EC=9D=B4=EB=AF=B8=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EB=B3=B4=EB=82=B8=20=EC=B9=9C=EA=B5=AC=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MemberFriendQueryRepository.java | 2 +- .../MemberFriendQueryRepositoryImpl.java | 14 +++-------- .../service/query/FriendQueryService.java | 23 ++++++++++++++++++- .../GroupInviteQueryRepository.java | 2 ++ .../GroupInviteQueryRepositoryImpl.java | 18 +++++++++++++-- .../MemberGroupQueryRepository.java | 1 + .../MemberGroupQueryRepositoryImpl.java | 8 +++++++ .../service/FriendQueryServiceTest.java | 7 ++++-- 8 files changed, 58 insertions(+), 17 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepository.java index 8e8c32667..d2677a9f1 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepository.java @@ -36,7 +36,7 @@ Optional findFriendsByTag( List findFriendIdsByOwnerId(final Long memberId); - Slice findFriendsBeforeGroupInvite( + Slice findFriends( final FriendBeforeGroupInviteRequest request); List findFriendIds(final List groupMemberIds, final Long memberId); diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepositoryImpl.java index 7bc29fdd2..875e67d0f 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepositoryImpl.java @@ -1,10 +1,8 @@ package site.timecapsulearchive.core.domain.friend.repository.member_friend; -import static com.querydsl.jpa.JPAExpressions.select; import static site.timecapsulearchive.core.domain.friend.entity.QFriendInvite.friendInvite; import static site.timecapsulearchive.core.domain.friend.entity.QMemberFriend.memberFriend; import static site.timecapsulearchive.core.domain.member.entity.QMember.member; -import static site.timecapsulearchive.core.domain.member_group.entity.QMemberGroup.memberGroup; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.Projections; @@ -73,8 +71,9 @@ private Slice getFriendSummaryDtos(final int size, return new SliceImpl<>(friendSummaryDtos, Pageable.ofSize(size), hasNext); } - public Slice findFriendsBeforeGroupInvite( - final FriendBeforeGroupInviteRequest request) { + public Slice findFriends( + final FriendBeforeGroupInviteRequest request + ) { final List friends = jpaQueryFactory .select( Projections.constructor( @@ -86,15 +85,8 @@ public Slice findFriendsBeforeGroupInvite( ) ) .from(memberFriend) - .innerJoin(member).on(memberFriend.owner.id.eq(member.id)) - .innerJoin(member).on(memberFriend.friend.id.eq(member.id)) .where(memberFriend.owner.id.eq(request.memberId()) .and(memberFriend.createdAt.lt(request.createdAt())) - .and(memberFriend.friend.id.notIn( - select(memberGroup.member.id) - .from(memberGroup) - .where(memberGroup.group.id.eq(request.groupId())) - )) ) .limit(request.size() + 1) .fetch(); diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java index d34230f0a..58666e62c 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java @@ -2,8 +2,10 @@ import java.time.ZonedDateTime; import java.util.List; +import java.util.stream.Stream; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Slice; +import org.springframework.data.domain.SliceImpl; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import site.timecapsulearchive.core.domain.friend.data.dto.FriendSummaryDto; @@ -12,6 +14,8 @@ import site.timecapsulearchive.core.domain.friend.data.request.FriendBeforeGroupInviteRequest; import site.timecapsulearchive.core.domain.friend.exception.FriendNotFoundException; import site.timecapsulearchive.core.domain.friend.repository.member_friend.MemberFriendRepository; +import site.timecapsulearchive.core.domain.member_group.repository.groupInviteRepository.GroupInviteRepository; +import site.timecapsulearchive.core.domain.member_group.repository.memberGroupRepository.MemberGroupRepository; import site.timecapsulearchive.core.global.common.wrapper.ByteArrayWrapper; @Service @@ -20,6 +24,8 @@ public class FriendQueryService { private final MemberFriendRepository memberFriendRepository; + private final MemberGroupRepository memberGroupRepository; + private final GroupInviteRepository groupInviteRepository; public Slice findFriendsSlice( final Long memberId, @@ -31,7 +37,22 @@ public Slice findFriendsSlice( public Slice findFriendsBeforeGroupInviteSlice( final FriendBeforeGroupInviteRequest request) { - return memberFriendRepository.findFriendsBeforeGroupInvite(request); + final Slice friendSummaryDtos = memberFriendRepository.findFriends( + request); + + final List groupMemberIdsToExcludeBeforeGroupInvite = Stream.concat( + memberGroupRepository.getGroupMemberIdsByGroupId(request.groupId()).stream(), + groupInviteRepository.getGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), + request.memberId()).stream()) + .distinct() + .toList(); + + final List friendSummaryBeforeGroupInvitedDtos = friendSummaryDtos.getContent() + .stream() + .filter(dto -> !groupMemberIdsToExcludeBeforeGroupInvite.contains(dto.id())).toList(); + + return new SliceImpl<>(friendSummaryBeforeGroupInvitedDtos, friendSummaryDtos.getPageable(), + friendSummaryDtos.hasNext()); } public Slice findFriendRequestsSlice( diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/groupInviteRepository/GroupInviteQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/groupInviteRepository/GroupInviteQueryRepository.java index 7d1725f84..bef2ad210 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/groupInviteRepository/GroupInviteQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/groupInviteRepository/GroupInviteQueryRepository.java @@ -16,4 +16,6 @@ Slice findGroupInvitesSummary( final int size, final ZonedDateTime createdAt ); + + List getGroupMemberIdsByGroupIdAndGroupOwnerId(final Long groupId, final Long memberId); } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/groupInviteRepository/GroupInviteQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/groupInviteRepository/GroupInviteQueryRepositoryImpl.java index ca2e6566b..c1e60cb9a 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/groupInviteRepository/GroupInviteQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/groupInviteRepository/GroupInviteQueryRepositoryImpl.java @@ -30,8 +30,11 @@ public class GroupInviteQueryRepositoryImpl implements GroupInviteQueryRepositor private final JPAQueryFactory jpaQueryFactory; @Override - public void bulkSave(final Long groupOwnerId, final Long groupId, - final List groupMemberIds) { + public void bulkSave( + final Long groupOwnerId, + final Long groupId, + final List groupMemberIds + ) { jdbcTemplate.batchUpdate( """ INSERT INTO group_invite ( @@ -105,4 +108,15 @@ public Slice findGroupInvitesSummary( return new SliceImpl<>(groupInviteSummaryDtos, Pageable.ofSize(size), hasNext); } + @Override + public List getGroupMemberIdsByGroupIdAndGroupOwnerId( + final Long groupId, + final Long groupOwnerId + ) { + return jpaQueryFactory + .select(groupInvite.groupMember.id) + .from(groupInvite) + .where(groupInvite.groupOwner.id.eq(groupOwnerId).and(groupInvite.group.id.eq(groupId))) + .fetch(); + } } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/memberGroupRepository/MemberGroupQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/memberGroupRepository/MemberGroupQueryRepository.java index e44701cb2..ebf8fbdb3 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/memberGroupRepository/MemberGroupQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/memberGroupRepository/MemberGroupQueryRepository.java @@ -18,4 +18,5 @@ public interface MemberGroupQueryRepository { List findGroupMemberInfos(Long memberId, Long groupId); Optional findGroupMembersCount(Long groupId); + List getGroupMemberIdsByGroupId(final Long groupId); } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/memberGroupRepository/MemberGroupQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/memberGroupRepository/MemberGroupQueryRepositoryImpl.java index 4251ae4ef..910317fb7 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/memberGroupRepository/MemberGroupQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/memberGroupRepository/MemberGroupQueryRepositoryImpl.java @@ -102,4 +102,12 @@ public Optional findGroupMembersCount(final Long groupId) { .fetchOne() ); } + + public List getGroupMemberIdsByGroupId(final Long groupId) { + return jpaQueryFactory + .select(memberGroup.member.id) + .from(memberGroup) + .where(memberGroup.group.id.eq(groupId)) + .fetch(); + } } diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java index 6c940d657..aad366c83 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java @@ -18,19 +18,22 @@ import site.timecapsulearchive.core.common.fixture.dto.FriendDtoFixture; import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDto; import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDtoByTag; -import site.timecapsulearchive.core.domain.friend.data.response.SearchTagFriendSummaryResponse; import site.timecapsulearchive.core.domain.friend.exception.FriendNotFoundException; import site.timecapsulearchive.core.domain.friend.repository.member_friend.MemberFriendRepository; import site.timecapsulearchive.core.domain.friend.service.query.FriendQueryService; +import site.timecapsulearchive.core.domain.member_group.repository.groupInviteRepository.GroupInviteRepository; +import site.timecapsulearchive.core.domain.member_group.repository.memberGroupRepository.MemberGroupRepository; import site.timecapsulearchive.core.global.common.wrapper.ByteArrayWrapper; class FriendQueryServiceTest { private final MemberFriendRepository memberFriendRepository = mock( MemberFriendRepository.class); + private final MemberGroupRepository memberGroupRepository = mock(MemberGroupRepository.class); + private final GroupInviteRepository groupInviteRepository = mock(GroupInviteRepository.class); private final FriendQueryService friendQueryService = new FriendQueryService( - memberFriendRepository); + memberFriendRepository, memberGroupRepository, groupInviteRepository); @Test void 사용자는_주소록_기반_핸드폰_번호로_Ahchive_사용자_리스트를_조회_할_수_있다() { From 7d3476f4d93432006331e7483b22b017839afc11 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 5 Jun 2024 01:15:50 +0900 Subject: [PATCH 2/5] =?UTF-8?q?test=20:=20=EA=B7=B8=EB=A3=B9=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=20=EC=A0=84=20=EC=B9=9C=EA=B5=AC=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/fixture/dto/FriendDtoFixture.java | 21 ++++++ .../service/FriendQueryServiceTest.java | 73 ++++++++++++++++++- 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/dto/FriendDtoFixture.java b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/dto/FriendDtoFixture.java index 5cf59d72a..4ee3f18b8 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/dto/FriendDtoFixture.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/dto/FriendDtoFixture.java @@ -1,9 +1,16 @@ package site.timecapsulearchive.core.common.fixture.dto; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.List; import java.util.Optional; +import java.util.stream.IntStream; import java.util.stream.LongStream; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.domain.SliceImpl; import site.timecapsulearchive.core.common.fixture.domain.MemberFixture; +import site.timecapsulearchive.core.domain.friend.data.dto.FriendSummaryDto; import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDto; import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDtoByTag; import site.timecapsulearchive.core.global.common.wrapper.ByteArrayWrapper; @@ -35,4 +42,18 @@ public static Optional getFriendSummaryDtoByTag() { .build()); } + + public static Slice getFriendSummaryDtoSlice(int count, boolean hasNextPage) { + List dtos = IntStream.range(0, count) + .mapToObj(i -> new FriendSummaryDto( + (long) i, + i + "testProfileUrl", + i + "testNickname", + ZonedDateTime.now(ZoneId.of("UTC")).plusDays(i) + ) + ) + .toList(); + + return new SliceImpl<>(dtos, Pageable.ofSize(count), hasNextPage); + } } diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java index aad366c83..2efac09e8 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java @@ -9,15 +9,21 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.Optional; import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.Test; +import org.springframework.data.domain.Slice; import site.timecapsulearchive.core.common.fixture.domain.MemberFixture; import site.timecapsulearchive.core.common.fixture.dto.FriendDtoFixture; +import site.timecapsulearchive.core.domain.friend.data.dto.FriendSummaryDto; import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDto; import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDtoByTag; +import site.timecapsulearchive.core.domain.friend.data.request.FriendBeforeGroupInviteRequest; import site.timecapsulearchive.core.domain.friend.exception.FriendNotFoundException; import site.timecapsulearchive.core.domain.friend.repository.member_friend.MemberFriendRepository; import site.timecapsulearchive.core.domain.friend.service.query.FriendQueryService; @@ -33,7 +39,10 @@ class FriendQueryServiceTest { private final GroupInviteRepository groupInviteRepository = mock(GroupInviteRepository.class); private final FriendQueryService friendQueryService = new FriendQueryService( - memberFriendRepository, memberGroupRepository, groupInviteRepository); + memberFriendRepository, + memberGroupRepository, + groupInviteRepository + ); @Test void 사용자는_주소록_기반_핸드폰_번호로_Ahchive_사용자_리스트를_조회_할_수_있다() { @@ -105,4 +114,66 @@ class FriendQueryServiceTest { assertThatThrownBy(() -> friendQueryService.searchFriend(memberId, tag)) .isInstanceOf(FriendNotFoundException.class); } + + @Test + void 그룹장은_그룹_초대_전_초대_가능한_친구_목록을_조회할_수_있다() { + //given + Long memberId = 1L; + Long groupId = 1L; + int size = 20; + ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")).plusDays(1); + + FriendBeforeGroupInviteRequest request = FriendBeforeGroupInviteRequest.of(memberId, + groupId, + size, now); + given(memberFriendRepository.findFriends(request)).willReturn( + FriendDtoFixture.getFriendSummaryDtoSlice(5, true)); + given(memberGroupRepository.getGroupMemberIdsByGroupId(request.groupId())).willReturn( + List.of(3L)); + given(groupInviteRepository.getGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), + request.memberId())).willReturn(List.of(4L)); + + Slice friendsBeforeGroupInviteSlice = friendQueryService.findFriendsBeforeGroupInviteSlice( + request); + + SoftAssertions.assertSoftly( + softly -> { + assertThat(friendsBeforeGroupInviteSlice.getContent()).isNotEmpty(); + assertThat(friendsBeforeGroupInviteSlice.getContent()).allMatch( + dto -> !dto.profileUrl().isBlank()); + assertThat(friendsBeforeGroupInviteSlice.getContent()).allMatch( + dto -> !dto.nickname().isBlank()); + assertThat(friendsBeforeGroupInviteSlice.getContent()).allMatch( + dto -> Objects.nonNull(dto.id())); + assertThat(friendsBeforeGroupInviteSlice.getContent()).allMatch( + dto -> Objects.nonNull(dto.createdAt())); + assertThat(friendsBeforeGroupInviteSlice.hasNext()).isTrue(); + assertThat(friendsBeforeGroupInviteSlice.getSize()).isEqualTo(5); + } + ); + } + + @Test + void 그룹장은_그룹_초대_전_이미_그룹멤버_혹은_그룹_요청을_보낸_사용자를_제외하고_초대_가능한_사용자를_조회한다() { + //given + Long memberId = 1L; + Long groupId = 1L; + int size = 20; + ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")).plusDays(1); + + FriendBeforeGroupInviteRequest request = FriendBeforeGroupInviteRequest.of(memberId, + groupId, + size, now); + given(memberFriendRepository.findFriends(request)).willReturn( + FriendDtoFixture.getFriendSummaryDtoSlice(5, true)); + given(memberGroupRepository.getGroupMemberIdsByGroupId(request.groupId())).willReturn( + List.of(3L)); + given(groupInviteRepository.getGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), + request.memberId())).willReturn(List.of(4L)); + + Slice friendsBeforeGroupInviteSlice = friendQueryService.findFriendsBeforeGroupInviteSlice( + request); + + assertThat(friendsBeforeGroupInviteSlice.getContent()).isNotIn(3L, 4L); + } } \ No newline at end of file From e7ff2bae8021b03e63f9aa0189ba7fb81bb33e0d Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 5 Jun 2024 01:25:39 +0900 Subject: [PATCH 3/5] =?UTF-8?q?chore=20:=20=EC=9E=90=EB=B0=94=20=EA=B5=AC?= =?UTF-8?q?=EA=B8=80=20=ED=98=95=EC=8B=9D=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/friend/api/query/FriendQueryApi.java | 8 ++++---- .../friend_invite/FriendInviteQueryRepositoryImpl.java | 2 -- .../member_friend/MemberFriendQueryRepositoryImpl.java | 1 - .../core/domain/group/api/query/GroupQueryApi.java | 1 - .../domain/group/api/query/GroupQueryApiController.java | 6 ++---- .../domain/group/repository/GroupQueryRepository.java | 1 - .../core/domain/member/repository/MemberRepository.java | 1 - .../data/response/GroupSendingInviteMemberResponse.java | 4 +++- .../MemberGroupQueryRepository.java | 1 + .../member_group_repository/MemberGroupRepository.java | 1 - .../core/global/config/redis/RedissonLockAspect.java | 3 ++- 11 files changed, 12 insertions(+), 17 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/api/query/FriendQueryApi.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/api/query/FriendQueryApi.java index 7fe063959..345a98c22 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/api/query/FriendQueryApi.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/api/query/FriendQueryApi.java @@ -66,10 +66,10 @@ ResponseEntity> findFriendsBeforeGroupInvite( @Operation( summary = "소셜 친구 요청 받은 목록 조회", description = """ - 사용자가 소셜 친구 요청을 받은 목록을 보여준다. -
- 수락 대기 중인 요청만 해당한다. - """, + 사용자가 소셜 친구 요청을 받은 목록을 보여준다. +
+ 수락 대기 중인 요청만 해당한다. + """, security = {@SecurityRequirement(name = "user_token")}, tags = {"friend"} ) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/friend_invite/FriendInviteQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/friend_invite/FriendInviteQueryRepositoryImpl.java index ae6aeceef..947f78446 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/friend_invite/FriendInviteQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/friend_invite/FriendInviteQueryRepositoryImpl.java @@ -12,9 +12,7 @@ import java.time.ZonedDateTime; import java.util.List; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.SliceImpl; import org.springframework.jdbc.core.BatchPreparedStatementSetter; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepositoryImpl.java index 598e5856d..f4d70e495 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/repository/member_friend/MemberFriendQueryRepositoryImpl.java @@ -1,6 +1,5 @@ package site.timecapsulearchive.core.domain.friend.repository.member_friend; -import static site.timecapsulearchive.core.domain.friend.entity.QFriendInvite.friendInvite; import static site.timecapsulearchive.core.domain.friend.entity.QMemberFriend.memberFriend; import static site.timecapsulearchive.core.domain.member.entity.QMember.member; diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/api/query/GroupQueryApi.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/api/query/GroupQueryApi.java index 42695d39b..8cf12d1d5 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/api/query/GroupQueryApi.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/api/query/GroupQueryApi.java @@ -9,7 +9,6 @@ import java.time.ZonedDateTime; import org.springframework.http.ResponseEntity; import site.timecapsulearchive.core.domain.group.data.response.GroupDetailResponse; -import site.timecapsulearchive.core.domain.group.data.response.GroupMemberInfosResponse; import site.timecapsulearchive.core.domain.group.data.response.GroupsSliceResponse; import site.timecapsulearchive.core.global.common.response.ApiSpec; diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/api/query/GroupQueryApiController.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/api/query/GroupQueryApiController.java index 4eb6a53ce..22349e302 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/api/query/GroupQueryApiController.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/api/query/GroupQueryApiController.java @@ -1,7 +1,6 @@ package site.timecapsulearchive.core.domain.group.api.query; import java.time.ZonedDateTime; -import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Slice; import org.springframework.http.ResponseEntity; @@ -13,9 +12,7 @@ import org.springframework.web.bind.annotation.RestController; import site.timecapsulearchive.core.domain.group.data.dto.CompleteGroupSummaryDto; import site.timecapsulearchive.core.domain.group.data.dto.GroupDetailTotalDto; -import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberDto; import site.timecapsulearchive.core.domain.group.data.response.GroupDetailResponse; -import site.timecapsulearchive.core.domain.group.data.response.GroupMemberInfosResponse; import site.timecapsulearchive.core.domain.group.data.response.GroupsSliceResponse; import site.timecapsulearchive.core.domain.group.service.query.GroupQueryService; import site.timecapsulearchive.core.global.common.response.ApiSpec; @@ -60,7 +57,8 @@ public ResponseEntity> findGroups( @RequestParam(defaultValue = "20", value = "size") final int size, @RequestParam(value = "created_at") final ZonedDateTime createdAt ) { - final Slice groupsSlice = groupQueryService.findGroupsSlice(memberId, + final Slice groupsSlice = groupQueryService.findGroupsSlice( + memberId, size, createdAt); diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepository.java index b13299a40..d9d6b63cf 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepository.java @@ -5,7 +5,6 @@ import java.util.Optional; import org.springframework.data.domain.Slice; import site.timecapsulearchive.core.domain.group.data.dto.GroupDetailDto; -import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberDto; import site.timecapsulearchive.core.domain.group.data.dto.GroupSummaryDto; diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/repository/MemberRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/repository/MemberRepository.java index 8efa30cea..02c68c260 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/repository/MemberRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/repository/MemberRepository.java @@ -1,6 +1,5 @@ package site.timecapsulearchive.core.domain.member.repository; -import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInviteMemberResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInviteMemberResponse.java index b4193f30f..a01e1a4fa 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInviteMemberResponse.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInviteMemberResponse.java @@ -11,9 +11,11 @@ public record GroupSendingInviteMemberResponse( String profileUrl, ZonedDateTime sendingInvitesCreatedAt ) { + public GroupSendingInviteMemberResponse { if (sendingInvitesCreatedAt != null) { - sendingInvitesCreatedAt = sendingInvitesCreatedAt.withZoneSameInstant(ResponseMappingConstant.ZONE_ID); + sendingInvitesCreatedAt = sendingInvitesCreatedAt.withZoneSameInstant( + ResponseMappingConstant.ZONE_ID); } } } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepository.java index 8d125b982..9d9c949e6 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepository.java @@ -18,5 +18,6 @@ public interface MemberGroupQueryRepository { List findGroupMemberInfos(Long memberId, Long groupId); Optional findGroupMembersCount(Long groupId); + List getGroupMemberIdsByGroupId(final Long groupId); } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupRepository.java index 39393cb7b..6f2a9cf28 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupRepository.java @@ -3,7 +3,6 @@ import java.util.List; import java.util.Optional; import org.springframework.data.repository.Repository; -import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberDto; import site.timecapsulearchive.core.domain.member_group.entity.MemberGroup; public interface MemberGroupRepository extends Repository, diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/global/config/redis/RedissonLockAspect.java b/backend/core/src/main/java/site/timecapsulearchive/core/global/config/redis/RedissonLockAspect.java index f4444c523..5430e1499 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/global/config/redis/RedissonLockAspect.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/global/config/redis/RedissonLockAspect.java @@ -32,7 +32,8 @@ public Object redissonLock(ProceedingJoinPoint joinPoint) throws Throwable { RedissonLock redissonLock = method.getAnnotation(RedissonLock.class); String lockKey = - method.getName() + DIVISION + RedisLockSpELParser.getLockKey(signature.getParameterNames(), + method.getName() + DIVISION + RedisLockSpELParser.getLockKey( + signature.getParameterNames(), joinPoint.getArgs(), redissonLock.value()); long waitTime = redissonLock.waitTime(); From e475fb00befe870700be82dd7bf5514a70c777ea Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 6 Jun 2024 13:25:40 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix=20:=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=BB=A8=EB=B2=A4=EC=85=98=20=EC=9D=BC=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/service/query/FriendQueryService.java | 4 ++-- .../GroupInviteQueryRepository.java | 2 +- .../GroupInviteQueryRepositoryImpl.java | 2 +- .../MemberGroupQueryRepository.java | 2 +- .../MemberGroupQueryRepositoryImpl.java | 2 +- .../domain/friend/service/FriendQueryServiceTest.java | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java index 47dfd562d..d7da2b7be 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java @@ -43,8 +43,8 @@ public Slice findFriendsBeforeGroupInviteSlice( request); final List groupMemberIdsToExcludeBeforeGroupInvite = Stream.concat( - memberGroupRepository.getGroupMemberIdsByGroupId(request.groupId()).stream(), - groupInviteRepository.getGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), + memberGroupRepository.findGroupMemberIdsByGroupId(request.groupId()).stream(), + groupInviteRepository.findGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), request.memberId()).stream()) .distinct() .toList(); diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/group_invite_repository/GroupInviteQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/group_invite_repository/GroupInviteQueryRepository.java index 60c47491c..65a8aa3f2 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/group_invite_repository/GroupInviteQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/group_invite_repository/GroupInviteQueryRepository.java @@ -18,7 +18,7 @@ Slice findGroupReceivingInvitesSlice( final ZonedDateTime createdAt ); - List getGroupMemberIdsByGroupIdAndGroupOwnerId(final Long groupId, final Long memberId); + List findGroupMemberIdsByGroupIdAndGroupOwnerId(final Long groupId, final Long memberId); List findGroupSendingInvites( final Long memberId, diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/group_invite_repository/GroupInviteQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/group_invite_repository/GroupInviteQueryRepositoryImpl.java index a81dec5b7..abd1b5b4e 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/group_invite_repository/GroupInviteQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/group_invite_repository/GroupInviteQueryRepositoryImpl.java @@ -103,7 +103,7 @@ public Slice findGroupReceivingInvitesSlice( } @Override - public List getGroupMemberIdsByGroupIdAndGroupOwnerId( + public List findGroupMemberIdsByGroupIdAndGroupOwnerId( final Long groupId, final Long groupOwnerId ) { diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepository.java index 9d9c949e6..b11a3eade 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepository.java @@ -19,5 +19,5 @@ public interface MemberGroupQueryRepository { Optional findGroupMembersCount(Long groupId); - List getGroupMemberIdsByGroupId(final Long groupId); + List findGroupMemberIdsByGroupId(final Long groupId); } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepositoryImpl.java index ab4c26fcc..84eb64bfe 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/repository/member_group_repository/MemberGroupQueryRepositoryImpl.java @@ -103,7 +103,7 @@ public Optional findGroupMembersCount(final Long groupId) { ); } - public List getGroupMemberIdsByGroupId(final Long groupId) { + public List findGroupMemberIdsByGroupId(final Long groupId) { return jpaQueryFactory .select(memberGroup.member.id) .from(memberGroup) diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java index ae52bdf62..0abefe6bb 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/service/FriendQueryServiceTest.java @@ -132,9 +132,9 @@ class FriendQueryServiceTest { size, now); given(memberFriendRepository.findFriends(request)).willReturn( FriendDtoFixture.getFriendSummaryDtoSlice(5, true)); - given(memberGroupRepository.getGroupMemberIdsByGroupId(request.groupId())).willReturn( + given(memberGroupRepository.findGroupMemberIdsByGroupId(request.groupId())).willReturn( List.of(3L)); - given(groupInviteRepository.getGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), + given(groupInviteRepository.findGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), request.memberId())).willReturn(List.of(4L)); Slice friendsBeforeGroupInviteSlice = friendQueryService.findFriendsBeforeGroupInviteSlice( @@ -170,9 +170,9 @@ class FriendQueryServiceTest { size, now); given(memberFriendRepository.findFriends(request)).willReturn( FriendDtoFixture.getFriendSummaryDtoSlice(5, true)); - given(memberGroupRepository.getGroupMemberIdsByGroupId(request.groupId())).willReturn( + given(memberGroupRepository.findGroupMemberIdsByGroupId(request.groupId())).willReturn( List.of(3L)); - given(groupInviteRepository.getGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), + given(groupInviteRepository.findGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), request.memberId())).willReturn(List.of(4L)); Slice friendsBeforeGroupInviteSlice = friendQueryService.findFriendsBeforeGroupInviteSlice( From 005134003c178d0d49de53010ed93aeead035f8f Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 6 Jun 2024 13:30:47 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix=20:=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/query/FriendQueryService.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java index d7da2b7be..15e711f91 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/query/FriendQueryService.java @@ -42,19 +42,33 @@ public Slice findFriendsBeforeGroupInviteSlice( final Slice friendSummaryDtos = memberFriendRepository.findFriends( request); - final List groupMemberIdsToExcludeBeforeGroupInvite = Stream.concat( + final List groupMemberIdsToExcludeBeforeGroupInvite = getGroupMemberIdsToExcludeBeforeGroupInvite( + request); + + final List friendSummaryBeforeGroupInvitedDtos = getFriendSummaryBeforeGroupInvitedDtos( + friendSummaryDtos, groupMemberIdsToExcludeBeforeGroupInvite); + + return new SliceImpl<>(friendSummaryBeforeGroupInvitedDtos, friendSummaryDtos.getPageable(), + friendSummaryDtos.hasNext()); + } + + private List getGroupMemberIdsToExcludeBeforeGroupInvite( + final FriendBeforeGroupInviteRequest request) { + return Stream.concat( memberGroupRepository.findGroupMemberIdsByGroupId(request.groupId()).stream(), groupInviteRepository.findGroupMemberIdsByGroupIdAndGroupOwnerId(request.groupId(), request.memberId()).stream()) .distinct() .toList(); + } - final List friendSummaryBeforeGroupInvitedDtos = friendSummaryDtos.getContent() + private List getFriendSummaryBeforeGroupInvitedDtos( + final Slice friendSummaryDtos, + final List groupMemberIdsToExcludeBeforeGroupInvite + ) { + return friendSummaryDtos.getContent() .stream() .filter(dto -> !groupMemberIdsToExcludeBeforeGroupInvite.contains(dto.id())).toList(); - - return new SliceImpl<>(friendSummaryBeforeGroupInvitedDtos, friendSummaryDtos.getPageable(), - friendSummaryDtos.hasNext()); } public Slice findFriendReceivingInvitesSlice(