-
Notifications
You must be signed in to change notification settings - Fork 2
[Concerts] 공연 목록 조회, 공연 상세 조회, 공연 예매처 조회 추가 #54
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
Changes from all commits
dbceb1c
edd2bfb
e4f6445
ac02b40
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 |
|---|---|---|
|
|
@@ -2,18 +2,35 @@ | |
|
|
||
| import com.back.web7_9_codecrete_be.domain.concerts.dto.KopisApiDto.concert.ConcertListResponse; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.dto.KopisApiDto.concertPlace.ConcertPlaceListResponse; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.dto.concert.ConcertDetailResponse; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.dto.concert.ConcertItem; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.dto.ticketOffice.TicketOfficeElement; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.entity.TicketOffice; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.service.ConcertService; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.service.KopisApiService; | ||
| import com.back.web7_9_codecrete_be.global.rsData.RsData; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springdoc.core.converters.models.PageableAsQueryParam; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.domain.Sort; | ||
| import org.springframework.stereotype.Controller; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping("api/v1/concerts/") | ||
| @Controller | ||
| @RequiredArgsConstructor | ||
| @Tag(name = "Concerts", description = "공연에 대한 정보를 제공하는 API 입니다.") | ||
| public class ConcertController { | ||
| private final ConcertService concertService; | ||
| private final KopisApiService kopisApiService; | ||
|
|
@@ -33,4 +50,46 @@ public ConcertPlaceListResponse setConcertPlace() throws InterruptedException { | |
| return kopisApiService.setConcertPlace(); | ||
| } | ||
|
|
||
| @Operation(summary = "공연목록", description = "공연 전체 목록을 조회합니다. 시작일자를 기준으로 오름차순 조회합니다.") | ||
| @GetMapping("list") | ||
| public RsData<List<ConcertItem>> getList ( | ||
| @RequestParam | ||
| @Schema(description = "page입니다. 일단은 ?page={page} 로 넘기시면 됩니다.", example = "1") | ||
| int page | ||
| ) { | ||
| Pageable pageable = PageRequest.of(page, 10, Sort.by("startDate").ascending()); | ||
| return RsData.success(concertService.getConcertsList(pageable)); | ||
| } | ||
|
|
||
| @Operation(summary = "다가오는 공연 목록", description = "오늘을 기준으로 다가오는 공연 목록을 조회합니다.") | ||
| @GetMapping("upComingList") | ||
| public RsData<List<ConcertItem>> getUpComingList ( | ||
| @RequestParam | ||
| @Schema(description = "page입니다. 일단은 ?page={page} 로 넘기시면 됩니다.", example = "1") | ||
| int page | ||
| ) { | ||
| Pageable pageable = PageRequest.of(page, 10); | ||
| return RsData.success(concertService.getUpcomingConcertsList(pageable)); | ||
| } | ||
|
|
||
| @Operation(summary = "공연 상세 조회", description = "공연에 대한 상세 목록을 조회합니다.") | ||
| @GetMapping("concertDetail") | ||
| public ConcertDetailResponse getConcertDetail( | ||
| @RequestParam | ||
| @Schema(description = "조회 기준이 되는 concertId입니다. ?concertId={concertId} 로 값을 넘기시면 됩니다.") | ||
| long concertId | ||
| ) { | ||
| return concertService.getConcertDetail(concertId); | ||
|
Collaborator
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. 여기도 다른 함수들처럼 RsData.success 로 통일하는게 더 좋을 것 같습니다!
Collaborator
Author
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. 확인했습니다! |
||
| } | ||
|
|
||
| @Operation(summary = "공연 예매처 조회", description = "공연에 대한 예매처들을 조회합니다.") | ||
| @GetMapping("ticketOffices") | ||
| public RsData<List<TicketOfficeElement>> getTicketOffices ( | ||
| @RequestParam | ||
| @Schema(description = "조회 기준이 되는 concertId입니다. ?concertId={concertId} 로 값을 넘기시면 됩니다.") | ||
| long concertId | ||
| ){ | ||
| return RsData.success(concertService.getTicketOfficesList(concertId)); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.back.web7_9_codecrete_be.domain.concerts.dto.concert; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| @Getter | ||
| public class ConcertDetailResponse { | ||
|
|
||
| @Schema(description = "콘서트 Id입니다.") | ||
| private Long concertId; | ||
|
|
||
| @Schema(description = "콘서트 이름입니다.") | ||
| private String name; | ||
|
|
||
| @Schema(description = "콘서트에 대한 설명입니다.") | ||
| private String description; | ||
|
|
||
| @Schema(description = "콘서트 장소 이름입니다.") | ||
| private String placeName; | ||
|
|
||
| @Schema(description = "콘서트 시작 날짜입니다.",format = "yyyy-MM-dd") | ||
| private LocalDate startDate; | ||
|
|
||
| @Schema(description = "콘서트 종료 날짜입니다.",format = "yyyy-MM-dd") | ||
| private LocalDate endDate; | ||
|
|
||
| @Schema(description = "콘서트 포스터URL입니다. 썸네일로 사용해주세요.") | ||
| private String posterUrl; | ||
|
|
||
| @Schema(description = "콘서트 티켓 최고가입니다.") | ||
| private int maxPrice; | ||
|
|
||
| @Schema(description = "콘서트 티켓 최저가입니다.") | ||
| private int minPrice; | ||
|
|
||
| @Schema(description = "콘서트 조회수입니다.") | ||
| private int viewCount; | ||
|
|
||
| @Schema(description = "콘서트 좋아요수입니다.") | ||
| private int likeCount; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package com.back.web7_9_codecrete_be.domain.concerts.dto.concert; | ||
|
|
||
| import com.back.web7_9_codecrete_be.domain.concerts.entity.Concert; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class ConcertItem { | ||
|
|
||
| @Schema(description = "콘서트 Id입니다.") | ||
| private long id; | ||
|
|
||
| @Schema(description = "콘서트 이름입니다.") | ||
| private String name; | ||
|
|
||
| @Schema(description = "콘서트 장소 이름입니다.") | ||
| private String placeName; | ||
|
|
||
| @Schema(description = "콘서트 시작 날짜입니다.",format = "yyyy-MM-dd") | ||
| private LocalDate startDate ; | ||
|
|
||
| @Schema(description = "콘서트 종료 날짜입니다.",format = "yyyy-MM-dd") | ||
| private LocalDate endDate ; | ||
|
|
||
| @Schema(description = "콘서트 포스터URL입니다. 썸네일로 사용해주세요.") | ||
| private String posterUrl; | ||
|
|
||
| @Schema(description = "콘서트 티켓 최고가입니다.") | ||
| private int maxPrice; | ||
|
|
||
| @Schema(description = "콘서트 티켓 최저가입니다.") | ||
| private int minPrice; | ||
|
|
||
| @Schema(description = "콘서트 조회수입니다.") | ||
| private int viewCount; | ||
|
|
||
| @Schema(description = "콘서트 좋아요수입니다.") | ||
| private int likeCount; | ||
|
|
||
| public ConcertItem(Concert concert) { | ||
| this.id = concert.getConcertId(); | ||
| this.name = concert.getName(); | ||
| this.placeName = concert.getConcertPlace().getPlaceName(); | ||
| this.startDate = concert.getStartDate(); | ||
| this.endDate =concert.getEndDate(); | ||
| this.posterUrl = concert.getPosterUrl(); | ||
| this.maxPrice = concert.getMaxPrice(); | ||
| this.minPrice = concert.getMinPrice(); | ||
| this.viewCount = concert.getViewCount(); | ||
| this.likeCount = concert.getLikeCount(); | ||
| } | ||
|
|
||
| public ConcertItem(long id, String name, String placeName, LocalDate startDate, LocalDate endDate, String posterUrl, int maxPrice, int minPrice, int viewCount, int likeCount) { | ||
| this.id = id; | ||
| this.name = name; | ||
| this.placeName = placeName; | ||
| this.startDate = startDate; | ||
| this.endDate = endDate; | ||
| this.posterUrl = posterUrl; | ||
| this.maxPrice = maxPrice; | ||
| this.minPrice = minPrice; | ||
| this.viewCount = viewCount; | ||
| this.likeCount = likeCount; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.back.web7_9_codecrete_be.domain.concerts.dto.ticketOffice; | ||
|
|
||
| import com.back.web7_9_codecrete_be.domain.concerts.entity.TicketOffice; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class TicketOfficeElement { | ||
|
|
||
| @Schema(description = "예매처 이름입니다.") | ||
| String ticketOfficeName; | ||
|
|
||
| @Schema(description = "예매처 주소입니다.") | ||
| String ticketOfficeUrl; | ||
|
|
||
| public TicketOfficeElement(TicketOffice ticketOffice) { | ||
| this.ticketOfficeName = ticketOffice.getTicketOfficeName(); | ||
| this.ticketOfficeUrl = ticketOffice.getTicketOfficeUrl(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| @Entity | ||
|
|
@@ -25,6 +26,12 @@ public class Concert { | |
| @Column(nullable = false,columnDefinition = "TEXT") | ||
| private String content; | ||
|
|
||
| @Column(name = "start_date",nullable = false) | ||
| private LocalDate startDate; | ||
|
|
||
| @Column(name = "end_date",nullable = false) | ||
| private LocalDate endDate; | ||
|
|
||
| @Column(name = "ticket_time", nullable = false) | ||
| private String ticketTime; | ||
|
|
||
|
|
@@ -43,18 +50,36 @@ public class Concert { | |
| @Column(name = "api_concert_id", nullable = false) | ||
| private String apiConcertId; | ||
|
|
||
| public Concert(ConcertPlace concertPlace, String name, String content, String ticketTime, int maxPrice, int minPrice, String apiConcertId) { | ||
| @Column(name = "poster_url",nullable = false,columnDefinition = "TEXT") | ||
| private String posterUrl; | ||
|
|
||
| private int viewCount; | ||
|
|
||
| private int likeCount; | ||
|
|
||
|
|
||
|
|
||
| public Concert(ConcertPlace concertPlace, String name, String content, LocalDate startDate, LocalDate endDate, String ticketTime, int maxPrice, int minPrice, String posterUrl,String apiConcertId) { | ||
| this.concertPlace = concertPlace; | ||
| this.name = name; | ||
| this.content = content; | ||
| this.ticketTime = ticketTime; | ||
| this.startDate = startDate; | ||
| this.endDate = endDate; | ||
| this.createdDate = LocalDateTime.now(); | ||
|
Collaborator
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. JPA Auditing을 사용하고 있어서, createdDate와 modifiedDate는 CreatedDate, LastModifiedDate 어노테이션 사용하시면 될 것 같습니다!
Collaborator
Author
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. 저는 뭔가... JPA 기능 쓰는게 영 익숙하지 않아서 잘 안쓰게 되는데, 해당 부분 확인해보겠습니다. |
||
| this.modifiedDate = LocalDateTime.now(); | ||
| this.maxPrice = maxPrice; | ||
| this.minPrice = minPrice; | ||
| this.posterUrl = posterUrl; | ||
| this.likeCount = 0; | ||
| this.viewCount = 0; | ||
| this.apiConcertId = apiConcertId; | ||
| } | ||
|
|
||
| public Concert(Long concertId) { | ||
| this.concertId = concertId; | ||
| } | ||
|
|
||
| public Concert update(ConcertPlace concertPlace, String content, String ticketTime, int maxPrice, int minPrice){ | ||
| this.concertPlace = concertPlace; | ||
| this.content = content; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,89 @@ | ||
| package com.back.web7_9_codecrete_be.domain.concerts.repository; | ||
|
|
||
| import com.back.web7_9_codecrete_be.domain.concerts.dto.concert.ConcertDetailResponse; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.dto.concert.ConcertItem; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.entity.Concert; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.entity.ConcertPlace; | ||
| import com.back.web7_9_codecrete_be.domain.concerts.entity.ConcertTime; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| @Repository | ||
| public interface ConcertRepository extends JpaRepository<Concert, Long> { | ||
| Concert getConcertByApiConcertId(String apiConcertId); | ||
|
|
||
| @Query(""" | ||
| SELECT | ||
| new com.back.web7_9_codecrete_be.domain.concerts.dto.concert.ConcertItem( | ||
| c.concertId as id, | ||
| c.name as name, | ||
| c.concertPlace.placeName as placeName, | ||
| c.startDate as startDate, | ||
| c.endDate as endDate, | ||
| c.posterUrl as posterUrl, | ||
| c.maxPrice as maxPrice, | ||
| c.minPrice as minPrice, | ||
| c.viewCount as viewCount, | ||
| c.likeCount as likeCount | ||
| ) | ||
| FROM | ||
| Concert c | ||
| """) | ||
| List<ConcertItem> getConcertItems(Pageable pageable); | ||
|
|
||
| @Query(""" | ||
| SELECT | ||
| new com.back.web7_9_codecrete_be.domain.concerts.dto.concert.ConcertItem( | ||
| c.concertId as id, | ||
| c.name as name, | ||
| c.concertPlace.placeName as placeName, | ||
| c.startDate as startDate, | ||
| c.endDate as endDate, | ||
| c.posterUrl as posterUrl, | ||
| c.maxPrice as maxPrice, | ||
| c.minPrice as minPrice, | ||
| c.viewCount as viewCount, | ||
| c.likeCount as likeCount | ||
| ) | ||
| FROM | ||
| Concert c | ||
| WHERE | ||
| c.startDate >= :fromDate | ||
| ORDER BY | ||
| c.startDate | ||
| asc | ||
| """) | ||
| List<ConcertItem> getUpComingConcertItems( | ||
| Pageable pageable, | ||
| @Param("fromDate") LocalDate fromDate | ||
| ); | ||
|
|
||
| @Query(""" | ||
| SELECT | ||
| new com.back.web7_9_codecrete_be.domain.concerts.dto.concert.ConcertDetailResponse( | ||
| c.concertId as concertId, | ||
| c.name as name, | ||
| c.content as description, | ||
| c.concertPlace.placeName as placeName, | ||
| c.startDate as startDate, | ||
| c.endDate as endDate, | ||
| c.posterUrl as posterUrl, | ||
| c.maxPrice as maxPrice, | ||
| c.minPrice as minPrice, | ||
| c.viewCount as viewCount, | ||
| c.likeCount as likeCount | ||
| ) | ||
| FROM | ||
| Concert c | ||
| WHERE | ||
| c.concertId = :concertId | ||
| """) | ||
| ConcertDetailResponse getConcertDetailById(@Param("concertId")long concertId); | ||
| } |
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.
Controller가 RestController와 중복되서 빼셔도 될 것 같습니다!
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.
넵 빼겠습니다.