Skip to content

Commit

Permalink
feat: 공연 상세 조회 (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmizz authored Aug 4, 2024
1 parent 9b83959 commit 5fe52cd
Show file tree
Hide file tree
Showing 51 changed files with 991 additions and 310 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
configurer -> configurer.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
.authorizeHttpRequests(registry -> registry
.requestMatchers(getMatcherForAnyone())
.permitAll()
.requestMatchers(getMatcherForUserAndAdmin())
.hasAnyRole("USER", "ADMIN")
.requestMatchers(getMatcherForAnyone())
.permitAll()
.anyRequest()
.hasAnyRole("ADMIN")
)
Expand Down Expand Up @@ -74,6 +74,7 @@ private RequestMatcher getMatcherForAnyone() {
antMatcher(HttpMethod.GET, "/api/v1/artists"),
antMatcher(HttpMethod.GET, "/api/v1/genres"),
antMatcher(HttpMethod.GET, "/api/v1/shows"),
antMatcher(HttpMethod.GET, "/api/v1/shows/{showId}"),
antMatcher(HttpMethod.GET, "/api/v1/artists/search/**"),
antMatcher(HttpMethod.GET, "/api/v1/shows/search/**")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,7 @@ public ResponseEntity<ShowDetailApiResponse> getShow(
@PathVariable("showId") UUID showId
) {
return ResponseEntity.ok(
new ShowDetailApiResponse(
showId,
"2021 서울재즈페스티벌",
new ArtistSimpleApiResponse(
UUID.randomUUID(),
"윈터",
image
),
new GenreSimpleApiResponse(
UUID.randomUUID(),
"재즈",
image
),
List.of(
new TicketingAndShowInfoApiResponse(
"2021-10-01 14:00:00",
"2021-10-03 14:00:00",
image
)
),
image
)
ShowDetailApiResponse.from(showService.getShow(showId))
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.show.controller.dto.param;

import com.example.show.service.dto.param.ShowTicketingSiteServiceParam;
import lombok.Builder;

@Builder
public record ShowTicketingSiteApiParam(
String siteName,
String siteURL
) {

public static ShowTicketingSiteApiParam from(ShowTicketingSiteServiceParam param) {
return ShowTicketingSiteApiParam.builder()
.siteName(param.siteName())
.siteURL(param.siteURL())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.example.show.controller.dto.request;

import com.example.show.controller.dto.response.SeatInfoApiResponse;
import com.example.show.controller.dto.response.TicketingInfoApiResponse;
import com.example.show.controller.vo.TicketingApiType;
import com.example.show.service.dto.request.ShowCreateServiceRequest;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand All @@ -22,29 +21,35 @@ public record ShowCreateApiForm(
@NotBlank(message = "공연 내용은 필수 요청값 입니다.")
String content,

@NotNull(message = "공연 날짜는 필수 요청값 입니다.")
LocalDate date,
@NotNull(message = "공연 시작 날짜는 필수 요청값 입니다.")
LocalDate startDate,

@NotNull(message = "공연 종료 날짜는 필수 요청값 입니다.")
LocalDate endDate,

@NotNull(message = "공연 장소는 필수 요청값 입니다.")
String location,

@NotNull(message = "공연 포스터는 필수 요청값 입니다.")
MultipartFile post,

@NotNull(message = "공연 좌석 타입은 필수 요청값 입니다.")
List<String> seatTypes,
@NotNull(message = "공연 티켓팅 종류는 필수 요청값 입니다.")
List<TicketingApiType> ticketingTypes,

@NotNull(message = "공연 좌석별 가격은 필수 요청값 입니다.")
List<Integer> pricesPerSeatType,

@NotNull(message = "공연 티켓 오픈 시간은 필수 요청값 입니다.")
LocalDateTime ticketOpenTime,
@NotNull(message = "공연 티켓팅 종류는 필수 요청값 입니다.")
List<LocalDate> ticketingDates,

@NotNull(message = "티켓팅 예약 사이트명은 필수 요청값 입니다.")
List<String> ticketBookingSites,

@NotNull(message = "티켓팅 예약 사이트 URL는 필수 요청값 입니다.")
List<String> ticketingSiteUrls,
List<String> ticketingSiteURL,

@NotNull(message = "공연 좌석 타입은 필수 요청값 입니다.")
List<String> seatTypes,

@NotNull(message = "공연 좌석별 가격은 필수 요청값 입니다.")
List<Integer> pricesPerSeatType,

@NotNull(message = "아티스트 ID는 필수 요청값 입니다.")
List<UUID> artistIds,
Expand All @@ -57,11 +62,13 @@ public ShowCreateServiceRequest toServiceRequest() {
return ShowCreateServiceRequest.builder()
.title(title)
.content(content)
.date(date)
.startDate(startDate)
.endDate(endDate)
.location(location)
.post(post)
.seatInfoApiResponse(getSeatInfoApiResponse())
.ticketingInfoApiResponse(getTicketingInfoApiResponse())
.showTicketingSites(getTicketingSitesApiResponse())
.showTicketingDates(getTicketingDatesApiResponse())
.artistIds(artistIds)
.genreIds(genreIds)
.build();
Expand All @@ -74,11 +81,15 @@ private SeatInfoApiResponse getSeatInfoApiResponse() {
return new SeatInfoApiResponse(priceInformation);
}

private TicketingInfoApiResponse getTicketingInfoApiResponse() {
Map<String, String> ticketingInformation = IntStream.range(0, ticketBookingSites.size())
private Map<String, String> getTicketingSitesApiResponse() {
return IntStream.range(0, ticketBookingSites.size())
.boxed()
.collect(Collectors.toMap(ticketBookingSites::get, ticketingSiteUrls::get));
return new TicketingInfoApiResponse(ticketOpenTime, ticketingInformation);
.collect(Collectors.toMap(ticketBookingSites::get, ticketingSiteURL::get));
}

private Map<TicketingApiType, LocalDate> getTicketingDatesApiResponse() {
return IntStream.range(0, ticketingTypes.size())
.boxed()
.collect(Collectors.toMap(ticketingTypes::get, ticketingDates::get));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.show.controller.dto.request;

import com.example.show.controller.dto.response.SeatInfoApiResponse;
import com.example.show.controller.dto.response.TicketingInfoApiResponse;
import com.example.show.service.dto.request.ShowUpdateServiceRequest;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -22,8 +21,11 @@ public record ShowUpdateApiForm(
@NotBlank(message = "공연 내용은 필수 요청값 입니다.")
String content,

@NotNull(message = "공연 날짜는 필수 요청값 입니다.")
LocalDate date,
@NotNull(message = "공연 시작 날짜는 필수 요청값 입니다.")
LocalDate startDate,

@NotNull(message = "공연 종료 날짜는 필수 요청값 입니다.")
LocalDate endDate,

@NotNull(message = "공연 장소는 필수 요청값 입니다.")
String location,
Expand All @@ -44,7 +46,7 @@ public record ShowUpdateApiForm(
List<String> ticketBookingSites,

@NotNull(message = "티켓팅 예약 사이트 URL는 필수 요청값 입니다.")
List<String> ticketingSiteUrls,
List<String> ticketingSiteURL,

@NotNull(message = "아티스트 ID는 필수 요청값 입니다.")
List<UUID> artistIds,
Expand All @@ -57,11 +59,12 @@ public ShowUpdateServiceRequest toServiceRequest() {
return ShowUpdateServiceRequest.builder()
.title(title)
.content(content)
.date(date)
.startDate(startDate)
.endDate(endDate)
.location(location)
.post(post)
.seatInfoApiResponse(getSeatInfoApiResponse())
.ticketingInfoApiResponse(getTicketingInfoApiResponse())
.showTicketingSiteInfos(getTicketingInfoApiResponse())
.artistIds(artistIds)
.genreIds(genreIds)
.build();
Expand All @@ -74,11 +77,9 @@ private SeatInfoApiResponse getSeatInfoApiResponse() {
return new SeatInfoApiResponse(priceInformation);
}

private TicketingInfoApiResponse getTicketingInfoApiResponse() {
Map<String, String> ticketingInformation = IntStream.range(0, ticketBookingSites.size())
private Map<String, String> getTicketingInfoApiResponse() {
return IntStream.range(0, ticketBookingSites.size())
.boxed()
.collect(Collectors.toMap(ticketBookingSites::get, ticketingSiteUrls::get));
return new TicketingInfoApiResponse(ticketOpenTime, ticketingInformation);
.collect(Collectors.toMap(ticketBookingSites::get, ticketingSiteURL::get));
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.example.show.controller.dto.response;

import java.util.Map;
import org.example.entity.show.info.SeatPrice;
import org.example.entity.show.info.SeatPrices;

public record SeatInfoApiResponse(
Map<String, Integer> priceInformation
) {

public static SeatInfoApiResponse from(SeatPrice seatPrice) {
return new SeatInfoApiResponse(seatPrice.getPriceInformation());
public static SeatInfoApiResponse from(SeatPrices seatPrices) {
return new SeatInfoApiResponse(seatPrices.getPriceBySeat());
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.show.controller.dto.response;

import com.example.show.service.dto.response.ShowArtistServiceResponse;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID;
import lombok.Builder;

@Builder
public record ShowArtistApiResponse(

@Schema(description = "아티스트 ID")
UUID id,

@Schema(description = "아티스트 한국어 이름")
String koreanName,

@Schema(description = "아티스트 영어 이름")
String englishName,

@Schema(description = "아티스트 이미지 주소")
String image
) {

public static ShowArtistApiResponse from(ShowArtistServiceResponse artists) {
return ShowArtistApiResponse.builder()
.id(artists.id())
.koreanName(artists.koreanName())
.englishName(artists.englishName())
.image(artists.image())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.example.show.controller.dto.response;

import com.example.artist.controller.dto.response.ArtistSimpleApiResponse;
import com.example.genre.controller.dto.response.GenreSimpleApiResponse;
import com.example.show.controller.dto.param.ShowTicketingSiteApiParam;
import com.example.show.service.dto.response.ShowDetailServiceResponse;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import java.util.UUID;
import lombok.Builder;

@Builder
public record ShowDetailApiResponse(

@Schema(description = "공연 ID")
Expand All @@ -14,17 +16,51 @@ public record ShowDetailApiResponse(
@Schema(description = "공연 이름")
String name,

@Schema(description = "공연 시작일")
String startDate,

@Schema(description = "공연 종료일")
String endDate,

@Schema(description = "공연 포스터 주소")
String posterImageURL,

@Schema(description = "아티스트 정보")
ArtistSimpleApiResponse artist,
List<ShowArtistApiResponse> artists,

@Schema(description = "장르 정보")
GenreSimpleApiResponse genre,
List<ShowGenreApiResponse> genres,

@Schema(description = "티켓팅 정보 및 공연 날짜")
List<TicketingAndShowInfoApiResponse> ticketingAndShowInfo,
@Schema(description = "좌석 정보")
ShowSeatApiResponse seats,

@Schema(description = "공연 포스터 주소")
String posterImageURL
@Schema(description = "티켓팅 정보 및 공연 날짜")
List<ShowTicketingSiteApiParam> ticketingSites
) {

public static ShowDetailApiResponse from(ShowDetailServiceResponse show) {
return ShowDetailApiResponse.builder()
.id(show.id())
.name(show.title())
.startDate(show.startDate().toString())
.endDate(show.endDate().toString())
.posterImageURL(show.posterImageURL())
.artists(
show.artists().stream()
.map(ShowArtistApiResponse::from)
.toList()
)
.genres(
show.genres().stream()
.map(ShowGenreApiResponse::from)
.toList()
)
.seats(ShowSeatApiResponse.from((show.seats())))
.ticketingSites(
show.ticketingSites().stream()
.map(ShowTicketingSiteApiParam::from)
.toList()
)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.show.controller.dto.response;

import com.example.show.service.dto.response.ShowGenreServiceResponse;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID;
import lombok.Builder;

@Builder
public record ShowGenreApiResponse(

@Schema(description = "장르 ID")
UUID id,

@Schema(description = "장르 이름")
String name
) {

public static ShowGenreApiResponse from(ShowGenreServiceResponse genre) {
return ShowGenreApiResponse.builder()
.id(genre.id())
.name(genre.name())
.build();
}
}
Loading

0 comments on commit 5fe52cd

Please sign in to comment.