-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...in/java/com/mookive/mookive_backend/playlist/application/dto/request/PlaylistRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mookive.mookive_backend.playlist.application.dto.request; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class PlaylistRequest { | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public static class PlaylistCreateRequest { | ||
private Long userId; | ||
private String name; | ||
|
||
@Builder | ||
public PlaylistCreateRequest(Long userId, String name) { | ||
this.userId = userId; | ||
this.name = name; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/mookive/mookive_backend/playlist/application/mapper/PlaylistMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.mookive.mookive_backend.playlist.application.mapper; | ||
|
||
import com.mookive.mookive_backend.playlist.application.dto.request.PlaylistRequest; | ||
import com.mookive.mookive_backend.playlist.domain.entity.Playlist; | ||
import com.mookive.mookive_backend.user.domain.entity.User; | ||
|
||
public class PlaylistMapper { | ||
|
||
public static Playlist mapToPlaylist(User user, PlaylistRequest.PlaylistCreateRequest playlistCreateRequest) { | ||
return Playlist.builder() | ||
.name(playlistCreateRequest.getName()) | ||
.user(user) | ||
.build(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../java/com/mookive/mookive_backend/playlist/application/service/PlaylistCreateService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.mookive.mookive_backend.playlist.application.service; | ||
|
||
import com.mookive.mookive_backend.playlist.application.dto.request.PlaylistRequest; | ||
import com.mookive.mookive_backend.playlist.application.mapper.PlaylistMapper; | ||
import com.mookive.mookive_backend.playlist.domain.entity.Playlist; | ||
import com.mookive.mookive_backend.playlist.domain.service.PlaylistSaveService; | ||
import com.mookive.mookive_backend.user.domain.entity.User; | ||
import com.mookive.mookive_backend.user.domain.service.UserQueryService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PlaylistCreateService { | ||
|
||
private final UserQueryService userQueryService; | ||
private final PlaylistSaveService playlistSaveService; | ||
|
||
public void createPlaylist(PlaylistRequest.PlaylistCreateRequest playlistCreateRequest) { | ||
System.out.println("playlistCreateRequest = " + playlistCreateRequest.getName()); | ||
Long userId = playlistCreateRequest.getUserId(); | ||
System.out.println("userId = " + userId); | ||
User user = userQueryService.findById(userId); | ||
Playlist playlist = PlaylistMapper.mapToPlaylist(user, playlistCreateRequest); | ||
playlistSaveService.savePlaylist(playlist); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/mookive/mookive_backend/playlist/domain/service/PlaylistSaveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.mookive.mookive_backend.playlist.domain.service; | ||
|
||
import com.mookive.mookive_backend.playlist.domain.entity.Playlist; | ||
import com.mookive.mookive_backend.playlist.domain.repository.PlaylistRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PlaylistSaveService { | ||
|
||
private final PlaylistRepository playlistRepository; | ||
|
||
public void savePlaylist(Playlist playlist) { | ||
playlistRepository.save(playlist); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/mookive/mookive_backend/playlist/presentation/PlaylistController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mookive.mookive_backend.playlist.presentation; | ||
|
||
import com.mookive.mookive_backend.playlist.application.dto.request.PlaylistRequest; | ||
import com.mookive.mookive_backend.playlist.application.service.PlaylistCreateService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class PlaylistController { | ||
|
||
private final PlaylistCreateService playlistCreateService; | ||
|
||
@PostMapping("/playlist") | ||
public void createPlaylist(@RequestBody PlaylistRequest.PlaylistCreateRequest playlistCreateRequest) { | ||
playlistCreateService.createPlaylist(playlistCreateRequest); | ||
} | ||
} |