From afac4e392410a8d360362e12e15766cf200337a4 Mon Sep 17 00:00:00 2001 From: ywonchae1 Date: Wed, 31 Jul 2024 16:58:47 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B8=B0=EB=A1=9D=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=20API=20=EC=9D=91=EB=8B=B5=20=EC=88=98=EC=A0=95=20(#94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image/service/ImageUploadService.java | 2 +- .../image/repository/ImageRepository.java | 2 -- .../image/dto/response/ImageSimpleResponse.java | 17 +++++++++++++++++ .../dto/response/MemoryDetailResponse.java | 3 +-- .../memory/dto/response/MemoryResponse.java | 7 ++++--- 5 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 module-presentation/src/main/java/com/depromeet/image/dto/response/ImageSimpleResponse.java diff --git a/module-domain/src/main/java/com/depromeet/image/service/ImageUploadService.java b/module-domain/src/main/java/com/depromeet/image/service/ImageUploadService.java index 266df3c3..e4ac1fc7 100644 --- a/module-domain/src/main/java/com/depromeet/image/service/ImageUploadService.java +++ b/module-domain/src/main/java/com/depromeet/image/service/ImageUploadService.java @@ -79,7 +79,7 @@ private ImagePresignedUrlVo getImageUploadResponseDto( @Override public void changeImageStatusAndAddMemoryIdToImages(Memory memory, List imageIds) { - if (imageIds.isEmpty()) return; + if (imageIds == null || imageIds.isEmpty()) return; List images = imagePersistencePort.findImageByIds(imageIds); for (Image image : images) { image.addMemoryToImage(memory); diff --git a/module-infrastructure/persistence-database/src/main/java/com/depromeet/image/repository/ImageRepository.java b/module-infrastructure/persistence-database/src/main/java/com/depromeet/image/repository/ImageRepository.java index a2c562ee..3b561590 100644 --- a/module-infrastructure/persistence-database/src/main/java/com/depromeet/image/repository/ImageRepository.java +++ b/module-infrastructure/persistence-database/src/main/java/com/depromeet/image/repository/ImageRepository.java @@ -78,8 +78,6 @@ public List findImageByIds(List ids) { List imageEntities = queryFactory .selectFrom(imageEntity) - .join(imageEntity.memory, memoryEntity) - .fetchJoin() .where(imageEntity.id.in(ids)) .fetch(); diff --git a/module-presentation/src/main/java/com/depromeet/image/dto/response/ImageSimpleResponse.java b/module-presentation/src/main/java/com/depromeet/image/dto/response/ImageSimpleResponse.java new file mode 100644 index 00000000..e09542e1 --- /dev/null +++ b/module-presentation/src/main/java/com/depromeet/image/dto/response/ImageSimpleResponse.java @@ -0,0 +1,17 @@ +package com.depromeet.image.dto.response; + +import com.depromeet.image.domain.Image; +import lombok.Builder; + +public record ImageSimpleResponse(Long imageId, String imageName, String url) { + @Builder + public ImageSimpleResponse {} + + public static ImageSimpleResponse of(Image image) { + return ImageSimpleResponse.builder() + .imageId(image.getId()) + .imageName(image.getImageName()) + .url(image.getImageUrl()) + .build(); + } +} diff --git a/module-presentation/src/main/java/com/depromeet/memory/dto/response/MemoryDetailResponse.java b/module-presentation/src/main/java/com/depromeet/memory/dto/response/MemoryDetailResponse.java index 1775efdf..973620ff 100644 --- a/module-presentation/src/main/java/com/depromeet/memory/dto/response/MemoryDetailResponse.java +++ b/module-presentation/src/main/java/com/depromeet/memory/dto/response/MemoryDetailResponse.java @@ -7,13 +7,12 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public record MemoryDetailResponse( - Long memoryDetailId, String item, Short heartRate, LocalTime pace, Integer kcal) { + String item, Short heartRate, LocalTime pace, Integer kcal) { @Builder public MemoryDetailResponse {} public static MemoryDetailResponse of(MemoryDetail memoryDetail) { return MemoryDetailResponse.builder() - .memoryDetailId(memoryDetail.getId()) .item(memoryDetail.getItem()) .heartRate(memoryDetail.getHeartRate()) .pace(memoryDetail.getPace()) diff --git a/module-presentation/src/main/java/com/depromeet/memory/dto/response/MemoryResponse.java b/module-presentation/src/main/java/com/depromeet/memory/dto/response/MemoryResponse.java index b60f3ef0..d9a5d7df 100644 --- a/module-presentation/src/main/java/com/depromeet/memory/dto/response/MemoryResponse.java +++ b/module-presentation/src/main/java/com/depromeet/memory/dto/response/MemoryResponse.java @@ -2,6 +2,7 @@ import com.depromeet.image.domain.Image; import com.depromeet.image.dto.response.ImageResponse; +import com.depromeet.image.dto.response.ImageSimpleResponse; import com.depromeet.member.dto.response.MemberSimpleResponse; import com.depromeet.memory.domain.Memory; import com.depromeet.memory.domain.MemoryDetail; @@ -24,7 +25,7 @@ public class MemoryResponse { private Pool pool; private MemoryDetailResponse memoryDetail; private List strokes; - private List images; + private List images; private LocalDate recordAt; private LocalTime startTime; private LocalTime endTime; @@ -86,8 +87,8 @@ private static LocalTime getDuration(LocalTime startTime, LocalTime endTime) { 0); } - private static List getImageSource(List images) { - return images.stream().map(ImageResponse::of).toList(); + private static List getImageSource(List images) { + return images.stream().map(ImageSimpleResponse::of).toList(); } private static List getResultStrokes(List strokes, Short lane) {