From e3cc43d8217533acc28101013003d0486c743cb1 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Wed, 5 Jun 2024 18:39:16 +0900 Subject: [PATCH 1/6] =?UTF-8?q?fix=20:=20s3=20presign=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/infra/queue/manager/SocialNotificationManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/infra/queue/manager/SocialNotificationManager.java b/backend/core/src/main/java/site/timecapsulearchive/core/infra/queue/manager/SocialNotificationManager.java index 888748a02..dbaf4e480 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/infra/queue/manager/SocialNotificationManager.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/infra/queue/manager/SocialNotificationManager.java @@ -10,12 +10,14 @@ import site.timecapsulearchive.core.infra.queue.data.dto.FriendsReqNotificationsDto; import site.timecapsulearchive.core.infra.queue.data.dto.GroupAcceptNotificationDto; import site.timecapsulearchive.core.infra.queue.data.dto.GroupInviteNotificationDto; +import site.timecapsulearchive.core.infra.s3.manager.S3PreSignedUrlManager; @Component @RequiredArgsConstructor public class SocialNotificationManager { private final RabbitTemplate basicRabbitTemplate; + private final S3PreSignedUrlManager s3PreSignedUrlManager; /** * 단건의 친구 요청을 받아서 알림 전송을 요청한다 @@ -59,10 +61,12 @@ public void sendFriendRequestMessages( return; } + String preSignedUrl = s3PreSignedUrlManager.getS3PreSignedUrlForGet(profileUrl); + basicRabbitTemplate.convertAndSend( RabbitmqComponentConstants.FRIEND_REQUEST_NOTIFICATION_EXCHANGE.getSuccessComponent(), RabbitmqComponentConstants.FRIEND_REQUEST_NOTIFICATION_QUEUE.getSuccessComponent(), - FriendsReqNotificationsDto.createOf(ownerNickname, profileUrl, targetIds) + FriendsReqNotificationsDto.createOf(ownerNickname, preSignedUrl, targetIds) ); } From 068392628b199cdb44cafec423805acef7aa9fc7 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Wed, 5 Jun 2024 18:55:22 +0900 Subject: [PATCH 2/6] =?UTF-8?q?fix=20:=20=EA=B7=B8=EB=A3=B9=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=20=EB=AA=A9=EB=A1=9D=20=EC=8A=AC=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 그룹 목록 초대 목록을 무한 스크롤 대비해 슬라이스로 변경 - 테스트 추가 --- .../api/query/MemberGroupQueryApi.java | 12 +++++-- .../query/MemberGroupQueryApiController.java | 21 ++++++++---- .../GroupSendingInvitesSliceRequestDto.java | 18 ++++++++++ ... => GroupSendingInvitesSliceResponse.java} | 14 +++++--- .../GroupInviteQueryRepository.java | 6 ++-- .../GroupInviteQueryRepositoryImpl.java | 31 ++++++++++++----- .../service/MemberGroupQueryService.java | 9 +++-- .../GroupInviteQueryRepositoryTest.java | 34 +++++++++++++------ 8 files changed, 105 insertions(+), 40 deletions(-) create mode 100644 backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupSendingInvitesSliceRequestDto.java rename backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/{GroupSendingInvitesResponse.java => GroupSendingInvitesSliceResponse.java} (62%) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/api/query/MemberGroupQueryApi.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/api/query/MemberGroupQueryApi.java index 9d4efaebc..f65919c37 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/api/query/MemberGroupQueryApi.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/api/query/MemberGroupQueryApi.java @@ -10,7 +10,7 @@ import org.springframework.http.ResponseEntity; import site.timecapsulearchive.core.domain.group.data.response.GroupMemberInfosResponse; import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceivingInvitesSliceResponse; -import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInvitesResponse; +import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInvitesSliceResponse; import site.timecapsulearchive.core.global.common.response.ApiSpec; public interface MemberGroupQueryApi { @@ -69,10 +69,16 @@ ResponseEntity> findGroupMemberInfos( description = "ok" ) }) - ResponseEntity> findGroupSendingInvites( + ResponseEntity> findGroupSendingInvites( Long memberId, @Parameter(in = ParameterIn.PATH, description = "그룹 아이디", required = true) - Long groupId + Long groupId, + + @Parameter(in = ParameterIn.QUERY, description = "마지막 그룹 초대 아이디") + Long groupInviteId, + + @Parameter(in = ParameterIn.QUERY, description = "페이지 크기", required = true) + int size ); } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/api/query/MemberGroupQueryApiController.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/api/query/MemberGroupQueryApiController.java index ba7eb7371..b036638c7 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/api/query/MemberGroupQueryApiController.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/api/query/MemberGroupQueryApiController.java @@ -15,8 +15,9 @@ import site.timecapsulearchive.core.domain.group.data.response.GroupMemberInfosResponse; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto; +import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInvitesSliceRequestDto; import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceivingInvitesSliceResponse; -import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInvitesResponse; +import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInvitesSliceResponse; import site.timecapsulearchive.core.domain.member_group.service.MemberGroupQueryService; import site.timecapsulearchive.core.global.common.response.ApiSpec; import site.timecapsulearchive.core.global.common.response.SuccessCode; @@ -84,17 +85,25 @@ public ResponseEntity> findGroupMemberInfos( produces = {"application/json"} ) @Override - public ResponseEntity> findGroupSendingInvites( + public ResponseEntity> findGroupSendingInvites( @AuthenticationPrincipal final Long memberId, - @PathVariable(value = "group_id") final Long groupId + @PathVariable(value = "group_id") final Long groupId, + @RequestParam(value = "group_invite_id", required = false) final Long groupInviteId, + @RequestParam(value = "size") final int size ) { - List groupSendingInvites = memberGroupQueryService.findGroupSendingInvites( - memberId, groupId); + GroupSendingInvitesSliceRequestDto dto = GroupSendingInvitesSliceRequestDto.create( + memberId, groupId, groupInviteId, size); + + Slice groupSendingInvitesSlice = memberGroupQueryService.findGroupSendingInvites( + dto); return ResponseEntity.ok( ApiSpec.success( SuccessCode.SUCCESS, - GroupSendingInvitesResponse.createOf(groupSendingInvites) + GroupSendingInvitesSliceResponse.createOf( + groupSendingInvitesSlice.getContent(), + groupSendingInvitesSlice.hasNext() + ) ) ); } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupSendingInvitesSliceRequestDto.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupSendingInvitesSliceRequestDto.java new file mode 100644 index 000000000..823e958b5 --- /dev/null +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupSendingInvitesSliceRequestDto.java @@ -0,0 +1,18 @@ +package site.timecapsulearchive.core.domain.member_group.data.dto; + +public record GroupSendingInvitesSliceRequestDto( + Long memberId, + Long groupId, + Long groupInviteId, + int size +) { + + public static GroupSendingInvitesSliceRequestDto create( + final Long memberId, + final Long groupId, + final Long groupInviteId, + final int size + ) { + return new GroupSendingInvitesSliceRequestDto(memberId, groupId, groupInviteId, size); + } +} diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInvitesResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInvitesSliceResponse.java similarity index 62% rename from backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInvitesResponse.java rename to backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInvitesSliceResponse.java index 4be590970..24b231bbe 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInvitesResponse.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupSendingInvitesSliceResponse.java @@ -5,19 +5,23 @@ import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto; @Schema(description = "그룹 초대 보낸 목록") -public record GroupSendingInvitesResponse( +public record GroupSendingInvitesSliceResponse( @Schema(description = "초대 보낸 그룹원 정보 리스트") - List responses + List groupSendingInviteMembers, + + @Schema(description = "다음 페이지 유무") + boolean hasNext ) { - public static GroupSendingInvitesResponse createOf( - final List groupSendingInviteMemberDtos + public static GroupSendingInvitesSliceResponse createOf( + final List groupSendingInviteMemberDtos, + final boolean hasNext ) { List groupSendingInviteMemberResponses = groupSendingInviteMemberDtos.stream() .map(GroupSendingInviteMemberDto::toResponse) .toList(); - return new GroupSendingInvitesResponse(groupSendingInviteMemberResponses); + return new GroupSendingInvitesSliceResponse(groupSendingInviteMemberResponses, hasNext); } } 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 c9c5c3166..64e878abc 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 @@ -5,6 +5,7 @@ import org.springframework.data.domain.Slice; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto; +import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInvitesSliceRequestDto; public interface GroupInviteQueryRepository { @@ -18,8 +19,7 @@ Slice findGroupReceivingInvitesSlice( final ZonedDateTime createdAt ); - List findGroupSendingInvites( - final Long memberId, - final Long groupId + Slice findGroupSendingInvites( + final GroupSendingInvitesSliceRequestDto dto ); } 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 7f2b33ec6..831b4e8e3 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 @@ -6,6 +6,7 @@ import static site.timecapsulearchive.core.domain.member_group.entity.QGroupInvite.groupInvite; import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -14,14 +15,13 @@ 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; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto; +import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInvitesSliceRequestDto; import site.timecapsulearchive.core.global.util.SliceUtil; @Repository @@ -101,11 +101,10 @@ public Slice findGroupReceivingInvitesSlice( return SliceUtil.makeSlice(size, groupInviteSummaryDtos); } - public List findGroupSendingInvites( - final Long memberId, - final Long groupId + public Slice findGroupSendingInvites( + final GroupSendingInvitesSliceRequestDto dto ) { - return jpaQueryFactory + List groupSendingInviteMemberDtos = jpaQueryFactory .select( Projections.constructor( GroupSendingInviteMemberDto.class, @@ -117,8 +116,24 @@ public List findGroupSendingInvites( ) .from(groupInvite) .join(groupInvite.groupMember, member) - .where(groupInvite.group.id.eq(groupId) - .and(groupInvite.groupOwner.id.eq(memberId))) + .where( + groupInviteIdPagingCursorCondition(dto), + groupInvite.group.id.eq(dto.groupId()) + .and(groupInvite.groupOwner.id.eq(dto.memberId())) + ) + .orderBy(groupInvite.id.desc()) + .limit(dto.size() + 1) .fetch(); + + return SliceUtil.makeSlice(dto.size(), groupSendingInviteMemberDtos); + } + + private BooleanExpression groupInviteIdPagingCursorCondition( + GroupSendingInvitesSliceRequestDto dto) { + if (dto.groupInviteId() == null) { + return null; + } + + return groupInvite.id.lt(dto.groupInviteId()); } } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/service/MemberGroupQueryService.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/service/MemberGroupQueryService.java index dd8141997..bd9f1c113 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/service/MemberGroupQueryService.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/service/MemberGroupQueryService.java @@ -10,6 +10,7 @@ import site.timecapsulearchive.core.domain.group.exception.GroupNotFoundException; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto; +import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInvitesSliceRequestDto; import site.timecapsulearchive.core.domain.member_group.repository.group_invite_repository.GroupInviteRepository; import site.timecapsulearchive.core.domain.member_group.repository.member_group_repository.MemberGroupRepository; @@ -41,10 +42,8 @@ public List findGroupMemberInfos( return memberGroupRepository.findGroupMemberInfos(memberId, groupId); } - public List findGroupSendingInvites( - final Long memberId, - final Long groupId - ) { - return groupInviteRepository.findGroupSendingInvites(memberId, groupId); + public Slice findGroupSendingInvites(final + GroupSendingInvitesSliceRequestDto dto) { + return groupInviteRepository.findGroupSendingInvites(dto); } } diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java index 5e8522e18..03c45d9fc 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java @@ -23,6 +23,7 @@ import site.timecapsulearchive.core.domain.member.entity.Member; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto; import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInviteMemberDto; +import site.timecapsulearchive.core.domain.member_group.data.dto.GroupSendingInvitesSliceRequestDto; import site.timecapsulearchive.core.domain.member_group.entity.GroupInvite; import site.timecapsulearchive.core.domain.member_group.repository.group_invite_repository.GroupInviteQueryRepository; import site.timecapsulearchive.core.domain.member_group.repository.group_invite_repository.GroupInviteQueryRepositoryImpl; @@ -37,6 +38,7 @@ class GroupInviteQueryRepositoryTest extends RepositoryTest { private Long groupId; private Long groupOwnerId; private Long groupMemberId; + private Long firstGroupInviteStartId; GroupInviteQueryRepositoryTest( JdbcTemplate jdbcTemplate, @@ -69,6 +71,10 @@ void setUp(@Autowired EntityManager entityManager) { GroupInvite groupInvite = GroupInvite.createOf(groups.get(i), groupOwners.get(i), groupMember); entityManager.persist(groupInvite); + + if (i == 0) { + firstGroupInviteStartId = groupInvite.getId(); + } } } @@ -129,19 +135,22 @@ void setUp(@Autowired EntityManager entityManager) { @Test void 그룹장은_자신이_보낸_그룹_초대_목록을_조회하면_그룹_초대목록이_나온다() { //given + GroupSendingInvitesSliceRequestDto requestDto = new GroupSendingInvitesSliceRequestDto( + groupOwnerId, groupId, null, 20 + ); + //when - List groupSendingInvites = groupInviteRepository.findGroupSendingInvites( - groupOwnerId, groupId); + Slice groupSendingInvites = groupInviteRepository.findGroupSendingInvites(requestDto); //then SoftAssertions.assertSoftly(softly -> { - softly.assertThat(groupSendingInvites).isNotEmpty(); - softly.assertThat(groupSendingInvites).allMatch(dto -> dto.id() != null); - softly.assertThat(groupSendingInvites) + softly.assertThat(groupSendingInvites.hasContent()).isTrue(); + softly.assertThat(groupSendingInvites.getContent()).allMatch(dto -> dto.id() != null); + softly.assertThat(groupSendingInvites.getContent()) .allMatch(dto -> dto.nickname() != null && !dto.nickname().isBlank()); - softly.assertThat(groupSendingInvites) + softly.assertThat(groupSendingInvites.getContent()) .allMatch(dto -> dto.profileUrl() != null && !dto.profileUrl().isBlank()); - softly.assertThat(groupSendingInvites) + softly.assertThat(groupSendingInvites.getContent()) .allMatch(dto -> dto.sendingInvitesCreatedAt() != null); }); } @@ -149,11 +158,16 @@ void setUp(@Autowired EntityManager entityManager) { @Test void 그룹원은_자신이_보낸_그룹_초대_목록을_조회하면_빈_리스트가_나온다() { //given + GroupSendingInvitesSliceRequestDto requestDto = new GroupSendingInvitesSliceRequestDto( + groupOwnerId, groupId, firstGroupInviteStartId - 1, 20 + ); + //when - List groupSendingInvites = groupInviteRepository.findGroupSendingInvites( - groupMemberId, groupId); + Slice groupSendingInvites = groupInviteRepository.findGroupSendingInvites( + requestDto + ); //then - assertThat(groupSendingInvites).isEmpty(); + assertThat(groupSendingInvites.isEmpty()).isTrue(); } } From 22c18ea582bbb931a2c05c2215a9740a3b6eea10 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Wed, 5 Jun 2024 21:05:20 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix=20:=20=EA=B7=B8=EB=A3=B9=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=20=EC=95=84=EC=9D=B4=EB=94=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 커서 기반 슬라이싱을 위한 groupInviteId 추가 --- .../member_group/data/dto/GroupSendingInviteMemberDto.java | 6 ++++-- .../data/response/GroupSendingInviteMemberResponse.java | 3 ++- .../GroupInviteQueryRepositoryImpl.java | 1 + .../repository/GroupInviteQueryRepositoryTest.java | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupSendingInviteMemberDto.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupSendingInviteMemberDto.java index 2fcb0f82b..4b69a3178 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupSendingInviteMemberDto.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupSendingInviteMemberDto.java @@ -5,7 +5,8 @@ import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInviteMemberResponse; public record GroupSendingInviteMemberDto( - Long id, + Long groupInviteId, + Long memberId, String nickname, String profileUrl, ZonedDateTime sendingInvitesCreatedAt @@ -13,7 +14,8 @@ public record GroupSendingInviteMemberDto( public GroupSendingInviteMemberResponse toResponse() { return GroupSendingInviteMemberResponse.builder() - .id(id) + .groupInviteId(groupInviteId) + .memberId(memberId) .nickname(nickname) .profileUrl(profileUrl) .sendingInvitesCreatedAt(sendingInvitesCreatedAt) 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..cee057b8a 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 @@ -6,7 +6,8 @@ @Builder public record GroupSendingInviteMemberResponse( - Long id, + Long groupInviteId, + Long memberId, String nickname, String profileUrl, ZonedDateTime sendingInvitesCreatedAt 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 831b4e8e3..b3ffe71ce 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 @@ -108,6 +108,7 @@ public Slice findGroupSendingInvites( .select( Projections.constructor( GroupSendingInviteMemberDto.class, + groupInvite.id, member.id, member.nickname, member.profileUrl, diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java index 03c45d9fc..d9d51aeae 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java @@ -145,7 +145,8 @@ void setUp(@Autowired EntityManager entityManager) { //then SoftAssertions.assertSoftly(softly -> { softly.assertThat(groupSendingInvites.hasContent()).isTrue(); - softly.assertThat(groupSendingInvites.getContent()).allMatch(dto -> dto.id() != null); + softly.assertThat(groupSendingInvites.getContent()).allMatch(dto -> dto.groupInviteId() != null); + softly.assertThat(groupSendingInvites.getContent()).allMatch(dto -> dto.memberId() != null); softly.assertThat(groupSendingInvites.getContent()) .allMatch(dto -> dto.nickname() != null && !dto.nickname().isBlank()); softly.assertThat(groupSendingInvites.getContent()) From c0a38806bad984486c916e55411d2c58bc501045 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Wed, 5 Jun 2024 21:24:22 +0900 Subject: [PATCH 4/6] =?UTF-8?q?test=20:=20=EC=8A=AC=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EA=B2=80=EC=A6=9D=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GroupInviteQueryRepositoryTest.java | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java index d9d51aeae..753f7c901 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/GroupInviteQueryRepositoryTest.java @@ -32,13 +32,14 @@ class GroupInviteQueryRepositoryTest extends RepositoryTest { private static final int MAX_GROUP_COUNT = 2; + private static final int MAX_GROUP_INVITE_COUNT = 10; private final GroupInviteQueryRepository groupInviteRepository; private Long groupId; private Long groupOwnerId; private Long groupMemberId; - private Long firstGroupInviteStartId; + private Long firstGroupInviteStartId = null; GroupInviteQueryRepositoryTest( JdbcTemplate jdbcTemplate, @@ -56,10 +57,12 @@ void setUp(@Autowired EntityManager entityManager) { groupOwners.forEach(entityManager::persist); groupOwnerId = groupOwners.get(0).getId(); - //그룹 초대 올 그룹원 - Member groupMember = MemberFixture.member(2); - entityManager.persist(groupMember); - groupMemberId = groupMember.getId(); + //그룹 초대 올 그룹원들 + List groupMembers = MemberFixture.members(2, MAX_GROUP_INVITE_COUNT); + for (Member groupMember : groupMembers) { + entityManager.persist(groupMember); + } + groupMemberId = groupMembers.get(0).getId(); // 그룹들 List groups = GroupFixture.groups(0, MAX_GROUP_COUNT); @@ -68,12 +71,14 @@ void setUp(@Autowired EntityManager entityManager) { // 그룹원에게 초대온 그룹 초대들 for (int i = 0; i < MAX_GROUP_COUNT; i++) { - GroupInvite groupInvite = GroupInvite.createOf(groups.get(i), groupOwners.get(i), - groupMember); - entityManager.persist(groupInvite); - - if (i == 0) { - firstGroupInviteStartId = groupInvite.getId(); + for (Member groupMember : groupMembers) { + GroupInvite groupInvite = GroupInvite.createOf(groups.get(i), groupOwners.get(i), + groupMember); + entityManager.persist(groupInvite); + + if (firstGroupInviteStartId == null) { + firstGroupInviteStartId = groupInvite.getId(); + } } } } @@ -140,13 +145,16 @@ void setUp(@Autowired EntityManager entityManager) { ); //when - Slice groupSendingInvites = groupInviteRepository.findGroupSendingInvites(requestDto); + Slice groupSendingInvites = groupInviteRepository.findGroupSendingInvites( + requestDto); //then SoftAssertions.assertSoftly(softly -> { softly.assertThat(groupSendingInvites.hasContent()).isTrue(); - softly.assertThat(groupSendingInvites.getContent()).allMatch(dto -> dto.groupInviteId() != null); - softly.assertThat(groupSendingInvites.getContent()).allMatch(dto -> dto.memberId() != null); + softly.assertThat(groupSendingInvites.getContent()) + .allMatch(dto -> dto.groupInviteId() != null); + softly.assertThat(groupSendingInvites.getContent()) + .allMatch(dto -> dto.memberId() != null); softly.assertThat(groupSendingInvites.getContent()) .allMatch(dto -> dto.nickname() != null && !dto.nickname().isBlank()); softly.assertThat(groupSendingInvites.getContent()) @@ -171,4 +179,24 @@ void setUp(@Autowired EntityManager entityManager) { //then assertThat(groupSendingInvites.isEmpty()).isTrue(); } + + @Test + void 사용자는_그룹_초대_보낸_목록_첫_페이지를_조회_후_다음_페이지에서_그룹_초대_보낸_목록을_조회_할_수_있다() { + //given + GroupSendingInvitesSliceRequestDto dto = GroupSendingInvitesSliceRequestDto.create( + groupOwnerId, groupId, null, MAX_GROUP_INVITE_COUNT / 2); + Slice firstSlice = groupInviteRepository.findGroupSendingInvites( + dto); + + //when + GroupSendingInviteMemberDto lastGroupInvite = firstSlice.getContent() + .get(firstSlice.getNumberOfElements() - 1); + Slice nextSlice = groupInviteRepository.findGroupSendingInvites( + GroupSendingInvitesSliceRequestDto.create(groupOwnerId, groupId, + lastGroupInvite.groupInviteId(), 20) + ); + + //then + assertThat(nextSlice.getContent()).isNotEmpty(); + } } From edf34ff31be9bbc4459ac5b788bcf4f1fd09a881 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Thu, 6 Jun 2024 11:00:13 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix=20:=20=EA=B7=B8=EB=A3=B9=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=20=EC=95=84=EC=9D=B4=EB=94=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/member_group/data/dto/GroupInviteSummaryDto.java | 2 +- .../data/response/GroupReceivingInviteSummaryResponse.java | 3 +++ .../GroupInviteQueryRepositoryImpl.java | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupInviteSummaryDto.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupInviteSummaryDto.java index a5fb7fb54..ab0a06cc3 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupInviteSummaryDto.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/dto/GroupInviteSummaryDto.java @@ -7,7 +7,7 @@ @Builder public record GroupInviteSummaryDto( - + Long groupInviteId, Long groupId, String groupName, String groupProfileUrl, diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupReceivingInviteSummaryResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupReceivingInviteSummaryResponse.java index 13d154fff..24d6cd9ec 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupReceivingInviteSummaryResponse.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/data/response/GroupReceivingInviteSummaryResponse.java @@ -9,6 +9,9 @@ @Schema(description = "초대온 그룹 요약 정보") public record GroupReceivingInviteSummaryResponse( + @Schema(description = "그룹 초대 아이디") + Long groupInviteId, + @Schema(description = "그룹 아이디") Long groupId, 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 b3ffe71ce..2f1ff36aa 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 @@ -83,6 +83,7 @@ public Slice findGroupReceivingInvitesSlice( .select( Projections.constructor( GroupInviteSummaryDto.class, + groupInvite.id, group.id, group.groupName, group.groupProfileUrl, From d45ac975eb4716810e0a9450781c55157e61c873 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Thu, 6 Jun 2024 14:46:36 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix=20:=20presign=20url=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infra/queue/manager/SocialNotificationManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/infra/queue/manager/SocialNotificationManager.java b/backend/core/src/main/java/site/timecapsulearchive/core/infra/queue/manager/SocialNotificationManager.java index dbaf4e480..8b251c60b 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/infra/queue/manager/SocialNotificationManager.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/infra/queue/manager/SocialNotificationManager.java @@ -61,12 +61,10 @@ public void sendFriendRequestMessages( return; } - String preSignedUrl = s3PreSignedUrlManager.getS3PreSignedUrlForGet(profileUrl); - basicRabbitTemplate.convertAndSend( RabbitmqComponentConstants.FRIEND_REQUEST_NOTIFICATION_EXCHANGE.getSuccessComponent(), RabbitmqComponentConstants.FRIEND_REQUEST_NOTIFICATION_QUEUE.getSuccessComponent(), - FriendsReqNotificationsDto.createOf(ownerNickname, preSignedUrl, targetIds) + FriendsReqNotificationsDto.createOf(ownerNickname, profileUrl, targetIds) ); } @@ -75,10 +73,12 @@ public void sendGroupInviteMessage( final String groupProfileUrl, final List targetIds ) { + String preSignedUrl = s3PreSignedUrlManager.getS3PreSignedUrlForGet(groupProfileUrl); + basicRabbitTemplate.convertAndSend( RabbitmqComponentConstants.GROUP_INVITE_NOTIFICATION_EXCHANGE.getSuccessComponent(), RabbitmqComponentConstants.GROUP_INVITE_NOTIFICATION_QUEUE.getSuccessComponent(), - GroupInviteNotificationDto.createOf(ownerNickname, groupProfileUrl, targetIds) + GroupInviteNotificationDto.createOf(ownerNickname, preSignedUrl, targetIds) ); }