Skip to content

Commit

Permalink
feat: 공연 목록 조회 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmizz authored Aug 11, 2024
1 parent 4d68c03 commit 933a7e0
Show file tree
Hide file tree
Showing 19 changed files with 167 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private CorsConfigurationSource corsConfigurationSource() {

private RequestMatcher getMatcherForAnyone() {
return RequestMatchers.anyOf(
antMatcher("/health"),
antMatcher("/swagger-ui/**"),
antMatcher("/v3/api-docs/**"),
antMatcher("/admin/**"),
Expand All @@ -75,6 +76,7 @@ private RequestMatcher getMatcherForAnyone() {
antMatcher(HttpMethod.GET, "/api/v1/genres"),
antMatcher(HttpMethod.GET, "/api/v1/shows"),
antMatcher(HttpMethod.GET, "/api/v1/shows/{showId}"),
antMatcher(HttpMethod.PATCH, "/api/v1/shows/{showId}/view"),
antMatcher(HttpMethod.GET, "/api/v1/artists/search/**"),
antMatcher(HttpMethod.GET, "/api/v1/shows/search/**"),
antMatcher(HttpMethod.GET, "/api/v1/artists/filter"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -57,8 +58,8 @@ public ResponseEntity<PaginationApiResponse<ShowPaginationApiParam>> getShows(

return ResponseEntity.ok(
PaginationApiResponse.<ShowPaginationApiParam>builder()
.data(data)
.hasNext(response.hasNext())
.data(data)
.hasNext(response.hasNext())
.build()
);

Expand Down Expand Up @@ -135,4 +136,12 @@ public ResponseEntity<PaginationApiResponse<ShowSearchPaginationApiParam>> searc
.build()
);
}

@PatchMapping("/{showId}/view")
@Operation(summary = "공연 조회수 증가")
public void view(
@PathVariable("showId") UUID showId
) {
showService.view(showId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public record ShowPaginationApiRequest(
boolean onlyOpenSchedule,

@Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null")
UUID cursor,
UUID cursorId,

@Parameter(description = "이전 페이지네이션 마지막 데이터의 정렬 필드 값 (RECENT: reservationAt, POPULAR: viewCount) / 최초 조회라면 null")
UUID cursorValue,

@Parameter(required = true, description = "조회하려는 데이터 개수")
int size
Expand All @@ -26,7 +29,8 @@ public record ShowPaginationApiRequest(
public ShowPaginationServiceRequest toServiceRequest(LocalDateTime now) {
return ShowPaginationServiceRequest.builder()
.sort(sort)
.cursor(cursor)
.cursorId(cursorId)
.cursorValue(cursorValue)
.size(size)
.now(now)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public record ShowInfoApiResponse(
LocalDate endDate,
String location,
String image,
int viewCount,
ShowSeatApiResponse seatInfoApiResponse,
ShowTicketingSiteApiResponse ticketingSiteApiResponse,
List<ShowTicketingTimeApiResponse> ticketingTimes,
Expand All @@ -32,6 +33,7 @@ public ShowInfoApiResponse(ShowInfoServiceResponse showInfoServiceResponse) {
showInfoServiceResponse.startDate(),
showInfoServiceResponse.location(),
showInfoServiceResponse.image(),
showInfoServiceResponse.viewCount(),
ShowSeatApiResponse.from(showInfoServiceResponse.seats()),
ShowTicketingSiteApiResponse.from(showInfoServiceResponse.ticketingSiteInfos()),
showInfoServiceResponse.ticketingSites().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ public record ShowPaginationApiParam(
@Schema(description = "공연 포스터 이미지 주소")
String posterImageURL,

@Schema(description = "예매일")
@Schema(description = "가장 근접한 예매 시간")
String reservationAt,

@Schema(description = "오픈 예정인 티켓팅 일정이 있는지 여부")
boolean hasTicketingOpenSchedule,

@Schema(description = "조회수")
int viewCount,

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

Expand All @@ -45,6 +48,7 @@ public static ShowPaginationApiParam from(ShowPaginationServiceResponse response
.posterImageURL(response.posterImageURL())
.reservationAt(response.reservationAt())
.hasTicketingOpenSchedule(response.hasTicketingOpenSchedule())
.viewCount(response.viewCount())
.artists(
response.artists().stream()
.map(ShowArtistPaginationApiParam::from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public PaginationServiceResponse<ShowPaginationServiceResponse> findShows(ShowPa
response.hasNext()
);
}

public void view(UUID showId) {
showUseCase.view(showId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
public record ShowPaginationServiceRequest(
ShowSortApiType sort,
boolean onlyOpenSchedule,
UUID cursor,
UUID cursorId,
Object cursorValue,
int size,
LocalDateTime now
) {
Expand All @@ -19,7 +20,8 @@ public ShowPaginationDomainRequest toDomainRequest() {
return ShowPaginationDomainRequest.builder()
.sort(sort.toDomainType())
.onlyOpenSchedule(onlyOpenSchedule)
.cursor(cursor)
.cursorId(cursorId)
.cursorValue(cursorValue)
.size(size)
.now(now)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public record ShowInfoServiceResponse(
LocalDate endDate,
String location,
String image,
int viewCount,
ShowSeatServiceResponse seats,
ShowTicketingSiteServiceResponse ticketingSiteInfos,
List<ShowTicketingTimeServiceResponse> ticketingSites,
Expand All @@ -40,6 +41,7 @@ public ShowInfoServiceResponse(ShowInfoDomainResponse showInfo) {
showInfo.show().endDate(),
showInfo.show().location(),
showInfo.show().image(),
showInfo.show().viewCount(),
ShowSeatServiceResponse.from(showInfo.show().seatPrices()),
ShowTicketingSiteServiceResponse.from(showInfo.show().ticketingSites()),
toShowTicketingTimeServiceResponses(showInfo.ticketingTimes()),
Expand Down Expand Up @@ -72,6 +74,7 @@ public static List<ShowInfoServiceResponse> as(
showWithTicketingTime.show().endDate(),
showWithTicketingTime.show().location(),
showWithTicketingTime.show().image(),
showWithTicketingTime.show().viewCount(),
ShowSeatServiceResponse.from(showWithTicketingTime.show().seatPrices()),
ShowTicketingSiteServiceResponse.from(
showWithTicketingTime.show().ticketingSites()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public record ShowPaginationServiceResponse(
String posterImageURL,
String reservationAt,
boolean hasTicketingOpenSchedule,
int viewCount,
List<ShowArtistSimpleServiceResponse> artists,
List<ShowGenreSimpleServiceResponse> genres,
List<ShowTicketingTimeServiceParam> showTicketingTimes
Expand All @@ -41,6 +42,7 @@ public static ShowPaginationServiceResponse from(ShowDetailDomainResponse respon
.posterImageURL(response.show().image())
.reservationAt(reservationAt)
.hasTicketingOpenSchedule(now.isBefore(response.show().lastTicketingAt()))
.viewCount(response.show().viewCount())
.artists(
response.artists().stream()
.map(ShowArtistSimpleServiceResponse::from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ private SliceUtil() {

public static <T> Slice<T> makeSlice(final int size, final List<T> dtos) {
final boolean hasNext = dtos.size() > size;

if (hasNext) {
dtos.remove(size);
return new SliceImpl<>(dtos.subList(0, size), Pageable.ofSize(size), true);
}

return new SliceImpl<>(dtos, Pageable.ofSize(size), hasNext);
return new SliceImpl<>(dtos, Pageable.ofSize(size), false);
}
}
3 changes: 2 additions & 1 deletion app/domain/common-domain/src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ VALUES (gen_random_uuid(),

-- Show
INSERT INTO show(id, created_at, updated_at, is_deleted, title, content, start_date, end_date,
location, image, last_ticketing_at, seat_prices, ticketing_sites)
location, image, last_ticketing_at, view_count, seat_prices, ticketing_sites)
VALUES ('eca21e50-1392-4059-b380-061a2323c6d2',
now(),
now(),
Expand All @@ -864,6 +864,7 @@ VALUES ('eca21e50-1392-4059-b380-061a2323c6d2',
'공연장 위치',
'https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg',
now(),
0,
'{"b": 20000, "c": 30000}',
'{"티켓링크": "https://naver.com"}');

Expand Down
22 changes: 10 additions & 12 deletions app/domain/common-domain/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
alter table if exists artist_search
drop
constraint if exists fk_artist_artist_search;
drop constraint if exists fk_artist_artist_search;

alter table if exists show_search
drop
constraint if exists fk_show_show_search;
drop constraint if exists fk_show_show_search;

alter table if exists show_ticketing_time
drop
constraint if exists fk_show_show_ticketing_time;
drop constraint if exists fk_show_show_ticketing_time;

drop table if exists admin cascade;
drop table if exists artist cascade;
Expand Down Expand Up @@ -131,6 +128,7 @@ create table show
location varchar(255) not null,
image varchar(255) not null,
last_ticketing_at timestamp(6) not null,
view_count int not null,
seat_prices jsonb not null,
ticketing_sites jsonb not null,
primary key (id)
Expand Down Expand Up @@ -223,15 +221,15 @@ create table users

alter table if exists artist_search
add constraint fk_artist_artist_search
foreign key (artist_id)
references artist;
foreign key (artist_id)
references artist;

alter table if exists show_search
add constraint fk_show_show_search
foreign key (show_id)
references show;
foreign key (show_id)
references show;

alter table if exists show_ticketing_time
add constraint fk_show_show_ticketing_time
foreign key (show_id)
references show;
foreign key (show_id)
references show;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
public record ShowPaginationDomainRequest(
ShowSortType sort,
boolean onlyOpenSchedule,
UUID cursor,
UUID cursorId,
Object cursorValue,
int size,
LocalDateTime now
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.example.dto.show.response;

import java.util.Set;
import lombok.Builder;
import org.example.dto.artist.response.ArtistDomainResponse;
import org.example.dto.genre.response.GenreDomainResponse;

@Builder
public record ShowDetailDomainResponse(
ShowDomainResponse show,
Set<ArtistDomainResponse> artists,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public record ShowDomainResponse(
String location,
String image,
LocalDateTime lastTicketingAt,
int viewCount,
SeatPrices seatPrices,
TicketingSites ticketingSites
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class Show extends BaseEntity {
@Column(name = "last_ticketing_at", nullable = false)
private LocalDateTime lastTicketingAt;

@Column(name = "view_count", nullable = false)
private int viewCount;

@Enumerated
private SeatPrices seatPrices;

Expand All @@ -70,6 +73,7 @@ private Show(
this.location = location;
this.image = image;
this.lastTicketingAt = lastTicketingAt;
this.viewCount = 0;
this.seatPrices = seatPrices;
this.ticketingSites = ticketingSites;
}
Expand Down Expand Up @@ -120,4 +124,8 @@ public void changeShowInfo(Show newShow) {
this.image = newShow.image;
this.seatPrices = newShow.seatPrices;
}

public void view() {
this.viewCount++;
}
}
Loading

0 comments on commit 933a7e0

Please sign in to comment.