Skip to content

Commit

Permalink
Merge branch 'develop_back_core' into feat/group_member_capsule_open_…
Browse files Browse the repository at this point in the history
…status-B-#484
  • Loading branch information
seokho-1116 authored Jun 11, 2024
2 parents bb93601 + 889f189 commit 3a22e75
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 244 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto;
package site.timecapsulearchive.core.domain.capsule.data.dto;

import java.time.ZonedDateTime;
import java.util.function.Function;
import site.timecapsulearchive.core.domain.capsule.data.response.CapsuleBasicInfoResponse;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.MyGroupCapsuleResponse;

public record MyGroupCapsuleDto(
public record CapsuleBasicInfoDto(
Long capsuleId,
String skinUrl,
ZonedDateTime dueDate,
Expand All @@ -15,9 +15,9 @@ public record MyGroupCapsuleDto(
CapsuleType capsuleType
) {

public MyGroupCapsuleResponse toResponse(
public CapsuleBasicInfoResponse toResponse(
final Function<String, String> singlePreSignUrlFunction) {
return MyGroupCapsuleResponse.builder()
return CapsuleBasicInfoResponse.builder()
.capsuleId(capsuleId)
.skinUrl(singlePreSignUrlFunction.apply(skinUrl))
.dueDate(dueDate)
Expand All @@ -27,4 +27,4 @@ public MyGroupCapsuleResponse toResponse(
.capsuleType(capsuleType)
.build();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.data.response;
package site.timecapsulearchive.core.domain.capsule.data.response;

import io.swagger.v3.oas.annotations.media.Schema;
import java.time.ZonedDateTime;
Expand All @@ -7,8 +7,8 @@
import site.timecapsulearchive.core.global.common.response.ResponseMappingConstant;

@Builder
@Schema(description = "사용자가 만든 그룹 캡슐")
public record MyGroupCapsuleResponse(
@Schema(description = "캡슐 기본 정보")
public record CapsuleBasicInfoResponse(

@Schema(description = "캡슐 아이디")
Long capsuleId,
Expand All @@ -32,7 +32,7 @@ public record MyGroupCapsuleResponse(
CapsuleType capsuleType
) {

public MyGroupCapsuleResponse {
public CapsuleBasicInfoResponse {
if (dueDate != null) {
dueDate = dueDate.withZoneSameInstant(ResponseMappingConstant.ZONE_ID);
}
Expand All @@ -41,4 +41,4 @@ public record MyGroupCapsuleResponse(
createdAt = createdAt.withZoneSameInstant(ResponseMappingConstant.ZONE_ID);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleOpenStateDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSummaryDto;
Expand Down Expand Up @@ -124,7 +125,7 @@ public ResponseEntity<ApiSpec<MyGroupCapsuleSliceResponse>> getMyGroupCapsules(
@RequestParam(defaultValue = "20", value = "size") final int size,
@RequestParam(value = "created_at") final ZonedDateTime createdAt
) {
final Slice<MyGroupCapsuleDto> groupCapsules = groupCapsuleService.findMyGroupCapsuleSlice(
final Slice<CapsuleBasicInfoDto> groupCapsules = groupCapsuleService.findMyGroupCapsuleSlice(
memberId,
size,
createdAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import java.util.List;
import java.util.function.Function;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.MyGroupCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.data.response.CapsuleBasicInfoResponse;

public record MyGroupCapsuleSliceResponse(
List<MyGroupCapsuleResponse> groupCapsules,
List<CapsuleBasicInfoResponse> groupCapsules,
Boolean hasNext
) {

public static MyGroupCapsuleSliceResponse createOf(
final List<MyGroupCapsuleDto> groupCapsules,
final List<CapsuleBasicInfoDto> groupCapsules,
final boolean hasNext,
final Function<String, String> singlePreSignUrlFunction
) {
List<MyGroupCapsuleResponse> groupCapsuleResponses = groupCapsules.stream()
List<CapsuleBasicInfoResponse> groupCapsuleResponses = groupCapsules.stream()
.map(capsule -> capsule.toResponse(singlePreSignUrlFunction))
.toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
import org.springframework.stereotype.Repository;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.MyGroupCapsuleDto;
import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberSummaryDto;
import site.timecapsulearchive.core.domain.member.entity.QMember;
import site.timecapsulearchive.core.global.util.SliceUtil;

@Repository
@RequiredArgsConstructor
Expand Down Expand Up @@ -131,15 +130,15 @@ public Optional<GroupCapsuleSummaryDto> findGroupCapsuleSummaryDtoByCapsuleId(
).get(capsuleId));
}

public Slice<MyGroupCapsuleDto> findMyGroupCapsuleSlice(
public Slice<CapsuleBasicInfoDto> findMyGroupCapsuleSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
final List<MyGroupCapsuleDto> groupCapsules = jpaQueryFactory
final List<CapsuleBasicInfoDto> groupCapsules = jpaQueryFactory
.select(
Projections.constructor(
MyGroupCapsuleDto.class,
CapsuleBasicInfoDto.class,
capsule.id,
capsuleSkin.imageUrl,
capsule.dueDate,
Expand All @@ -159,12 +158,7 @@ public Slice<MyGroupCapsuleDto> findMyGroupCapsuleSlice(
.limit(size + 1)
.fetch();

final boolean hasNext = groupCapsules.size() > size;
if (hasNext) {
groupCapsules.remove(size);
}

return new SliceImpl<>(groupCapsules, Pageable.ofSize(size), hasNext);
return SliceUtil.makeSlice(size, groupCapsules);
}

public boolean findGroupCapsuleExistByGroupId(Long groupId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.entity.Capsule;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.exception.CapsuleNotFondException;
Expand Down Expand Up @@ -89,7 +90,7 @@ public GroupCapsuleSummaryDto findGroupCapsuleSummaryByGroupIDAndCapsuleId(
* @param createdAt 조회를 시작할 캡슐의 생성 시간, 첫 조회라면 현재 시간, 이후 조회라면 맨 마지막 데이터의 시간
* @return 사용자가 생성한 그룹 캡슐 목록
*/
public Slice<MyGroupCapsuleDto> findMyGroupCapsuleSlice(
public Slice<CapsuleBasicInfoDto> findMyGroupCapsuleSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.request.CapsuleCreateRequest;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.response.CapsuleDetailResponse;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.response.CapsuleSummaryResponse;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.facade.CapsuleFacade;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.dto.MyPublicCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.dto.MyPublicCapsuleSliceResponse;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.dto.PublicCapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.reqeust.PublicCapsuleUpdateRequest;
Expand Down Expand Up @@ -137,7 +137,7 @@ public ResponseEntity<ApiSpec<MyPublicCapsuleSliceResponse>> getMyPublicCapsules
@RequestParam(defaultValue = "20", value = "size") final int size,
@RequestParam(value = "created_at") final ZonedDateTime createdAt
) {
final Slice<MyPublicCapsuleDto> publicCapsules = publicCapsuleService.findMyPublicCapsuleSlice(
final Slice<CapsuleBasicInfoDto> publicCapsules = publicCapsuleService.findMyPublicCapsuleSlice(
memberId, size, createdAt);

return ResponseEntity.ok(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import java.util.function.Function;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.response.MyPublicCapsuleResponse;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.data.response.CapsuleBasicInfoResponse;

@Schema(description = "사용자가 만든 공개 캡슐 슬라이싱")
public record MyPublicCapsuleSliceResponse(

@Schema(description = "사용자가 만든 공개 캡슐 정보")
List<MyPublicCapsuleResponse> publicCapsules,
List<CapsuleBasicInfoResponse> publicCapsules,

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

public static MyPublicCapsuleSliceResponse createOf(
final List<MyPublicCapsuleDto> publicCapsules,
final List<CapsuleBasicInfoDto> publicCapsules,
final boolean hasNext,
final Function<String, String> singlePreSignUrlFunction
) {
List<MyPublicCapsuleResponse> publicCapsuleResponses = publicCapsules.stream()
List<CapsuleBasicInfoResponse> publicCapsuleResponses = publicCapsules.stream()
.map(capsule -> capsule.toResponse(singlePreSignUrlFunction))
.toList();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
import org.springframework.stereotype.Repository;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.dto.MyPublicCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.dto.PublicCapsuleDetailDto;
import site.timecapsulearchive.core.global.util.SliceUtil;

@Repository
@RequiredArgsConstructor
Expand Down Expand Up @@ -158,28 +159,22 @@ public Slice<PublicCapsuleDetailDto> findPublicCapsulesDtoMadeByFriend(
.limit(size + 1)
.fetch();

final boolean hasNext = canMoreRead(size, publicCapsuleDetailDtos.size());
if (hasNext) {
publicCapsuleDetailDtos.remove(size);
}

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

return SliceUtil.makeSlice(size, publicCapsuleDetailDtos);
}

private boolean canMoreRead(final int size, final int capsuleSize) {
return capsuleSize > size;
}

public Slice<MyPublicCapsuleDto> findMyPublicCapsuleSlice(
public Slice<CapsuleBasicInfoDto> findMyPublicCapsuleSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
) {
final List<MyPublicCapsuleDto> publicCapsules = jpaQueryFactory
final List<CapsuleBasicInfoDto> publicCapsules = jpaQueryFactory
.select(
Projections.constructor(
MyPublicCapsuleDto.class,
CapsuleBasicInfoDto.class,
capsule.id,
capsuleSkin.imageUrl,
capsule.dueDate,
Expand All @@ -199,11 +194,6 @@ public Slice<MyPublicCapsuleDto> findMyPublicCapsuleSlice(
.limit(size + 1)
.fetch();

final boolean hasNext = publicCapsules.size() > size;
if (hasNext) {
publicCapsules.remove(size);
}

return new SliceImpl<>(publicCapsules, Pageable.ofSize(size), hasNext);
return SliceUtil.makeSlice(size, publicCapsules);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.exception.CapsuleNotFondException;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.dto.MyPublicCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.public_capsule.data.dto.PublicCapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.public_capsule.repository.PublicCapsuleQueryRepository;

Expand Down Expand Up @@ -70,7 +70,7 @@ public Slice<PublicCapsuleDetailDto> findPublicCapsulesMadeByFriend(
* @param createdAt 조회를 시작할 캡슐의 생성 시간, 첫 조회라면 현재 시간, 이후 조회라면 맨 마지막 데이터의 시간
* @return 사용자가 생성한 공개 캡슐 목록
*/
public Slice<MyPublicCapsuleDto> findMyPublicCapsuleSlice(
public Slice<CapsuleBasicInfoDto> findMyPublicCapsuleSlice(
final Long memberId,
final int size,
final ZonedDateTime createdAt
Expand Down
Loading

0 comments on commit 3a22e75

Please sign in to comment.