44import com .back .web7_9_codecrete_be .domain .concerts .dto .KopisApiDto .concertPlace .ConcertPlaceListResponse ;
55import com .back .web7_9_codecrete_be .domain .concerts .dto .concert .ConcertDetailResponse ;
66import com .back .web7_9_codecrete_be .domain .concerts .dto .concert .ConcertItem ;
7+ import com .back .web7_9_codecrete_be .domain .concerts .dto .concert .ConcertLikeResponse ;
78import com .back .web7_9_codecrete_be .domain .concerts .dto .ticketOffice .TicketOfficeElement ;
89import com .back .web7_9_codecrete_be .domain .concerts .entity .TicketOffice ;
910import com .back .web7_9_codecrete_be .domain .concerts .service .ConcertService ;
1011import com .back .web7_9_codecrete_be .domain .concerts .service .KopisApiService ;
12+ import com .back .web7_9_codecrete_be .domain .users .entity .User ;
13+ import com .back .web7_9_codecrete_be .global .rq .Rq ;
1114import com .back .web7_9_codecrete_be .global .rsData .RsData ;
1215import io .swagger .v3 .oas .annotations .Operation ;
1316import io .swagger .v3 .oas .annotations .media .Schema ;
1922import org .springframework .data .domain .Pageable ;
2023import org .springframework .data .domain .Sort ;
2124import org .springframework .stereotype .Controller ;
22- import org .springframework .web .bind .annotation .GetMapping ;
23- import org .springframework .web .bind .annotation .RequestMapping ;
24- import org .springframework .web .bind .annotation .RequestParam ;
25- import org .springframework .web .bind .annotation .RestController ;
25+ import org .springframework .web .bind .annotation .*;
2626
2727import java .util .List ;
2828
3333@ Tag (name = "Concerts" , description = "공연에 대한 정보를 제공하는 API 입니다." )
3434public class ConcertController {
3535 private final ConcertService concertService ;
36- private final KopisApiService kopisApiService ;
37-
38- @ GetMapping ("tests" )
39- public ConcertListResponse tests () {
40- return kopisApiService .getConcertsList ();
41- }
42-
43- @ GetMapping ("totalGetTest" )
44- public ConcertListResponse totalGetTest () throws InterruptedException {
45- return kopisApiService .setConcertsList ();
46- }
47-
48- @ GetMapping ("setConcertPlace" )
49- public ConcertPlaceListResponse setConcertPlace () throws InterruptedException {
50- return kopisApiService .setConcertPlace ();
51- }
36+ private final Rq rq ;
5237
5338 @ Operation (summary = "공연목록" , description = "공연 전체 목록을 조회합니다. 시작일자를 기준으로 오름차순 조회합니다." )
5439 @ GetMapping ("list" )
5540 public RsData <List <ConcertItem >> getList (
56- @ RequestParam
57- @ Schema (description = "page입니다. 일단은 ?page={page} 로 넘기시면 됩니다." , example = "1" )
58- int page
41+ @ Schema (description = "페이징 처리 또는 무한 스크롤 구현에 쓸 Pageable 객체입니다." )
42+ Pageable pageable
5943 ) {
60- Pageable pageable = PageRequest .of (page , 10 , Sort .by ("startDate" ).ascending ());
6144 return RsData .success (concertService .getConcertsList (pageable ));
6245 }
6346
6447 @ Operation (summary = "다가오는 공연 목록" , description = "오늘을 기준으로 다가오는 공연 목록을 조회합니다." )
6548 @ GetMapping ("upComingList" )
6649 public RsData <List <ConcertItem >> getUpComingList (
67- @ RequestParam
68- @ Schema (description = "page입니다. 일단은 ?page={page} 로 넘기시면 됩니다." , example = "1" )
69- int page
50+ @ Schema (description = "페이징 처리 또는 무한 스크롤 구현에 쓸 Pageable 객체입니다." )
51+ Pageable pageable
7052 ) {
71- Pageable pageable = PageRequest .of (page , 10 );
7253 return RsData .success (concertService .getUpcomingConcertsList (pageable ));
7354 }
7455
56+ @ Operation (summary = "좋아요 한 공연 조회" , description = "좋아요를 누른 공연에 대한 목록을 조회합니다. 저장 날짜를 기준으로 내림차순 정렬로 표시합니다.(최신으로 추가된 목록순입니다.)" )
57+ @ GetMapping ("likedConcertList" )
58+ public RsData <List <ConcertItem >> getLikedConcertList (
59+ @ Schema (description = "페이징 처리 또는 무한 스크롤 구현에 쓸 Pageable 객체입니다." )
60+ Pageable pageable
61+ ){
62+ User user = rq .getUser ();
63+ return RsData .success (concertService .getLikedConcertsList (pageable ,user ));
64+ }
65+
7566 @ Operation (summary = "공연 상세 조회" , description = "공연에 대한 상세 목록을 조회합니다." )
7667 @ GetMapping ("concertDetail" )
7768 public ConcertDetailResponse getConcertDetail (
@@ -82,6 +73,8 @@ public ConcertDetailResponse getConcertDetail(
8273 return concertService .getConcertDetail (concertId );
8374 }
8475
76+
77+
8578 @ Operation (summary = "공연 예매처 조회" , description = "공연에 대한 예매처들을 조회합니다." )
8679 @ GetMapping ("ticketOffices" )
8780 public RsData <List <TicketOfficeElement >> getTicketOffices (
@@ -92,4 +85,34 @@ public RsData<List<TicketOfficeElement>> getTicketOffices (
9285 return RsData .success (concertService .getTicketOfficesList (concertId ));
9386 }
9487
88+ @ Operation (summary = "공연 좋아요 기능" , description = "사용자가 마음에 드는 공연에 대해 좋아요를 통해 저장할 수 있습니다." )
89+ @ PostMapping ("like/{concertId}" )
90+ public RsData <Void > likeConcert (
91+ @ PathVariable long concertId
92+ ) {
93+ User user = rq .getUser ();
94+ concertService .likeConcert (concertId , user );
95+ return RsData .success (null );
96+ }
97+
98+ @ Operation (summary = "공연 좋아요 해제 기능" , description = "좋아요를 해제할 수 있습니다." )
99+ @ DeleteMapping ("dislike/{concertId}" )
100+ public RsData <Void > dislikeConcert (
101+ @ PathVariable long concertId
102+ ) {
103+ User user = rq .getUser ();
104+ concertService .dislikeConcert (concertId , user );
105+ return RsData .success (null );
106+ }
107+
108+ @ Operation (summary = "공연 좋아요 여부 확인" , description = "좋아요 여부를 확인합니다." )
109+ @ GetMapping ("isLike/{concertId}" )
110+ public RsData <ConcertLikeResponse > isLikeConcert (
111+ @ PathVariable long concertId
112+ ){
113+ User user = rq .getUser ();
114+ return RsData .success (concertService .isLikeConcert (concertId , user ));
115+ }
116+
117+
95118}
0 commit comments