Skip to content

Commit

Permalink
feat: 기록 상세 API 응답 수정 (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
ywonchae1 committed Jul 31, 2024
1 parent 9d10d89 commit afac4e3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private ImagePresignedUrlVo getImageUploadResponseDto(

@Override
public void changeImageStatusAndAddMemoryIdToImages(Memory memory, List<Long> imageIds) {
if (imageIds.isEmpty()) return;
if (imageIds == null || imageIds.isEmpty()) return;
List<Image> images = imagePersistencePort.findImageByIds(imageIds);
for (Image image : images) {
image.addMemoryToImage(memory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ public List<Image> findImageByIds(List<Long> ids) {
List<ImageEntity> imageEntities =
queryFactory
.selectFrom(imageEntity)
.join(imageEntity.memory, memoryEntity)
.fetchJoin()
.where(imageEntity.id.in(ids))
.fetch();

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,7 +25,7 @@ public class MemoryResponse {
private Pool pool;
private MemoryDetailResponse memoryDetail;
private List<StrokeResponse> strokes;
private List<ImageResponse> images;
private List<ImageSimpleResponse> images;
private LocalDate recordAt;
private LocalTime startTime;
private LocalTime endTime;
Expand Down Expand Up @@ -86,8 +87,8 @@ private static LocalTime getDuration(LocalTime startTime, LocalTime endTime) {
0);
}

private static List<ImageResponse> getImageSource(List<Image> images) {
return images.stream().map(ImageResponse::of).toList();
private static List<ImageSimpleResponse> getImageSource(List<Image> images) {
return images.stream().map(ImageSimpleResponse::of).toList();
}

private static List<StrokeResponse> getResultStrokes(List<Stroke> strokes, Short lane) {
Expand Down

0 comments on commit afac4e3

Please sign in to comment.