Skip to content

Commit

Permalink
Merge pull request #28 from Likelion-YeungNam-Univ/feat/#23-playlist-tag
Browse files Browse the repository at this point in the history
Feat/#23 playlist tag
  • Loading branch information
jjjjjinseo authored Jul 29, 2024
2 parents 959eedd + 7e1b5c5 commit e6a3858
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Getter
Expand All @@ -20,20 +22,32 @@ public class PlaylistDto {
private Boolean isCompleted;
private LocalDateTime createdAt;
private Long userId;
private List<TagDto> tags;
private List<SimpleVideoDto> videos;


@Builder
public PlaylistDto(Long id, String title, String totalTime, Boolean isCompleted, LocalDateTime createdAt, Long userId, List<SimpleVideoDto> videos) {
public PlaylistDto(Long id, String title, String totalTime, Boolean isCompleted, LocalDateTime createdAt, Long userId, List<SimpleVideoDto> videos, List<TagDto> tags) {
this.id = id;
this.title = title;
this.totalTime = totalTime;
this.isCompleted = isCompleted;
this.createdAt = createdAt;
this.userId = userId;
this.videos = videos;
this.tags = tags;
}

public static PlaylistDto fromEntity(Playlist playlist) {
Set<String> excludedWords = Set.of("운동", "집중공략", "플리");
String titleWithoutExcludedWords = Arrays.stream(playlist.getTitle().split(" "))
.filter(word -> !excludedWords.contains(word))
.collect(Collectors.joining(" "));

List<TagDto> tags = Arrays.stream(titleWithoutExcludedWords.split(" "))
.map(TagDto::new)
.collect(Collectors.toList());

return PlaylistDto.builder()
.id(playlist.getId())
.title(playlist.getTitle())
Expand All @@ -44,6 +58,7 @@ public static PlaylistDto fromEntity(Playlist playlist) {
.videos(playlist.getVideos().stream()
.map(SimpleVideoDto::fromEntity)
.collect(Collectors.toList()))
.tags(tags)
.build();
}
}
14 changes: 14 additions & 0 deletions src/main/java/com/example/beginnerfitbe/playlist/dto/TagDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.beginnerfitbe.playlist.dto;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class TagDto {
private String tag;
public TagDto(String tag) {
this.tag = tag;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.beginnerfitbe.playlist.domain.Playlist;
import com.example.beginnerfitbe.playlist.dto.PlaylistDto;
import com.example.beginnerfitbe.playlist.dto.TagDto;
import com.example.beginnerfitbe.playlist.repository.PlaylistRepository;
import com.example.beginnerfitbe.user.dto.UserDto;
import com.example.beginnerfitbe.youtube.dto.SelectedVideoDto;
Expand All @@ -21,6 +22,7 @@
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
Expand All @@ -43,7 +45,7 @@ public PlaylistDto create(User user) throws IOException {
SelectedVideoDto selectVideoDto = youtubeUtil.selectVideos(query, requestTime);

Playlist playlist = Playlist.builder()
.title(query + " 집중 공략하기 플리")
.title(query + " 집중공략 플리")
.createdAt(LocalDateTime.now())
.isCompleted(false)
.totalTime(selectVideoDto.getTotalTime())
Expand All @@ -54,6 +56,7 @@ public PlaylistDto create(User user) throws IOException {
playlist = playlistRepository.save(playlist);

youtubeVideoService.create(selectVideoDto, playlist);

return PlaylistDto.fromEntity(playlist);
}

Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ spring:
redis:
host: localhost
port: 6379
timeout: 6000ms
lettuce:
pool:
max-active: 50
max-idle: 30
min-idle: 10
max-wait: 10000ms
shutdown-timeout: 200ms

jwt:
secret: ${JWT_SECRET}
Expand Down

0 comments on commit e6a3858

Please sign in to comment.