-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTaskConverter.java
More file actions
71 lines (60 loc) · 2.62 KB
/
TaskConverter.java
File metadata and controls
71 lines (60 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package umc.codeplay.converter;
import java.util.ArrayList;
import java.util.stream.Collectors;
import org.springframework.stereotype.Component;
import lombok.RequiredArgsConstructor;
import umc.codeplay.domain.Harmony;
import umc.codeplay.domain.Remix;
import umc.codeplay.domain.Track;
import umc.codeplay.dto.TaskResponseDTO;
@Component
@RequiredArgsConstructor
public class TaskConverter {
public TaskResponseDTO.HarmonyDTO toHarmonyDTO(Harmony harmony) {
return TaskResponseDTO.HarmonyDTO.builder()
.harmonyId(harmony.getId())
.musicId(harmony.getMusic().getId())
.musicTitle(harmony.getMusic().getTitle())
.createdAt(harmony.getCreatedAt())
.scale(harmony.getScale())
.genre(harmony.getGenre())
.bpm(harmony.getBpm())
.voiceColor(harmony.getVoiceColor())
.build();
}
public TaskResponseDTO.TrackDTO toTrackDTO(Track track) {
return TaskResponseDTO.TrackDTO.builder()
.trackId(track.getId())
.musicId(track.getMusic().getId())
.musicTitle(track.getMusic().getTitle())
.createdAt(track.getCreatedAt())
.vocalUrl(track.getVocalUrl())
.instrumentalUrl(track.getInstrumentalUrl())
.bassUrl(track.getBassUrl())
.drumsUrl(track.getDrumsUrl())
.build();
}
public TaskResponseDTO.RemixDTO toRemixDTO(Remix remix) {
return TaskResponseDTO.RemixDTO.builder()
.remixId(remix.getId())
.musicId(remix.getMusic().getId())
.musicTitle(remix.getMusic().getTitle())
.createdAt(remix.getCreatedAt())
.scaleModulation(remix.getScaleModulation())
.tempoRatio(remix.getTempoRatio())
.reverbAmount(remix.getReverbAmount())
.isCorusOn(remix.getIsChorusOn())
.resultMusicUrl(remix.getResultMusicUrl())
.parentRemixId(
remix.getParentRemix() != null
? remix.getParentRemix().getId()
: null) // 부모 Remix ID
.childRemixList(
remix.getChildRemixList() != null
? remix.getChildRemixList().stream()
.map(this::toRemixDTO)
.collect(Collectors.toList())
: new ArrayList<>()) // 자식 Remix 리스트
.build();
}
}