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

Feature/#664 행사 dto의 image url을 s3의 데이터로 대체 #676

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4e2d027
Merge branch 'backend-main' of https://github.com/woowacourse-teams/2…
Sep 25, 2023
61ad1bf
Merge branches 'backend-main' and 'backend-main' of https://github.co…
Sep 27, 2023
6920902
feat: 행사 단건 조회 시 섬네일 이미지와 나머지 이미지들을 반환하도록 DTO 수정
Sep 27, 2023
67616b9
Merge branch 'Feature/#650-행사_상태_리팩터링' of https://github.com/woowacou…
Sep 27, 2023
3980a47
test: 이미지 Fixture 추가
Sep 28, 2023
7a8452e
feat: 행사 섬네일 이미지만 가져오는 쿼리문 추가
Sep 28, 2023
488018e
test: 행사 섬네일 이미지만 가져오는 쿼리문 테스트 작성
Sep 28, 2023
9a9e042
feat: 불필요한 DTO 제거
Sep 28, 2023
e1f465d
feat: 행사 다건 조회 시 S3에 저장된 이미지를 조회하도록 수정 및 행사 도메인의 imageUrl 컬럼 제거
Sep 28, 2023
7f8f6b1
feat: 행사 생성/수정 시 imageUrl을 받지 않도록 수정
Sep 28, 2023
b6f4208
feat: event table의 image_url 컬럼 제거
Sep 29, 2023
2dc704c
Merge branch 'backend-main' into Feature/#664-행사_DTO의_imageUrl을_S3의_데…
amaran-th Oct 3, 2023
568b8e4
fix: data.sql에서 event의 image 컬럼 값 제거
Oct 4, 2023
dbfcf72
Merge branch 'Feature/#664-행사_DTO의_imageUrl을_S3의_데이터로_대체' of https://…
Oct 4, 2023
5e2152c
fix: schema.sql ddl 끝에 세미콜론 추가
Oct 4, 2023
6294a3b
Merge branch 'backend-main' into Feature/#664-행사_DTO의_imageUrl을_S3의_데…
amaran-th Oct 5, 2023
88360e9
fix: DetailResponse에서 imageUrl 제거
Oct 6, 2023
9696715
Merge branch 'backend-main' into Feature/#664-행사_DTO의_imageUrl을_S3의_데…
amaran-th Oct 6, 2023
53749ce
refactor: 행사 상세 정보 조회 dto에서 필요없는 요소 제거
Oct 7, 2023
7cca4ea
refactor: 행사 상세 정보 조회 dto에서 필요없는 요소 제거
Oct 7, 2023
965b078
refactor: 행사 상세 조회/목록 조회 DTO의 imageUrl을 thumbnailUrl로 이름 변경
Oct 9, 2023
1978ad0
Merge branch 'backend-main' of https://github.com/woowacourse-teams/2…
Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -66,8 +67,23 @@ public EventDetailResponse findEvent(final Long id, final LocalDate today) {
.sorted(comparing(Image::getOrder))
.map(Image::getName)
.collect(toList());
final String thumbnailImageUrl = extractThumbnailImage(imageUrls);
final List<String> informationImageUrls = extractInformationImages(imageUrls);
return EventDetailResponse.from(event, today, thumbnailImageUrl, informationImageUrls);
}

return EventDetailResponse.from(event, today, imageUrls);
private String extractThumbnailImage(final List<String> imageUrls) {
if (imageUrls.isEmpty()) {
return null;
}
return imageUrls.get(0);
}

private List<String> extractInformationImages(final List<String> imageUrls) {
if (imageUrls.size() <= 1) {
return Collections.emptyList();
}
return imageUrls.subList(1, imageUrls.size());
}

@Transactional(readOnly = true)
Expand Down Expand Up @@ -193,8 +209,9 @@ public EventDetailResponse addEvent(final EventDetailRequest request,
.collect(toList());

eventPublisher.publish(event);

return EventDetailResponse.from(event, today, imageUrls);
final String thumbnailImageUrl = extractThumbnailImage(imageUrls);
final List<String> informationImageUrls = extractInformationImages(imageUrls);
return EventDetailResponse.from(event, today, thumbnailImageUrl, informationImageUrls);
}

public EventDetailResponse updateEvent(final Long eventId, final EventDetailRequest request,
Expand Down Expand Up @@ -223,8 +240,9 @@ public EventDetailResponse updateEvent(final Long eventId, final EventDetailRequ
.sorted(comparing(Image::getOrder))
.map(Image::getName)
.collect(toList());

return EventDetailResponse.from(updatedEvent, today, imageUrls);
final String thumbnailImageUrl = extractThumbnailImage(imageUrls);
final List<String> informationImageUrls = extractInformationImages(imageUrls);
return EventDetailResponse.from(updatedEvent, today, thumbnailImageUrl, informationImageUrls);
}

public void deleteEvent(final Long eventId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class EventDetailResponse {
public static EventDetailResponse from(
final Event event,
final LocalDate today,
final String imageUrl,
Copy link
Collaborator

@hyeonjerry hyeonjerry Oct 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개인적으로 imageUrl이라고 하는 것 보다 thumbnailUrl이라고 하는게 더 명확하게 의미를 전달할 수 있을 것 같아요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의견 반영해서 EventDetailResponse, EventResponse의 imageUrl을 thumbnailUrl로 이름 변경했습니다!

final List<String> imageUrls
) {
final List<String> tagNames = event.getTags().stream()
Expand All @@ -63,7 +64,7 @@ public static EventDetailResponse from(
event.getEventPeriod().calculateEventStatus(today).name(),
event.getEventPeriod().calculateEventApplyStatus(today).name(),
tagNames,
event.getImageUrl(),
imageUrl,
event.getEventPeriod().calculateRemainingDays(today),
event.getEventPeriod().calculateApplyRemainingDays(today),
event.getType().toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ void success() {
new Image("imageUrl2", ImageType.EVENT, event.getId(), 0, LocalDateTime.now())
);

final List<String> imageUrls = List.of("imageUrl2", "imageUrl1");
final String imageUrl = "imageUrl2";
final List<String> imageUrls = List.of("imageUrl1");

final EventDetailResponse expected = EventDetailResponse.from(event, 날짜_8월_10일(), imageUrls);
final EventDetailResponse expected = EventDetailResponse.from(event, 날짜_8월_10일(), imageUrl,
imageUrls);

//when
final EventDetailResponse actual = eventService.findEvent(event.getId(), 날짜_8월_10일());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void createEventDetailResponseTest() {
//given
final Event 구름톤 = EventFixture.구름톤();
final LocalDate 날짜 = LocalDate.of(2023, 7, 1);
final String imageUrl = "thumbnail";
final List<String> imageUrls = List.of("imageUrl1", "imageUrl2");

final EventDetailResponse expected = new EventDetailResponse(
Expand All @@ -34,7 +35,7 @@ void createEventDetailResponseTest() {
EventStatus.UPCOMING.name(),
EventStatus.UPCOMING.name(),
Collections.emptyList(),
구름톤.getImageUrl(),
imageUrl,
2, 2,
구름톤.getType().toString(),
imageUrls,
Expand All @@ -43,7 +44,7 @@ void createEventDetailResponseTest() {
);

//when
final EventDetailResponse actual = EventDetailResponse.from(구름톤, 날짜, imageUrls);
final EventDetailResponse actual = EventDetailResponse.from(구름톤, 날짜, imageUrl, imageUrls);

//then
assertThat(actual)
Expand Down