Skip to content

Commit

Permalink
fix : 공연 어드민 기능 오류 수정 (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
GaBaljaintheroom authored Aug 7, 2024
1 parent e4f28b1 commit ae41cd5
Show file tree
Hide file tree
Showing 43 changed files with 538 additions and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ private RequestMatcher getMatcherForUserAndAdmin() {
antMatcher(HttpMethod.POST, "/api/v1/genres/subscribe"),
antMatcher(HttpMethod.POST, "/api/v1/genres/unsubscribe"),
antMatcher(HttpMethod.GET, "/api/v1/genres/subscriptions"),
antMatcher(HttpMethod.GET, "/api/v1/genres/unsubscriptions"),
antMatcher(HttpMethod.POST, "/api/v1/artists/subscribe"),
antMatcher(HttpMethod.POST, "/api/v1/artists/unsubscribe"),
antMatcher(HttpMethod.GET, "/api/v1/artists/subscriptions")
antMatcher(HttpMethod.GET, "/api/v1/artists/subscriptions"),
antMatcher(HttpMethod.GET, "/api/v1/artists/unsubscriptions")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.example.artist.controller.dto.response.ArtistDetailApiFormResponse;
import com.example.artist.service.ArtistAdminService;
import com.example.artist.service.dto.response.ArtistDetailServiceResponse;
import com.example.genre.controller.dto.response.GenreNameApiFormResponse;
import com.example.genre.controller.dto.response.GenreNameApiResponse;
import com.example.genre.service.GenreAdminService;
import jakarta.validation.Valid;
import java.util.List;
Expand All @@ -30,8 +30,8 @@ public class ArtistAdminController {

@GetMapping
public String createArtist(Model model) {
List<GenreNameApiFormResponse> genres = genreAdminService.findAllGenres().stream()
.map(GenreNameApiFormResponse::new)
List<GenreNameApiResponse> genres = genreAdminService.findAllGenres().stream()
.map(GenreNameApiResponse::new)
.toList();
model.addAttribute("genres", genres);
return "artist_create_form";
Expand All @@ -56,8 +56,8 @@ public String findAllArtist(Model model) {

@GetMapping("/{id}")
public String findArtist(@PathVariable("id") UUID id, Model model) {
List<GenreNameApiFormResponse> genres = genreAdminService.findAllGenres().stream()
.map(GenreNameApiFormResponse::new)
List<GenreNameApiResponse> genres = genreAdminService.findAllGenres().stream()
.map(GenreNameApiResponse::new)
.toList();
model.addAttribute("genres", genres);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ArtistController {

private final ArtistService artistService;

@GetMapping
@GetMapping("/unsubscriptions")
@Operation(summary = "구독하지 않은 아티스트 목록 조회")
public ResponseEntity<PaginationApiResponse<ArtistUnsubscriptionPaginationApiParam>> getUnsubscribedArtists(
@AuthenticationPrincipal AuthenticatedUser user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public record ArtistKoreanNameApiResponse(
) {

public ArtistKoreanNameApiResponse(
ArtistKoreanNameServiceResponse artistKoreanNameServiceResponse) {
ArtistKoreanNameServiceResponse artistKoreanNameServiceResponse
) {
this(
artistKoreanNameServiceResponse.id(),
artistKoreanNameServiceResponse.koreanName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.example.genre.controller.dto.request.GenreCreateApiForm;
import com.example.genre.controller.dto.request.GenreUpdateApiForm;
import com.example.genre.controller.dto.response.GenreNameApiFormResponse;
import com.example.genre.controller.dto.response.GenreNameApiResponse;
import com.example.genre.service.GenreAdminService;
import com.example.genre.service.dto.response.GenreNameServiceResponse;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -38,8 +38,8 @@ public String createGenre(@Valid GenreCreateApiForm genreCreateApiForm) {

@GetMapping("/list")
public String findAllGenres(Model model) {
List<GenreNameApiFormResponse> genreNameApiFormResponses = genreAdminService.findAllGenres().stream()
.map(response -> new GenreNameApiFormResponse(response.id(), response.name()))
List<GenreNameApiResponse> genreNameApiFormResponses = genreAdminService.findAllGenres().stream()
.map(response -> new GenreNameApiResponse(response.id(), response.name()))
.toList();

model.addAttribute("genres", genreNameApiFormResponses);
Expand All @@ -50,7 +50,7 @@ public String findAllGenres(Model model) {
public String findGenre(@PathVariable("id") UUID id, Model model) {
GenreNameServiceResponse genreNameServiceResponse = genreAdminService.findGenreById(
id);
GenreNameApiFormResponse genreNameApiFormResponse = new GenreNameApiFormResponse(
GenreNameApiResponse genreNameApiFormResponse = new GenreNameApiResponse(
genreNameServiceResponse.id(),
genreNameServiceResponse.name()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class GenreController {

private final GenreService genreService;

@GetMapping
@GetMapping("/unsubscriptions")
@Operation(summary = "구독하지 않은 장르 목록 조회")
public ResponseEntity<PaginationApiResponse<GenreUnsubscriptionPaginationApiParam>> getUnsubscribedGenres(
@AuthenticationPrincipal AuthenticatedUser user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import com.example.genre.service.dto.response.GenreNameServiceResponse;
import java.util.UUID;

public record GenreNameApiFormResponse(
public record GenreNameApiResponse(
UUID id,
String name
) {

public GenreNameApiFormResponse(GenreNameServiceResponse genreNameServiceResponse) {
public GenreNameApiResponse(GenreNameServiceResponse genreNameServiceResponse) {
this (
genreNameServiceResponse.id(),
genreNameServiceResponse.name()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.example.artist.controller.dto.response.ArtistKoreanNameApiResponse;
import com.example.artist.service.ArtistAdminService;
import com.example.genre.controller.dto.response.GenreNameApiFormResponse;
import com.example.genre.controller.dto.response.GenreNameApiResponse;
import com.example.genre.service.GenreAdminService;
import com.example.show.controller.dto.request.ShowCreateApiForm;
import com.example.show.controller.dto.request.ShowUpdateApiForm;
Expand Down Expand Up @@ -38,9 +38,9 @@ public String createShow(Model model) {
.map(ArtistKoreanNameApiResponse::new)
.toList();

List<GenreNameApiFormResponse> genres = genreAdminService.findAllGenres()
List<GenreNameApiResponse> genres = genreAdminService.findAllGenres()
.stream()
.map(GenreNameApiFormResponse::new)
.map(GenreNameApiResponse::new)
.toList();

model.addAttribute("artists", artists);
Expand Down Expand Up @@ -72,9 +72,9 @@ public String findShow(@PathVariable("id") UUID id, Model model) {
.map(ArtistKoreanNameApiResponse::new)
.toList();

List<GenreNameApiFormResponse> genres = genreAdminService.findAllGenres()
List<GenreNameApiResponse> genres = genreAdminService.findAllGenres()
.stream()
.map(GenreNameApiFormResponse::new)
.map(GenreNameApiResponse::new)
.toList();

ShowInfoServiceResponse showInfoServiceResponse = showAdminService.findShowInfo(id);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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 Down Expand Up @@ -36,7 +37,7 @@ public record ShowCreateApiForm(
List<TicketingApiType> ticketingTypes,

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

@NotNull(message = "티켓팅 예약 사이트명은 필수 요청값 입니다.")
List<String> ticketBookingSites,
Expand Down Expand Up @@ -85,7 +86,7 @@ private Map<String, String> getTicketingSitesApiResponse() {
.collect(Collectors.toMap(ticketBookingSites::get, ticketingSiteURL::get));
}

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

import com.example.show.controller.dto.response.SeatInfoApiResponse;
import com.example.show.controller.vo.TicketingApiType;
import com.example.show.service.dto.request.ShowUpdateServiceRequest;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -33,21 +33,24 @@ public record ShowUpdateApiForm(
@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<LocalDateTime> ticketingDates,

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

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

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

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

@NotNull(message = "아티스트 ID는 필수 요청값 입니다.")
List<UUID> artistIds,

Expand All @@ -63,23 +66,29 @@ public ShowUpdateServiceRequest toServiceRequest() {
.endDate(endDate)
.location(location)
.post(post)
.seatInfoApiResponse(getSeatInfoApiResponse())
.showTicketingSiteInfos(getTicketingInfoApiResponse())
.priceInformation(getPriceInformation())
.showTicketingSites(getTicketingSitesApiResponse())
.ticketingTimes(getTicketingDatesApiResponse())
.artistIds(artistIds)
.genreIds(genreIds)
.build();
}

private SeatInfoApiResponse getSeatInfoApiResponse() {
Map<String, Integer> priceInformation = IntStream.range(0, seatTypes.size())
private Map<String, Integer> getPriceInformation() {
return IntStream.range(0, seatTypes.size())
.boxed()
.collect(Collectors.toMap(seatTypes::get, pricesPerSeatType::get));
return new SeatInfoApiResponse(priceInformation);
}

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

private Map<TicketingApiType, LocalDateTime> getTicketingDatesApiResponse() {
return IntStream.range(0, ticketingTypes.size())
.boxed()
.collect(Collectors.toMap(ticketingTypes::get, ticketingDates::get));
}
}

This file was deleted.

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

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;
Expand Down Expand Up @@ -31,11 +30,14 @@ public record ShowDetailApiResponse(
@Schema(description = "장르 정보")
List<ShowGenreApiResponse> genres,

@Schema(description = "티켓팅 예매 시간 정보")
List<ShowTicketingTimeApiResponse> ticketingTimes,

@Schema(description = "좌석 정보")
ShowSeatApiResponse seats,

@Schema(description = "티켓팅 정보 및 공연 날짜")
List<ShowTicketingSiteApiParam> ticketingSites
ShowTicketingSiteApiResponse ticketingSites
) {

public static ShowDetailApiResponse from(ShowDetailServiceResponse show) {
Expand All @@ -55,12 +57,13 @@ public static ShowDetailApiResponse from(ShowDetailServiceResponse show) {
.map(ShowGenreApiResponse::from)
.toList()
)
.seats(ShowSeatApiResponse.from((show.seats())))
.ticketingSites(
show.ticketingSites().stream()
.map(ShowTicketingSiteApiParam::from)
.ticketingTimes(
show.ticketingTimes().stream()
.map(ShowTicketingTimeApiResponse::from)
.toList()
)
.seats(ShowSeatApiResponse.from((show.seats())))
.ticketingSites(ShowTicketingSiteApiResponse.from(show.ticketingSites()))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.example.show.controller.dto.response;

import com.example.artist.service.dto.response.ArtistKoreanNameServiceResponse;
import com.example.genre.service.dto.response.GenreNameServiceResponse;
import com.example.show.controller.dto.param.ShowTicketingSiteApiParam;
import com.example.artist.controller.dto.response.ArtistKoreanNameApiResponse;
import com.example.genre.controller.dto.response.GenreNameApiResponse;
import com.example.show.service.dto.response.ShowInfoServiceResponse;
import java.time.LocalDate;
import java.util.List;
Expand All @@ -17,11 +16,13 @@ public record ShowInfoApiResponse(
LocalDate endDate,
String location,
String image,
SeatInfoApiResponse seatInfoApiResponse,
List<ShowTicketingSiteApiParam> ticketingSites,
List<ArtistKoreanNameServiceResponse> artistKoreanNameResponses,
List<GenreNameServiceResponse> genreNameResponses
ShowSeatApiResponse seatInfoApiResponse,
ShowTicketingSiteApiResponse ticketingSiteApiResponse,
List<ShowTicketingTimeApiResponse> ticketingTimes,
List<ArtistKoreanNameApiResponse> artistKoreanNameResponses,
List<GenreNameApiResponse> genreNameResponses
) {

public ShowInfoApiResponse(ShowInfoServiceResponse showInfoServiceResponse) {
this(
showInfoServiceResponse.id(),
Expand All @@ -31,12 +32,17 @@ public ShowInfoApiResponse(ShowInfoServiceResponse showInfoServiceResponse) {
showInfoServiceResponse.startDate(),
showInfoServiceResponse.location(),
showInfoServiceResponse.image(),
showInfoServiceResponse.seatInfoApiResponse(),
showInfoServiceResponse.ticketingSiteInfos().stream()
.map(ShowTicketingSiteApiParam::from)
ShowSeatApiResponse.from(showInfoServiceResponse.seats()),
ShowTicketingSiteApiResponse.from(showInfoServiceResponse.ticketingSiteInfos()),
showInfoServiceResponse.ticketingSites().stream()
.map(ShowTicketingTimeApiResponse::from)
.toList(),
showInfoServiceResponse.artistKoreanNameResponses().stream()
.map(ArtistKoreanNameApiResponse::new)
.toList(),
showInfoServiceResponse.artistKoreanNameResponses(),
showInfoServiceResponse.genreNameResponses()
showInfoServiceResponse.genreNameResponses().stream()
.map(GenreNameApiResponse::new)
.toList()
);
}

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

import com.example.show.service.dto.response.ShowTicketingSiteServiceResponse;
import java.util.Map;
import lombok.Builder;

@Builder
public record ShowTicketingSiteApiResponse(
Map<String, String> ticketingSites
) {

public static ShowTicketingSiteApiResponse from(
ShowTicketingSiteServiceResponse ticketingSites
) {
return new ShowTicketingSiteApiResponse(ticketingSites.ticketingSites());
}
}
Loading

0 comments on commit ae41cd5

Please sign in to comment.