22
33import com .example .demo .domain .playlist .dto .EditFinalPlaylistRequest ;
44import com .example .demo .domain .playlist .dto .FinalPlaylistRequest ;
5+ import com .example .demo .domain .playlist .dto .PlaylistDraft ;
56import com .example .demo .domain .playlist .dto .playlistdto .MainPlaylistDetailResponse ;
6- import com .example .demo .domain .playlist .dto .playlistdto .PlaylistCreateRequest ;
7+ import com .example .demo .domain .playlist .dto .playlistdto .SavePlaylistRequest ;
78import com .example .demo .domain .playlist .dto .playlistdto .PlaylistWithSongsResponse ;
89import com .example .demo .domain .playlist .service .PlaylistService ;
910import com .example .demo .global .security .filter .CustomUserDetails ;
2122import org .springframework .security .core .annotation .AuthenticationPrincipal ;
2223import org .springframework .web .bind .annotation .*;
2324
24- import java .util .Arrays ;
25-
2625
2726@ Slf4j
2827@ RestController
@@ -82,9 +81,9 @@ public ResponseEntity<MainPlaylistDetailResponse> getPlaylistDetail(
8281 public ResponseEntity <Void > saveTempPlaylist (
8382 @ io .swagger .v3 .oas .annotations .parameters .RequestBody (
8483 required = true ,
85- content = @ Content (schema = @ Schema (implementation = PlaylistCreateRequest .class ))
84+ content = @ Content (schema = @ Schema (implementation = SavePlaylistRequest .class ))
8685 )
87- @ RequestBody @ Valid PlaylistCreateRequest request ,
86+ @ RequestBody @ Valid SavePlaylistRequest request ,
8887 HttpSession session
8988 ) {
9089 log .info ("[/temp] SESSION ID = {}" , session .getId ());
@@ -94,6 +93,65 @@ public ResponseEntity<Void> saveTempPlaylist(
9493 return ResponseEntity .ok ().build ();
9594 }
9695
96+ @ Operation (
97+ summary = "ํ๋ ์ด๋ฆฌ์คํธ ์์ ์ ์ฅ" ,
98+ description = "ํ๋ ์ด๋ฆฌ์คํธ๋ฅผ ์์ ์ ์ฅํฉ๋๋ค"
99+ )
100+ @ ApiResponse (responseCode = "200" , description = "์์ ์ ์ฅ ์๋ฃ" )
101+ @ PostMapping ("/v2/temp" )
102+ public ResponseEntity <String > createDraftPlaylist (
103+ @ io .swagger .v3 .oas .annotations .parameters .RequestBody (
104+ required = true ,
105+ content = @ Content (schema = @ Schema (implementation = PlaylistDraft .class ))
106+ )
107+ @ RequestBody @ Valid PlaylistDraft playlistDraft
108+ ) {
109+ String draftId = playlistService .saveDraftPlaylist (playlistDraft );
110+ return ResponseEntity .ok (draftId );
111+ }
112+
113+ @ Operation (
114+ summary = "ํ๋ ์ด๋ฆฌ์คํธ ์ ์ฅ" ,
115+ description = "ํ๋ ์ด๋ฆฌ์คํธ๋ฅผ ์ต์ข
์ ์ฅํฉ๋๋ค."
116+ )
117+ @ ApiResponse (
118+ responseCode = "200" ,
119+ description = "์์ฑ๋ ํ๋ ์ด๋ฆฌ์คํธ ์์ธ" ,
120+ content = @ Content (schema = @ Schema (implementation = PlaylistWithSongsResponse .class ))
121+ )
122+ @ ApiResponse (responseCode = "409" , description = "์์ ์ ์ฅ๋ณธ ์์" )
123+ @ PostMapping ("/v2/final/{draftId}" )
124+ public ResponseEntity <PlaylistWithSongsResponse > saveDraftPlaylist (
125+ @ Parameter (hidden = true )
126+ @ AuthenticationPrincipal CustomUserDetails user ,
127+ @ PathVariable String draftId
128+ ) {
129+ PlaylistWithSongsResponse response = playlistService .saveFinalPlaylist (user .getId (), draftId );
130+ return ResponseEntity .ok (response );
131+ }
132+
133+ @ Operation (
134+ summary = "ํ๋ ์ด๋ฆฌ์คํธ ์์ ์ ์ฅ" ,
135+ description = "์ธ์
์ ์ ์ฅ๋ ์์๋ณธ๊ณผ CD ์์ฒญ์ ์ฌ์ฉํ์ฌ ํ๋ ์ด๋ฆฌ์คํธ๋ฅผ ์์ ํฉ๋๋ค"
136+ )
137+ @ ApiResponse (
138+ responseCode = "200" ,
139+ description = "์์ฑ๋ ํ๋ ์ด๋ฆฌ์คํธ ์์ธ" ,
140+ content = @ Content (schema = @ Schema (implementation = PlaylistWithSongsResponse .class ))
141+ )
142+ @ ApiResponse (responseCode = "409" , description = "์์ ์ ์ฅ๋ณธ ์์" )
143+ @ PatchMapping ("/v2/final/playlist/{playlistId}/draft/{draftId}" )
144+ public ResponseEntity <PlaylistWithSongsResponse > editFinalPlaylist (
145+ @ Parameter (hidden = true )
146+ @ AuthenticationPrincipal CustomUserDetails user ,
147+ @ PathVariable Long playlistId , @ PathVariable String draftId
148+ ) {
149+ PlaylistWithSongsResponse response = playlistService .editFinalPlaylist (user .getId (),
150+ playlistId , draftId );
151+
152+ return ResponseEntity .ok (response );
153+ }
154+
97155 @ Operation (
98156 summary = "ํ๋ ์ด๋ฆฌ์คํธ ์์ฑ(์ธ์
์์๋ณธ ์ฌ์ฉ + Cd ์์ฒญ)" ,
99157 description = "์ธ์
์ ์ ์ฅ๋ ์์๋ณธ๊ณผ CD ์์ฒญ์ ์ฌ์ฉํ์ฌ ์ค์ ํ๋ ์ด๋ฆฌ์คํธ๋ฅผ ์์ฑํฉ๋๋ค."
@@ -113,12 +171,12 @@ public ResponseEntity<PlaylistWithSongsResponse> savePlaylist(
113171 ) {
114172 log .info ("[/final] SESSION ID = {}" , session .getId ());
115173
116- PlaylistCreateRequest request = (PlaylistCreateRequest ) session .getAttribute ("tempPlaylist" );
174+ SavePlaylistRequest request = (SavePlaylistRequest ) session .getAttribute ("tempPlaylist" );
117175 if (request == null ) {
118176 throw new IllegalStateException ("์ธ์
์ ์์ ์ ์ฅ๋ ํ๋ ์ด๋ฆฌ์คํธ๊ฐ ์์ต๋๋ค." );
119177 }
120178
121- PlaylistWithSongsResponse response = playlistService .saveFinalPlaylistWithSongsAndCd (user .getId (), request , finalPlaylistRequest . saveCdRequest (). cdItems () );
179+ PlaylistWithSongsResponse response = playlistService .saveFinalPlaylistWithSongsAndCd (user .getId (), request , finalPlaylistRequest );
122180
123181 session .removeAttribute ("tempPlaylist" );
124182 return ResponseEntity .ok (response );
@@ -141,13 +199,13 @@ public ResponseEntity<PlaylistWithSongsResponse> editPlaylist(
141199 @ RequestBody EditFinalPlaylistRequest editFinalPlaylistRequest ,
142200 HttpSession session
143201 ) {
144- PlaylistCreateRequest request = (PlaylistCreateRequest ) session .getAttribute ("tempPlaylist" );
202+ SavePlaylistRequest request = (SavePlaylistRequest ) session .getAttribute ("tempPlaylist" );
145203 if (request == null ) {
146204 throw new IllegalStateException ("์ธ์
์ ์์ ์ ์ฅ๋ ํ๋ ์ด๋ฆฌ์คํธ๊ฐ ์์ต๋๋ค." );
147205 }
148206
149- PlaylistWithSongsResponse response = playlistService .editFinalPlaylistWithSongsAndCd (user .getId (), editFinalPlaylistRequest . playlistId (),
150- request , editFinalPlaylistRequest . saveCdRequest (). cdItems () );
207+ PlaylistWithSongsResponse response = playlistService .editFinalPlaylistWithSongsAndCd (user .getId (),
208+ request , editFinalPlaylistRequest );
151209
152210 session .removeAttribute ("tempPlaylist" );
153211 return ResponseEntity .ok (response );
0 commit comments