-
Notifications
You must be signed in to change notification settings - Fork 1
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
[feat]: 공연 단건 정보 조회 API 추가 #33
Changes from 17 commits
0c07585
1ca4e5b
b9b2d95
f6f57c9
7dda6b5
2f14b7c
789c88d
12f1aff
e9ab71a
6638025
210a340
5eee542
07ed441
334fabc
eb5218a
caa42ae
babb762
6c88622
23b8021
300c112
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.hooon.show; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import dev.hooon.show.application.ShowService; | ||
import dev.hooon.show.dto.response.ShowDetailsInfoResponse; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class ShowDetailApiController { | ||
|
||
private final ShowService showService; | ||
|
||
@GetMapping("/api/shows/{show_id}") | ||
public ResponseEntity<ShowDetailsInfoResponse> getShowDetailInfo( | ||
@PathVariable("show_id") Long showId | ||
) { | ||
ShowDetailsInfoResponse showDetailsInfoResponse = showService.getShowDetailInfo(showId); | ||
return ResponseEntity.ok(showDetailsInfoResponse); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dev.hooon.show; | ||
|
||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.jdbc.Sql; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.ResultActions; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
|
||
import dev.hooon.common.support.ApiTestSupport; | ||
|
||
@DisplayName("[ShowDetailApiController API 테스트]") | ||
@Sql("/sql/show_dummy.sql") | ||
class ShowDetailApiControllerTest extends ApiTestSupport { | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@DisplayName("[공연 아이디를 통해 API 를 호출하면 해당 공연의 세부 정보를 조회할 수 있다]") | ||
@Test | ||
void getShowDetailInfoTest() throws Exception { | ||
// when | ||
ResultActions resultActions = mockMvc.perform( | ||
MockMvcRequestBuilders | ||
.get("/api/shows/1") | ||
); | ||
|
||
// then | ||
resultActions.andExpectAll( | ||
status().isOk(), | ||
|
||
jsonPath("$.showName").value("레미제라블"), | ||
jsonPath("$.showStartDate").value("2023-10-10"), | ||
jsonPath("$.showEndDate").value("2023-10-12"), | ||
jsonPath("$.showTime").value(150), | ||
jsonPath("$.showIntermissionTime").value(15), | ||
jsonPath("$.showAgeLimit").value("만 8세 이상"), | ||
|
||
jsonPath("$.placeDetailsInfo.showPlaceName").value("블루스퀘어 신한카드홀"), | ||
jsonPath("$.placeDetailsInfo.showPlaceContactInfo").value("1544-1591"), | ||
jsonPath("$.placeDetailsInfo.showPlaceAddress").value("서울특별시 용산구 이태원로 294 블루스퀘어(한남동)"), | ||
jsonPath("$.placeDetailsInfo.showPlaceUrl").value("http://www.bluesquare.kr/index.asp") | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,40 +17,42 @@ | |
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@Table(name = "show_table") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저희 @AllArgsConstructor 사용 안하기로 컨벤션 정했던거같아요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 테스트 시 데이터 insert를 위해서 필요해서 만들었습니다..!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 이거 생성자 추가로 변경하겠습니당 |
||
public class Show extends TimeBaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
@Column(name = "show_id") | ||
private Long id; | ||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
@Column(name = "show_id") | ||
private Long id; | ||
|
||
@Column(name = "show_name", nullable = false) | ||
private String name; | ||
@Column(name = "show_name", nullable = false) | ||
private String name; | ||
|
||
@Enumerated(STRING) | ||
@Column(name = "show_category", nullable = false) | ||
private ShowCategory category; | ||
@Enumerated(STRING) | ||
@Column(name = "show_category", nullable = false) | ||
private ShowCategory category; | ||
|
||
@Embedded | ||
private ShowPeriod showPeriod; | ||
@Embedded | ||
private ShowPeriod showPeriod; | ||
|
||
@Embedded | ||
private ShowTime showTime; | ||
@Embedded | ||
private ShowTime showTime; | ||
|
||
@Column(name = "show_age_limit", nullable = false) | ||
private String showAgeLimit; | ||
@Column(name = "show_age_limit", nullable = false) | ||
private String showAgeLimit; | ||
|
||
@Column(name = "show_total_seats") | ||
private int totalSeats; | ||
@Column(name = "show_total_seats") | ||
private int totalSeats; | ||
|
||
@ManyToOne(fetch = LAZY) | ||
@JoinColumn(name = "show_place_id", nullable = false, foreignKey = @ForeignKey(value = NO_CONSTRAINT)) | ||
private Place place; | ||
@ManyToOne(fetch = LAZY) | ||
@JoinColumn(name = "show_place_id", nullable = false, foreignKey = @ForeignKey(value = NO_CONSTRAINT)) | ||
private Place place; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dev.hooon.show.domain.repository; | ||
|
||
import dev.hooon.show.domain.entity.place.Place; | ||
|
||
public interface PlaceRepository { | ||
|
||
Place save(Place place); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dev.hooon.show.domain.repository; | ||
|
||
import java.util.Optional; | ||
|
||
import dev.hooon.show.domain.entity.Show; | ||
|
||
public interface ShowRepository { | ||
|
||
Optional<Show> findById(Long id); | ||
|
||
Show save(Show show); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,12 @@ | |
|
||
import java.util.List; | ||
|
||
import dev.hooon.show.domain.entity.Show; | ||
import dev.hooon.show.dto.query.SeatDateRoundDto; | ||
import dev.hooon.show.dto.response.AbleBookingDateRoundResponse; | ||
import dev.hooon.show.dto.response.AbleBookingDateRoundResponse.AvailableDate; | ||
import dev.hooon.show.dto.response.PlaceDetailsInfo; | ||
import dev.hooon.show.dto.response.ShowDetailsInfoResponse; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
@@ -21,4 +24,21 @@ public static AbleBookingDateRoundResponse toSeatDateRoundResponse(List<SeatDate | |
|
||
return new AbleBookingDateRoundResponse(availableDates); | ||
} | ||
|
||
public static ShowDetailsInfoResponse toShowDetailInfoResponse(Show show) { | ||
return new ShowDetailsInfoResponse( | ||
show.getName(), | ||
show.getShowPeriod().getStartDate(), | ||
show.getShowPeriod().getEndDate(), | ||
show.getShowTime().getTotalMinutes(), | ||
show.getShowTime().getIntermissionMinutes(), | ||
show.getShowAgeLimit(), | ||
new PlaceDetailsInfo( | ||
show.getPlace().getName(), | ||
show.getPlace().getContactInfo(), | ||
show.getPlace().getAddress(), | ||
show.getPlace().getPlaceUrl() | ||
Comment on lines
+31
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. . 에 . 찍으면서 호출하는 패턴 대신 별도의 getter 를 구현하는게 좋다고 생각을 했었는데... 이건 별도로 구현할 게터가 너무 많아보이네요... 그냥 이대로 써도 괜찮을 것 같아요 ㅎㅎ |
||
) | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dev.hooon.show.dto.response; | ||
|
||
public record PlaceDetailsInfo( | ||
String showPlaceName, | ||
String showPlaceContactInfo, | ||
String showPlaceAddress, | ||
String showPlaceUrl | ||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dev.hooon.show.dto.response; | ||
|
||
import java.time.LocalDate; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
|
||
public record ShowDetailsInfoResponse( | ||
String showName, | ||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
LocalDate showStartDate, | ||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
LocalDate showEndDate, | ||
int showTime, | ||
int showIntermissionTime, | ||
String showAgeLimit, | ||
PlaceDetailsInfo placeDetailsInfo | ||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev.hooon.show.exception; | ||
|
||
import dev.hooon.common.exception.ErrorCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum ShowErrorCode implements ErrorCode { | ||
|
||
SHOW_NOT_FOUND("공연을 찾을 수 없습니다.", "S_001"); | ||
|
||
private final String message; | ||
private final String code; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orElseThrow() 로 처리하는게 어떨까요? 더 깔끔할거같아요 ㅎㅎ