diff --git a/backend/emm-sale/src/documentTest/java/com/emmsale/EventApiTest.java b/backend/emm-sale/src/documentTest/java/com/emmsale/EventApiTest.java index aeab6a1c3..c7dc6e9f2 100644 --- a/backend/emm-sale/src/documentTest/java/com/emmsale/EventApiTest.java +++ b/backend/emm-sale/src/documentTest/java/com/emmsale/EventApiTest.java @@ -24,6 +24,7 @@ import com.emmsale.member.domain.Member; import com.emmsale.tag.TagFixture; import com.emmsale.tag.application.dto.TagRequest; +import com.emmsale.tag.application.dto.TagResponse; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.util.HashMap; @@ -76,6 +77,8 @@ class EventApiTest extends MockMvcTestHelper { .description("신청 종료일자(nullable)"), fieldWithPath("location").type(JsonFieldType.STRING).description("장소"), fieldWithPath("tags[]").type(JsonFieldType.ARRAY).description("태그들"), + fieldWithPath("tags[].id").type(JsonFieldType.NUMBER).description("행사 태그 ID"), + fieldWithPath("tags[].name").type(JsonFieldType.STRING).description("행사 태그 이름"), fieldWithPath("thumbnailUrl").type(JsonFieldType.STRING) .description("섬네일 이미지 Url(포스터)"), fieldWithPath("type").type(JsonFieldType.STRING) @@ -100,7 +103,9 @@ class EventApiTest extends MockMvcTestHelper { fieldWithPath("[].applyEndDate").type(JsonFieldType.STRING) .description("행사 신청 종료 일자(nullable)"), fieldWithPath("[].location").type(JsonFieldType.STRING).description("행사 장소"), - fieldWithPath("[].tags[]").type(JsonFieldType.ARRAY).description("행사 태그들"), + fieldWithPath("[].tags[]").type(JsonFieldType.ARRAY).description("태그들"), + fieldWithPath("[].tags[].id").type(JsonFieldType.NUMBER).description("행사 태그 ID"), + fieldWithPath("[].tags[].name").type(JsonFieldType.STRING).description("행사 태그 이름"), fieldWithPath("[].thumbnailUrl").type(JsonFieldType.STRING) .description("행사 섬네일 이미지 Url(포스터)"), fieldWithPath("[].type").type(JsonFieldType.STRING) @@ -116,11 +121,14 @@ class EventApiTest extends MockMvcTestHelper { void findEvent() throws Exception { //given final Long eventId = 1L; + final List tagResponses = List.of( + new TagResponse(1L, "코틀린"), new TagResponse(2L, "백엔드"), new TagResponse(3L, "안드로이드") + ); final EventResponse eventResponse = new EventResponse(eventId, "인프콘 2023", "http://infcon.com", LocalDateTime.of(2023, 8, 15, 12, 0), LocalDateTime.of(2023, 8, 15, 12, 0), LocalDateTime.of(2023, 8, 1, 12, 0), LocalDateTime.of(2023, 8, 15, 12, 0), "코엑스", - List.of("코틀린", "백엔드", "안드로이드"), + tagResponses, "https://www.image.com", EventType.COMPETITION.toString(), List.of("imageUrl1", "imageUrl2"), "인프런", "유료", "온라인"); @@ -163,7 +171,7 @@ void findEvents() throws Exception { LocalDateTime.parse("2023-08-03T12:00:00"), LocalDateTime.parse("2023-06-23T10:00:00"), LocalDateTime.parse("2023-07-03T12:00:00"), - "코엑스", List.of("백엔드", "프론트엔드"), + "코엑스", List.of(new TagResponse(1L, "백엔드"), new TagResponse(2L, "프론트엔드")), "imageUrl0", EventType.CONFERENCE.name(), List.of("imageUrl1", "imageUrl2"), "인프런", PaymentType.PAID.getValue(), @@ -175,7 +183,7 @@ void findEvents() throws Exception { LocalDateTime.parse("2023-07-30T12:00:00"), LocalDateTime.parse("2023-07-01T00:00:00"), LocalDateTime.parse("2023-07-21T23:59:59"), - "코엑스", List.of("AI"), + "코엑스", List.of(new TagResponse(5L, "AI")), "imageUrl0", EventType.CONFERENCE.name(), List.of("imageUrl1", "imageUrl2"), "인프런", PaymentType.PAID.getValue(), @@ -234,7 +242,7 @@ void updateEventTest() throws Exception { request.getInformationUrl(), request.getStartDateTime(), request.getEndDateTime(), request.getApplyStartDateTime(), request.getApplyEndDateTime(), request.getLocation(), - tags.stream().map(TagRequest::getName).collect(Collectors.toList()), + List.of(new TagResponse(1L, "백엔드"), new TagResponse(2L, "안드로이드")), "image1.jpg", request.getType().toString(), List.of("imageUrl1", "imageUrl2"), "행사기관", "유료", "온라인"); @@ -339,7 +347,7 @@ void addEventTest() throws Exception { request.getInformationUrl(), request.getStartDateTime(), request.getEndDateTime(), request.getApplyStartDateTime(), request.getApplyEndDateTime(), request.getLocation(), - tags.stream().map(TagRequest::getName).collect(Collectors.toList()), + List.of(new TagResponse(1L, "백엔드"), new TagResponse(2L, "안드로이드")), "image1.jpg", request.getType().toString(), List.of("imageUrl1", "imageUrl2"), "행사기관", "무료", "오프라인"); diff --git a/backend/emm-sale/src/main/java/com/emmsale/event/application/dto/EventResponse.java b/backend/emm-sale/src/main/java/com/emmsale/event/application/dto/EventResponse.java index de14d8ab3..e4cfed34b 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/event/application/dto/EventResponse.java +++ b/backend/emm-sale/src/main/java/com/emmsale/event/application/dto/EventResponse.java @@ -6,7 +6,7 @@ import com.emmsale.event.domain.EventStatus; import com.emmsale.event.domain.EventTag; import com.emmsale.image.domain.AllImagesOfContent; -import com.emmsale.tag.domain.Tag; +import com.emmsale.tag.application.dto.TagResponse; import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; import java.util.ArrayList; @@ -34,7 +34,7 @@ public class EventResponse { @JsonFormat(pattern = DATE_TIME_FORMAT) private final LocalDateTime applyEndDate; private final String location; - private final List tags; + private final List tags; private final String thumbnailUrl; private final String type; private final List imageUrls; @@ -46,9 +46,9 @@ public static EventResponse from( final Event event, final AllImagesOfContent images ) { - final List tagNames = event.getTags().stream() + final List tagResponses = event.getTags().stream() .map(EventTag::getTag) - .map(Tag::getName) + .map(TagResponse::from) .collect(toUnmodifiableList()); return new EventResponse( @@ -60,7 +60,7 @@ public static EventResponse from( event.getEventPeriod().getApplyStartDate(), event.getEventPeriod().getApplyEndDate(), event.getLocation(), - tagNames, + tagResponses, images.extractThumbnailImage(), event.getType().toString(), images.extractInformationImages(),