From 77bf76ce29b6b7055d864fd0317aef39df63eb82 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sat, 8 Jun 2024 19:18:35 +0900 Subject: [PATCH 1/6] =?UTF-8?q?fix=20:=20=EA=B3=B5=ED=86=B5=20DTO=20?= =?UTF-8?q?=EC=B6=94=EC=B6=9C=20=EB=B0=8F=20=EA=B8=B0=EC=A1=B4=20DTO=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/CapsuleBasicInfoDto.java} | 12 ++++++------ .../response/CapsuleBasicInfoResponse.java} | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) rename backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/{group_capsule/data/dto/MyGroupCapsuleDto.java => data/dto/CapsuleBasicInfoDto.java} (68%) rename backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/{group_capsule/data/response/MyGroupCapsuleResponse.java => data/response/CapsuleBasicInfoResponse.java} (82%) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/data/dto/MyGroupCapsuleDto.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/data/dto/CapsuleBasicInfoDto.java similarity index 68% rename from backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/data/dto/MyGroupCapsuleDto.java rename to backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/data/dto/CapsuleBasicInfoDto.java index e2adb4825..fffbe3fe2 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/data/dto/MyGroupCapsuleDto.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/data/dto/CapsuleBasicInfoDto.java @@ -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, @@ -15,9 +15,9 @@ public record MyGroupCapsuleDto( CapsuleType capsuleType ) { - public MyGroupCapsuleResponse toResponse( + public CapsuleBasicInfoResponse toResponse( final Function singlePreSignUrlFunction) { - return MyGroupCapsuleResponse.builder() + return CapsuleBasicInfoResponse.builder() .capsuleId(capsuleId) .skinUrl(singlePreSignUrlFunction.apply(skinUrl)) .dueDate(dueDate) @@ -27,4 +27,4 @@ public MyGroupCapsuleResponse toResponse( .capsuleType(capsuleType) .build(); } -} +} \ No newline at end of file diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/data/response/MyGroupCapsuleResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/data/response/CapsuleBasicInfoResponse.java similarity index 82% rename from backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/data/response/MyGroupCapsuleResponse.java rename to backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/data/response/CapsuleBasicInfoResponse.java index 256d80354..883e1c4e9 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/data/response/MyGroupCapsuleResponse.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/data/response/CapsuleBasicInfoResponse.java @@ -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; @@ -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, @@ -32,7 +32,7 @@ public record MyGroupCapsuleResponse( CapsuleType capsuleType ) { - public MyGroupCapsuleResponse { + public CapsuleBasicInfoResponse { if (dueDate != null) { dueDate = dueDate.withZoneSameInstant(ResponseMappingConstant.ZONE_ID); } @@ -41,4 +41,4 @@ public record MyGroupCapsuleResponse( createdAt = createdAt.withZoneSameInstant(ResponseMappingConstant.ZONE_ID); } } -} +} \ No newline at end of file From 0d0e0dfb405ca6724c6dea6569715e46951182b0 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sat, 8 Jun 2024 17:27:32 +0900 Subject: [PATCH 2/6] =?UTF-8?q?fix=20:=20secret=20=EC=BA=A1=EC=8A=90=20?= =?UTF-8?q?=EA=B3=B5=ED=86=B5=20=EC=9D=91=EB=8B=B5=20DTO=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/SecretCapsuleApiController.java | 4 +- .../data/dto/MySecreteCapsuleDto.java | 32 -------------- .../MySecretCapsuleSliceResponse.java | 9 ++-- .../response/MySecreteCapsuleResponse.java | 43 ------------------- .../SecretCapsuleQueryRepository.java | 10 ++--- .../service/SecretCapsuleService.java | 4 +- 6 files changed, 14 insertions(+), 88 deletions(-) delete mode 100644 backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/dto/MySecreteCapsuleDto.java delete mode 100644 backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/response/MySecreteCapsuleResponse.java diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/api/SecretCapsuleApiController.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/api/SecretCapsuleApiController.java index 15458cde6..5ea1bddb2 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/api/SecretCapsuleApiController.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/api/SecretCapsuleApiController.java @@ -15,6 +15,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.entity.CapsuleType; import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto; import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleSummaryDto; @@ -22,7 +23,6 @@ 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.secret_capsule.data.dto.MySecreteCapsuleDto; import site.timecapsulearchive.core.domain.capsule.secret_capsule.data.reqeust.SecretCapsuleUpdateRequest; import site.timecapsulearchive.core.domain.capsule.secret_capsule.data.response.MySecretCapsuleSliceResponse; import site.timecapsulearchive.core.domain.capsule.secret_capsule.service.SecretCapsuleService; @@ -64,7 +64,7 @@ public ResponseEntity> getMySecretCapsules @RequestParam(defaultValue = "20", value = "size") final int size, @RequestParam(defaultValue = "0", value = "created_at") final ZonedDateTime createdAt ) { - final Slice dtos = secretCapsuleService.findSecretCapsuleSliceByMemberId( + final Slice dtos = secretCapsuleService.findSecretCapsuleSliceByMemberId( memberId, size, createdAt); return ResponseEntity.ok( diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/dto/MySecreteCapsuleDto.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/dto/MySecreteCapsuleDto.java deleted file mode 100644 index 19d661802..000000000 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/dto/MySecreteCapsuleDto.java +++ /dev/null @@ -1,32 +0,0 @@ -package site.timecapsulearchive.core.domain.capsule.secret_capsule.data.dto; - -import java.time.ZonedDateTime; -import java.util.function.Function; -import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType; -import site.timecapsulearchive.core.domain.capsule.secret_capsule.data.response.MySecreteCapsuleResponse; - -public record MySecreteCapsuleDto( - Long capsuleId, - String skinUrl, - ZonedDateTime dueDate, - ZonedDateTime createdAt, - String title, - Boolean isOpened, - CapsuleType type -) { - - public MySecreteCapsuleResponse toResponse( - final Function preSignUrlFunction - ) { - return MySecreteCapsuleResponse.builder() - .capsuleId(capsuleId) - .SkinUrl(preSignUrlFunction.apply(skinUrl)) - .dueDate(dueDate) - .createdAt(createdAt) - .title(title) - .isOpened(isOpened) - .type(type) - .build(); - } - -} diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/response/MySecretCapsuleSliceResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/response/MySecretCapsuleSliceResponse.java index f2ecc413d..15e626d9d 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/response/MySecretCapsuleSliceResponse.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/response/MySecretCapsuleSliceResponse.java @@ -4,23 +4,24 @@ import java.util.List; import java.util.function.Function; import org.springframework.data.domain.Slice; -import site.timecapsulearchive.core.domain.capsule.secret_capsule.data.dto.MySecreteCapsuleDto; +import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto; +import site.timecapsulearchive.core.domain.capsule.data.response.CapsuleBasicInfoResponse; @Schema(description = "내가 생성한 비밀 캡슐 목록 응답") public record MySecretCapsuleSliceResponse( @Schema(description = "내 비밀 캡슐 리스트") - List capsules, + List capsules, @Schema(description = "다음 페이지 유무") Boolean hasNext ) { public static MySecretCapsuleSliceResponse createOf( - final Slice dtos, + final Slice dtos, final Function preSignUrlFunction ) { - final List capsules = dtos.getContent(). + final List capsules = dtos.getContent(). stream() .map(dto -> dto.toResponse(preSignUrlFunction)) .toList(); diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/response/MySecreteCapsuleResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/response/MySecreteCapsuleResponse.java deleted file mode 100644 index 15314fed7..000000000 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/data/response/MySecreteCapsuleResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -package site.timecapsulearchive.core.domain.capsule.secret_capsule.data.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.time.ZonedDateTime; -import lombok.Builder; -import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType; -import site.timecapsulearchive.core.global.common.response.ResponseMappingConstant; - -@Builder -@Schema(description = "내 비밀 캡슐 응답") -public record MySecreteCapsuleResponse( - @Schema(description = "비밀 캡슐 아이디") - Long capsuleId, - - @Schema(description = "캡슐 스킨 url") - String SkinUrl, - - @Schema(description = "내 비밀 캡슐 만료일") - ZonedDateTime dueDate, - - @Schema(description = "내 비밀 캡슐 생성일") - ZonedDateTime createdAt, - - @Schema(description = "내 비밀 캡슐 제목") - String title, - - @Schema(description = "내 비밀 캡슐 오픈 여부") - Boolean isOpened, - - @Schema(description = "내 비밀 캡슐 타입") - CapsuleType type -) { - - public MySecreteCapsuleResponse { - if (dueDate != null) { - dueDate = dueDate.withZoneSameInstant(ResponseMappingConstant.ZONE_ID); - } - - if (createdAt != null) { - createdAt = createdAt.withZoneSameInstant(ResponseMappingConstant.ZONE_ID); - } - } -} diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/repository/SecretCapsuleQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/repository/SecretCapsuleQueryRepository.java index 99490a193..4362078d3 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/repository/SecretCapsuleQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/repository/SecretCapsuleQueryRepository.java @@ -18,10 +18,10 @@ 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.secret_capsule.data.dto.MySecreteCapsuleDto; @Repository @RequiredArgsConstructor @@ -104,12 +104,12 @@ private StringExpression groupConcatDistinct(final StringExpression expression) return Expressions.stringTemplate("GROUP_CONCAT(DISTINCT {0})", expression); } - public Slice findSecretCapsuleSliceByMemberIdAndCreatedAt( + public Slice findSecretCapsuleSliceByMemberIdAndCreatedAt( final Long memberId, final int size, final ZonedDateTime createdAt ) { - final List mySecretCapsules = findMySecretCapsuleDtosByMemberIdAndCreatedAt( + final List mySecretCapsules = findMySecretCapsuleDtosByMemberIdAndCreatedAt( memberId, size, createdAt ); @@ -121,7 +121,7 @@ public Slice findSecretCapsuleSliceByMemberIdAndCreatedAt( return new SliceImpl<>(mySecretCapsules, Pageable.ofSize(size), hasNext); } - private List findMySecretCapsuleDtosByMemberIdAndCreatedAt( + private List findMySecretCapsuleDtosByMemberIdAndCreatedAt( final Long memberId, final int size, final ZonedDateTime createdAt @@ -129,7 +129,7 @@ private List findMySecretCapsuleDtosByMemberIdAndCreatedAt( return jpaQueryFactory .select( Projections.constructor( - MySecreteCapsuleDto.class, + CapsuleBasicInfoDto.class, capsule.id, capsuleSkin.imageUrl, capsule.dueDate, diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/service/SecretCapsuleService.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/service/SecretCapsuleService.java index 87182171f..62e5acd51 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/service/SecretCapsuleService.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/service/SecretCapsuleService.java @@ -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.secret_capsule.data.dto.MySecreteCapsuleDto; import site.timecapsulearchive.core.domain.capsule.secret_capsule.repository.SecretCapsuleQueryRepository; @Service @@ -27,7 +27,7 @@ public class SecretCapsuleService { * @param createdAt 마지막 캡슐 생성 날짜 * @return 내 페이지에서 비밀 캡슐을 조회한다. */ - public Slice findSecretCapsuleSliceByMemberId( + public Slice findSecretCapsuleSliceByMemberId( final Long memberId, final int size, final ZonedDateTime createdAt From b9adfd64befaa9619d7506d445383f2af59b4961 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sat, 8 Jun 2024 17:30:06 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix=20:=20public=20=EC=BA=A1=EC=8A=90=20?= =?UTF-8?q?=EA=B3=B5=ED=86=B5=20=EC=9D=91=EB=8B=B5=20DTO=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/PublicCapsuleApiController.java | 4 +- .../data/dto/MyPublicCapsuleDto.java | 30 ------------- .../dto/MyPublicCapsuleSliceResponse.java | 9 ++-- .../response/MyPublicCapsuleResponse.java | 44 ------------------- .../PublicCapsuleQueryRepository.java | 8 ++-- .../service/PublicCapsuleService.java | 4 +- .../PublicCapsuleQueryRepositoryTest.java | 4 +- 7 files changed, 15 insertions(+), 88 deletions(-) delete mode 100644 backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/dto/MyPublicCapsuleDto.java delete mode 100644 backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/response/MyPublicCapsuleResponse.java diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/api/PublicCapsuleApiController.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/api/PublicCapsuleApiController.java index 7b3e7665e..97cd4d050 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/api/PublicCapsuleApiController.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/api/PublicCapsuleApiController.java @@ -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.entity.CapsuleType; import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto; import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleSummaryDto; @@ -21,7 +22,6 @@ 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; @@ -137,7 +137,7 @@ public ResponseEntity> getMyPublicCapsules @RequestParam(defaultValue = "20", value = "size") final int size, @RequestParam(value = "created_at") final ZonedDateTime createdAt ) { - final Slice publicCapsules = publicCapsuleService.findMyPublicCapsuleSlice( + final Slice publicCapsules = publicCapsuleService.findMyPublicCapsuleSlice( memberId, size, createdAt); return ResponseEntity.ok( diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/dto/MyPublicCapsuleDto.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/dto/MyPublicCapsuleDto.java deleted file mode 100644 index 8fe22bbc9..000000000 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/dto/MyPublicCapsuleDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package site.timecapsulearchive.core.domain.capsule.public_capsule.data.dto; - -import java.time.ZonedDateTime; -import java.util.function.Function; -import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType; -import site.timecapsulearchive.core.domain.capsule.public_capsule.data.response.MyPublicCapsuleResponse; - -public record MyPublicCapsuleDto( - Long capsuleId, - String skinUrl, - ZonedDateTime dueDate, - ZonedDateTime createdAt, - String title, - Boolean isOpened, - CapsuleType capsuleType -) { - - public MyPublicCapsuleResponse toResponse( - final Function singlePreSignUrlFunction) { - return MyPublicCapsuleResponse.builder() - .capsuleId(capsuleId) - .skinUrl(singlePreSignUrlFunction.apply(skinUrl)) - .dueDate(dueDate) - .createdAt(createdAt) - .title(title) - .isOpened(isOpened) - .capsuleType(capsuleType) - .build(); - } -} diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/dto/MyPublicCapsuleSliceResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/dto/MyPublicCapsuleSliceResponse.java index a74bd4939..a05510495 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/dto/MyPublicCapsuleSliceResponse.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/dto/MyPublicCapsuleSliceResponse.java @@ -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 publicCapsules, + List publicCapsules, @Schema(description = "다음 페이지 유무") Boolean hasNext ) { public static MyPublicCapsuleSliceResponse createOf( - final List publicCapsules, + final List publicCapsules, final boolean hasNext, final Function singlePreSignUrlFunction ) { - List publicCapsuleResponses = publicCapsules.stream() + List publicCapsuleResponses = publicCapsules.stream() .map(capsule -> capsule.toResponse(singlePreSignUrlFunction)) .toList(); diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/response/MyPublicCapsuleResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/response/MyPublicCapsuleResponse.java deleted file mode 100644 index 3dea37611..000000000 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/data/response/MyPublicCapsuleResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -package site.timecapsulearchive.core.domain.capsule.public_capsule.data.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.time.ZonedDateTime; -import lombok.Builder; -import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType; -import site.timecapsulearchive.core.global.common.response.ResponseMappingConstant; - -@Builder -@Schema(description = "사용자가 만든 공개 캡슐") -public record MyPublicCapsuleResponse( - - @Schema(description = "캡슐 아이디") - Long capsuleId, - - @Schema(description = "스킨 url") - String skinUrl, - - @Schema(description = "개봉일") - ZonedDateTime dueDate, - - @Schema(description = "생성일") - ZonedDateTime createdAt, - - @Schema(description = "제목") - String title, - - @Schema(description = "캡슐 개봉 여부") - Boolean isOpened, - - @Schema(description = "캡슐 타입") - CapsuleType capsuleType -) { - - public MyPublicCapsuleResponse { - if (dueDate != null) { - dueDate = dueDate.withZoneSameInstant(ResponseMappingConstant.ZONE_ID); - } - - if (createdAt != null) { - createdAt = createdAt.withZoneSameInstant(ResponseMappingConstant.ZONE_ID); - } - } -} diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepository.java index 980a5caac..8e1a4d9fa 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepository.java @@ -19,10 +19,10 @@ 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; @Repository @@ -171,15 +171,15 @@ private boolean canMoreRead(final int size, final int capsuleSize) { return capsuleSize > size; } - public Slice findMyPublicCapsuleSlice( + public Slice findMyPublicCapsuleSlice( final Long memberId, final int size, final ZonedDateTime createdAt ) { - final List publicCapsules = jpaQueryFactory + final List publicCapsules = jpaQueryFactory .select( Projections.constructor( - MyPublicCapsuleDto.class, + CapsuleBasicInfoDto.class, capsule.id, capsuleSkin.imageUrl, capsule.dueDate, diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/service/PublicCapsuleService.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/service/PublicCapsuleService.java index e58b91da6..75293a823 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/service/PublicCapsuleService.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/service/PublicCapsuleService.java @@ -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; @@ -70,7 +70,7 @@ public Slice findPublicCapsulesMadeByFriend( * @param createdAt 조회를 시작할 캡슐의 생성 시간, 첫 조회라면 현재 시간, 이후 조회라면 맨 마지막 데이터의 시간 * @return 사용자가 생성한 공개 캡슐 목록 */ - public Slice findMyPublicCapsuleSlice( + public Slice findMyPublicCapsuleSlice( final Long memberId, final int size, final ZonedDateTime createdAt diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepositoryTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepositoryTest.java index 3181f65e8..bdab3a023 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepositoryTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepositoryTest.java @@ -19,11 +19,11 @@ import site.timecapsulearchive.core.common.fixture.domain.CapsuleSkinFixture; import site.timecapsulearchive.core.common.fixture.domain.MemberFixture; import site.timecapsulearchive.core.common.fixture.domain.MemberFriendFixture; +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.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.capsuleskin.entity.CapsuleSkin; import site.timecapsulearchive.core.domain.friend.entity.MemberFriend; @@ -193,7 +193,7 @@ void setup(@Autowired EntityManager entityManager) { ZonedDateTime now = ZonedDateTime.now().plusDays(1); //when - Slice publicCapsules = publicCapsuleQueryRepository.findMyPublicCapsuleSlice( + Slice publicCapsules = publicCapsuleQueryRepository.findMyPublicCapsuleSlice( memberId, size, now); //then From 773deebb4a59bac0d27e8b3479b51c2b816bf21a Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sat, 8 Jun 2024 17:31:16 +0900 Subject: [PATCH 4/6] =?UTF-8?q?fix=20:=20=EC=B9=9C=EA=B5=AC=20=EC=BA=A1?= =?UTF-8?q?=EC=8A=90=20=EC=8A=AC=EB=9D=BC=EC=9D=B4=EC=8A=A4=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/PublicCapsuleQueryRepository.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepository.java index 8e1a4d9fa..b9aa3f28b 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/public_capsule/repository/PublicCapsuleQueryRepository.java @@ -24,6 +24,7 @@ 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.PublicCapsuleDetailDto; +import site.timecapsulearchive.core.global.util.SliceUtil; @Repository @RequiredArgsConstructor @@ -158,13 +159,7 @@ public Slice 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) { @@ -199,11 +194,6 @@ public Slice 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); } } From a9d2ae21392ceaa465bb314c5949266df474db0b Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sat, 8 Jun 2024 17:32:12 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix=20:=20=EB=B9=84=EB=B0=80=20=EC=BA=A1?= =?UTF-8?q?=EC=8A=90=20=EC=8A=AC=EB=9D=BC=EC=9D=B4=EC=8A=A4=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SecretCapsuleQueryRepository.java | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/repository/SecretCapsuleQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/repository/SecretCapsuleQueryRepository.java index 4362078d3..fff856330 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/repository/SecretCapsuleQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/secret_capsule/repository/SecretCapsuleQueryRepository.java @@ -14,14 +14,13 @@ 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.global.util.SliceUtil; @Repository @RequiredArgsConstructor @@ -109,24 +108,7 @@ public Slice findSecretCapsuleSliceByMemberIdAndCreatedAt( final int size, final ZonedDateTime createdAt ) { - final List mySecretCapsules = findMySecretCapsuleDtosByMemberIdAndCreatedAt( - memberId, size, createdAt - ); - - final boolean hasNext = canMoreRead(size, mySecretCapsules.size()); - if (hasNext) { - mySecretCapsules.remove(size); - } - - return new SliceImpl<>(mySecretCapsules, Pageable.ofSize(size), hasNext); - } - - private List findMySecretCapsuleDtosByMemberIdAndCreatedAt( - final Long memberId, - final int size, - final ZonedDateTime createdAt - ) { - return jpaQueryFactory + final List mySecretCapsules = jpaQueryFactory .select( Projections.constructor( CapsuleBasicInfoDto.class, @@ -149,9 +131,7 @@ private List findMySecretCapsuleDtosByMemberIdAndCreatedAt( .orderBy(capsule.id.desc()) .limit(size + 1) .fetch(); - } - private boolean canMoreRead(final int size, final int capsuleSize) { - return capsuleSize > size; + return SliceUtil.makeSlice(size, mySecretCapsules); } } \ No newline at end of file From 333c4cd8b8c5cf5f917e7e32b1f0a6440ed17b99 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sat, 8 Jun 2024 17:33:20 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix=20:=20=EA=B7=B8=EB=A3=B9=20=EC=BA=A1?= =?UTF-8?q?=EC=8A=90=20=EC=8A=AC=EB=9D=BC=EC=9D=B4=EC=8A=A4=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/GroupCapsuleQueryRepository.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/repository/GroupCapsuleQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/repository/GroupCapsuleQueryRepository.java index 3efe95754..48d2edcdc 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/repository/GroupCapsuleQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/group_capsule/repository/GroupCapsuleQueryRepository.java @@ -159,12 +159,7 @@ public Slice 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) {