Skip to content
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

feat : 그룹 초대 받은 목록, 보낸 목록 API 추가 #465

Merged
merged 10 commits into from
Jun 4, 2024
Prev Previous commit
Next Next commit
fix : 단어 수정
- 더 명확한 의미를 위해 반의어인 receiving으로 수정
seokho-1116 committed Jun 4, 2024
commit 603f155bf1d13b543cd8d8e4ee62d27d63c8aae6
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.time.ZonedDateTime;
import org.springframework.http.ResponseEntity;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceptionInvitesSliceResponse;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceivingInvitesSliceResponse;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupSendingInvitesResponse;
import site.timecapsulearchive.core.global.common.response.ApiSpec;

@@ -27,7 +27,7 @@ public interface MemberGroupQueryApi {
description = "ok"
)
})
ResponseEntity<ApiSpec<GroupReceptionInvitesSliceResponse>> findGroupReceptionInvites(
ResponseEntity<ApiSpec<GroupReceivingInvitesSliceResponse>> findGroupReceivingInvites(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "페이지 크기", required = true)
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import org.springframework.web.bind.annotation.RestController;
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.response.GroupReceptionInvitesSliceResponse;
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.service.MemberGroupQueryService;
import site.timecapsulearchive.core.global.common.response.ApiSpec;
@@ -30,24 +30,24 @@ public class MemberGroupQueryApiController implements MemberGroupQueryApi {


@GetMapping(
value = "/reception-invites",
value = "/receiving-invites",
produces = {"application/json"}
)
@Override
public ResponseEntity<ApiSpec<GroupReceptionInvitesSliceResponse>> findGroupReceptionInvites(
public ResponseEntity<ApiSpec<GroupReceivingInvitesSliceResponse>> findGroupReceivingInvites(
@AuthenticationPrincipal final Long memberId,
@RequestParam(defaultValue = "20", value = "size") final int size,
@RequestParam(value = "created_at") final ZonedDateTime createdAt
) {
final Slice<GroupInviteSummaryDto> groupInviteSummarySlice = memberGroupQueryService.findGroupReceptionInvitesSlice(
final Slice<GroupInviteSummaryDto> groupReceivingInvitesSlice = memberGroupQueryService.findGroupReceivingInvitesSlice(
memberId, size, createdAt);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
GroupReceptionInvitesSliceResponse.createOf(
groupInviteSummarySlice.getContent(),
groupInviteSummarySlice.hasNext(),
GroupReceivingInvitesSliceResponse.createOf(
groupReceivingInvitesSlice.getContent(),
groupReceivingInvitesSlice.hasNext(),
s3PreSignedUrlManager::getS3PreSignedUrlForGet
)
)
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import java.time.ZonedDateTime;
import java.util.function.Function;
import lombok.Builder;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceptionInviteSummaryResponse;
import site.timecapsulearchive.core.domain.member_group.data.response.GroupReceivingInviteSummaryResponse;

@Builder
public record GroupInviteSummaryDto(
@@ -12,19 +12,19 @@ public record GroupInviteSummaryDto(
String groupName,
String groupProfileUrl,
String description,
ZonedDateTime groupReceptionInviteTime,
ZonedDateTime groupReceivingInviteTime,
String groupOwnerName
) {

public GroupReceptionInviteSummaryResponse toResponse(
public GroupReceivingInviteSummaryResponse toResponse(
final Function<String, String> preSignedUrlFunction
) {
return GroupReceptionInviteSummaryResponse.builder()
return GroupReceivingInviteSummaryResponse.builder()
.groupId(groupId)
.groupName(groupName)
.groupProfileUrl(preSignedUrlFunction.apply(groupProfileUrl))
.description(description)
.groupReceptionInviteTime(groupReceptionInviteTime)
.groupReceivingInviteTime(groupReceivingInviteTime)
.groupOwnerName(groupOwnerName)
.build();
}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

@Builder
@Schema(description = "초대온 그룹 요약 정보")
public record GroupReceptionInviteSummaryResponse(
public record GroupReceivingInviteSummaryResponse(

@Schema(description = "그룹 아이디")
Long groupId,
@@ -22,15 +22,15 @@ public record GroupReceptionInviteSummaryResponse(
String description,

@Schema(description = "그룹 초대 시간")
ZonedDateTime groupReceptionInviteTime,
ZonedDateTime groupReceivingInviteTime,

@Schema(description = "그룹장")
String groupOwnerName
) {

public GroupReceptionInviteSummaryResponse {
if (groupReceptionInviteTime != null) {
groupReceptionInviteTime = groupReceptionInviteTime.withZoneSameInstant(
public GroupReceivingInviteSummaryResponse {
if (groupReceivingInviteTime != null) {
groupReceivingInviteTime = groupReceivingInviteTime.withZoneSameInstant(
ResponseMappingConstant.ZONE_ID);
}
}
Original file line number Diff line number Diff line change
@@ -5,23 +5,23 @@
import java.util.function.Function;
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupInviteSummaryDto;

public record GroupReceptionInvitesSliceResponse(
public record GroupReceivingInvitesSliceResponse(
@Schema(description = "초대 온 그룹 요약 정보 리스트")
List<GroupReceptionInviteSummaryResponse> responses,
List<GroupReceivingInviteSummaryResponse> responses,

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

public static GroupReceptionInvitesSliceResponse createOf(
public static GroupReceivingInvitesSliceResponse createOf(
final List<GroupInviteSummaryDto> dtos,
final boolean hasNext,
final Function<String, String> preSignedUrlFunction
) {
List<GroupReceptionInviteSummaryResponse> groupReceptionInviteSummaryResponses = dtos.stream()
List<GroupReceivingInviteSummaryResponse> groupReceivingInviteSummaryResponse = dtos.stream()
.map(dto -> dto.toResponse(preSignedUrlFunction)).toList();

return new GroupReceptionInvitesSliceResponse(groupReceptionInviteSummaryResponses,
return new GroupReceivingInvitesSliceResponse(groupReceivingInviteSummaryResponse,
hasNext);
}
}
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ public interface GroupInviteQueryRepository {

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

Slice<GroupInviteSummaryDto> findGroupRecetpionInvitesSlice(
Slice<GroupInviteSummaryDto> findGroupReceivingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
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.global.util.SliceUtil;

@Repository
@RequiredArgsConstructor
@@ -72,7 +73,7 @@ public List<Long> findGroupInviteIdsByGroupIdAndGroupOwnerId(
}

@Override
public Slice<GroupInviteSummaryDto> findGroupRecetpionInvitesSlice(
public Slice<GroupInviteSummaryDto> findGroupReceivingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
@@ -96,22 +97,9 @@ public Slice<GroupInviteSummaryDto> findGroupRecetpionInvitesSlice(
.limit(size + 1)
.fetch();

return makeSlice(size, groupInviteSummaryDtos);
return SliceUtil.makeSlice(size, groupInviteSummaryDtos);
}

private <T> Slice<T> makeSlice(
final int size,
final List<T> dtos
) {
final boolean hasNext = dtos.size() > size;
if (hasNext) {
dtos.remove(size);
}

return new SliceImpl<>(dtos, Pageable.ofSize(size), hasNext);
}

@Override
public List<GroupSendingInviteMemberDto> findGroupSendingInvites(
final Long memberId,
final Long groupId
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@ public class MemberGroupQueryService {

private final GroupInviteRepository groupInviteRepository;

public Slice<GroupInviteSummaryDto> findGroupReceptionInvitesSlice(
public Slice<GroupInviteSummaryDto> findGroupReceivingInvitesSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
return groupInviteRepository.findGroupRecetpionInvitesSlice(memberId, size, createdAt);
return groupInviteRepository.findGroupReceivingInvitesSlice(memberId, size, createdAt);
}

public List<GroupSendingInviteMemberDto> findGroupSendingInvites(
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ void setUp(@Autowired EntityManager entityManager) {
ZonedDateTime createAt = ZonedDateTime.now().plusDays(1);

//when
Slice<GroupInviteSummaryDto> groupInvitesSummary = groupInviteRepository.findGroupRecetpionInvitesSlice(
Slice<GroupInviteSummaryDto> groupInvitesSummary = groupInviteRepository.findGroupReceivingInvitesSlice(
memberId, size, createAt);

//then
@@ -95,7 +95,7 @@ void setUp(@Autowired EntityManager entityManager) {
ZonedDateTime createAt = ZonedDateTime.now().plusDays(1);

//when
Slice<GroupInviteSummaryDto> groupInvitesSummary = groupInviteRepository.findGroupRecetpionInvitesSlice(
Slice<GroupInviteSummaryDto> groupInvitesSummary = groupInviteRepository.findGroupReceivingInvitesSlice(
memberId, size, createAt);

//then
@@ -114,13 +114,13 @@ void setUp(@Autowired EntityManager entityManager) {
Long memberId = groupMemberId;
int size = 1;
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")).plusDays(3);
Slice<GroupInviteSummaryDto> firstSlice = groupInviteRepository.findGroupRecetpionInvitesSlice(
Slice<GroupInviteSummaryDto> firstSlice = groupInviteRepository.findGroupReceivingInvitesSlice(
memberId, size, now);

//when
GroupInviteSummaryDto dto = firstSlice.getContent().get(0);
Slice<GroupInviteSummaryDto> groupInvitesSummary = groupInviteRepository.findGroupRecetpionInvitesSlice(
memberId, size, dto.groupReceptionInviteTime().plusSeconds(1L));
Slice<GroupInviteSummaryDto> groupInvitesSummary = groupInviteRepository.findGroupReceivingInvitesSlice(
memberId, size, dto.groupReceivingInviteTime().plusSeconds(1L));

//then
assertThat(groupInvitesSummary.getContent()).isNotEmpty();