Skip to content

Commit

Permalink
Merge pull request #477 from tukcomCD2024/fix/group_invite_list-B-#472
Browse files Browse the repository at this point in the history
fix : 그룹 초대 슬라이스로 변경 & 그룹장 프로필 오류 수정
  • Loading branch information
seokho-1116 authored Jun 7, 2024
2 parents eada8af + 971f0b3 commit ab203f3
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -69,10 +69,16 @@ ResponseEntity<ApiSpec<GroupMemberInfosResponse>> findGroupMemberInfos(
description = "ok"
)
})
ResponseEntity<ApiSpec<GroupSendingInvitesResponse>> findGroupSendingInvites(
ResponseEntity<ApiSpec<GroupSendingInvitesSliceResponse>> 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
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,17 +85,25 @@ public ResponseEntity<ApiSpec<GroupMemberInfosResponse>> findGroupMemberInfos(
produces = {"application/json"}
)
@Override
public ResponseEntity<ApiSpec<GroupSendingInvitesResponse>> findGroupSendingInvites(
public ResponseEntity<ApiSpec<GroupSendingInvitesSliceResponse>> 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<GroupSendingInviteMemberDto> groupSendingInvites = memberGroupQueryService.findGroupSendingInvites(
memberId, groupId);
GroupSendingInvitesSliceRequestDto dto = GroupSendingInvitesSliceRequestDto.create(
memberId, groupId, groupInviteId, size);

Slice<GroupSendingInviteMemberDto> groupSendingInvitesSlice = memberGroupQueryService.findGroupSendingInvites(
dto);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
GroupSendingInvitesResponse.createOf(groupSendingInvites)
GroupSendingInvitesSliceResponse.createOf(
groupSendingInvitesSlice.getContent(),
groupSendingInvitesSlice.hasNext()
)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Builder
public record GroupInviteSummaryDto(

Long groupInviteId,
Long groupId,
String groupName,
String groupProfileUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
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
) {

public GroupSendingInviteMemberResponse toResponse() {
return GroupSendingInviteMemberResponse.builder()
.id(id)
.groupInviteId(groupInviteId)
.memberId(memberId)
.nickname(nickname)
.profileUrl(profileUrl)
.sendingInvitesCreatedAt(sendingInvitesCreatedAt)
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
@Schema(description = "초대온 그룹 요약 정보")
public record GroupReceivingInviteSummaryResponse(

@Schema(description = "그룹 초대 아이디")
Long groupInviteId,

@Schema(description = "그룹 아이디")
Long groupId,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

@Builder
public record GroupSendingInviteMemberResponse(
Long id,
Long groupInviteId,
Long memberId,
String nickname,
String profileUrl,
ZonedDateTime sendingInvitesCreatedAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GroupSendingInviteMemberResponse> responses
List<GroupSendingInviteMemberResponse> groupSendingInviteMembers,

@Schema(description = "다음 페이지 유무")
boolean hasNext
) {

public static GroupSendingInvitesResponse createOf(
final List<GroupSendingInviteMemberDto> groupSendingInviteMemberDtos
public static GroupSendingInvitesSliceResponse createOf(
final List<GroupSendingInviteMemberDto> groupSendingInviteMemberDtos,
final boolean hasNext
) {
List<GroupSendingInviteMemberResponse> groupSendingInviteMemberResponses = groupSendingInviteMemberDtos.stream()
.map(GroupSendingInviteMemberDto::toResponse)
.toList();

return new GroupSendingInvitesResponse(groupSendingInviteMemberResponses);
return new GroupSendingInvitesSliceResponse(groupSendingInviteMemberResponses, hasNext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -20,8 +21,7 @@ Slice<GroupInviteSummaryDto> findGroupReceivingInvitesSlice(

List<Long> findGroupMemberIdsByGroupIdAndGroupOwnerId(final Long groupId, final Long memberId);

List<GroupSendingInviteMemberDto> findGroupSendingInvites(
final Long memberId,
final Long groupId
Slice<GroupSendingInviteMemberDto> findGroupSendingInvites(
final GroupSendingInvitesSliceRequestDto dto
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
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.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.impl.JPAQueryFactory;
import java.sql.PreparedStatement;
import java.sql.SQLException;
Expand All @@ -20,6 +22,8 @@
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.domain.member_group.data.dto.GroupSendingInvitesSliceRequestDto;
import site.timecapsulearchive.core.global.util.SliceUtil;

@Repository
Expand Down Expand Up @@ -84,6 +88,7 @@ public Slice<GroupInviteSummaryDto> findGroupReceivingInvitesSlice(
.select(
Projections.constructor(
GroupInviteSummaryDto.class,
groupInvite.id,
group.id,
group.groupName,
group.groupProfileUrl,
Expand Down Expand Up @@ -115,14 +120,14 @@ public List<Long> findGroupMemberIdsByGroupIdAndGroupOwnerId(
}

@Override
public List<GroupSendingInviteMemberDto> findGroupSendingInvites(
final Long memberId,
final Long groupId
public Slice<GroupSendingInviteMemberDto> findGroupSendingInvites(
final GroupSendingInvitesSliceRequestDto dto
) {
return jpaQueryFactory
List<GroupSendingInviteMemberDto> groupSendingInviteMemberDtos = jpaQueryFactory
.select(
Projections.constructor(
GroupSendingInviteMemberDto.class,
groupInvite.id,
member.id,
member.nickname,
member.profileUrl,
Expand All @@ -131,8 +136,24 @@ public List<GroupSendingInviteMemberDto> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -41,10 +42,8 @@ public List<GroupMemberDto> findGroupMemberInfos(
return memberGroupRepository.findGroupMemberInfos(memberId, groupId);
}

public List<GroupSendingInviteMemberDto> findGroupSendingInvites(
final Long memberId,
final Long groupId
) {
return groupInviteRepository.findGroupSendingInvites(memberId, groupId);
public Slice<GroupSendingInviteMemberDto> findGroupSendingInvites(final
GroupSendingInvitesSliceRequestDto dto) {
return groupInviteRepository.findGroupSendingInvites(dto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* 단건의 친구 요청을 받아서 알림 전송을 요청한다
Expand Down Expand Up @@ -71,10 +73,12 @@ public void sendGroupInviteMessage(
final String groupProfileUrl,
final List<Long> 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)
);
}

Expand Down
Loading

0 comments on commit ab203f3

Please sign in to comment.