From 37523e45871c1aacc0e526dcaaba25f9cbf4ca1b Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 01:23:31 +0900 Subject: [PATCH 01/12] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20::=20[#512]=20v3.?= =?UTF-8?q?0=20api=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSource/RemoteChartDataSource.swift | 2 +- .../Interface/Entity/ChartRankingEntity.swift | 7 +-- .../Interface/Enum/ChartDateType.swift | 18 +++--- .../Repository/ChartRepository.swift | 2 +- .../UseCase/FetchChartRankingUseCase.swift | 2 +- .../ChartDomain/Sources/API/ChartAPI.swift | 13 ++-- .../RemoteChartDataSourceImpl.swift | 4 +- .../Repository/ChartRepositoryImpl.swift | 7 +-- .../FetchChartRankingResponseDTO.swift | 61 +++++-------------- .../FetchChartRankingUseCaseImpl.swift | 4 +- .../ViewModels/ChartContentViewModel.swift | 11 ++-- .../Views/ChartContentTableViewCell.swift | 4 +- 12 files changed, 46 insertions(+), 89 deletions(-) diff --git a/Projects/Domains/ChartDomain/Interface/DataSource/RemoteChartDataSource.swift b/Projects/Domains/ChartDomain/Interface/DataSource/RemoteChartDataSource.swift index a1d10c4c7..b2ba8db74 100644 --- a/Projects/Domains/ChartDomain/Interface/DataSource/RemoteChartDataSource.swift +++ b/Projects/Domains/ChartDomain/Interface/DataSource/RemoteChartDataSource.swift @@ -2,6 +2,6 @@ import Foundation import RxSwift public protocol RemoteChartDataSource { - func fetchChartRanking(type: ChartDateType, limit: Int) -> Single<[ChartRankingEntity]> + func fetchChartRanking(type: ChartDateType) -> Single<[ChartRankingEntity]> func fetchChartUpdateTime(type: ChartDateType) -> Single } diff --git a/Projects/Domains/ChartDomain/Interface/Entity/ChartRankingEntity.swift b/Projects/Domains/ChartDomain/Interface/Entity/ChartRankingEntity.swift index d91960a55..2644f2ef4 100644 --- a/Projects/Domains/ChartDomain/Interface/Entity/ChartRankingEntity.swift +++ b/Projects/Domains/ChartDomain/Interface/Entity/ChartRankingEntity.swift @@ -5,8 +5,6 @@ public struct ChartRankingEntity: Equatable { id: String, title: String, artist: String, - remix: String, - reaction: String, views: Int, last: Int, increase: Int, @@ -16,8 +14,6 @@ public struct ChartRankingEntity: Equatable { self.id = id self.title = title self.artist = artist - self.remix = remix - self.reaction = reaction self.views = views self.last = last self.increase = increase @@ -25,8 +21,7 @@ public struct ChartRankingEntity: Equatable { self.isSelected = isSelected } - public let id, title, artist, remix: String - public let reaction: String + public let id, title, artist: String public let views, last, increase: Int public let date: String public var isSelected: Bool diff --git a/Projects/Domains/ChartDomain/Interface/Enum/ChartDateType.swift b/Projects/Domains/ChartDomain/Interface/Enum/ChartDateType.swift index 1731a1187..3cbadd120 100644 --- a/Projects/Domains/ChartDomain/Interface/Enum/ChartDateType.swift +++ b/Projects/Domains/ChartDomain/Interface/Enum/ChartDateType.swift @@ -1,22 +1,22 @@ import Foundation public enum ChartDateType: String { - case monthly - case weekly - case daily case hourly + case daily + case weekly + case monthly case total public var display: String { switch self { - case .monthly: - return "월간순" - case .weekly: - return "주간순" - case .daily: - return "일간순" case .hourly: return "시간순" + case .daily: + return "일간순" + case .weekly: + return "주간순" + case .monthly: + return "월간순" case .total: return "누적순" } diff --git a/Projects/Domains/ChartDomain/Interface/Repository/ChartRepository.swift b/Projects/Domains/ChartDomain/Interface/Repository/ChartRepository.swift index f83980b44..1cf503904 100644 --- a/Projects/Domains/ChartDomain/Interface/Repository/ChartRepository.swift +++ b/Projects/Domains/ChartDomain/Interface/Repository/ChartRepository.swift @@ -2,6 +2,6 @@ import Foundation import RxSwift public protocol ChartRepository { - func fetchChartRanking(type: ChartDateType, limit: Int) -> Single<[ChartRankingEntity]> + func fetchChartRanking(type: ChartDateType) -> Single<[ChartRankingEntity]> func fetchChartUpdateTime(type: ChartDateType) -> Single } diff --git a/Projects/Domains/ChartDomain/Interface/UseCase/FetchChartRankingUseCase.swift b/Projects/Domains/ChartDomain/Interface/UseCase/FetchChartRankingUseCase.swift index ca20bec0b..1fba1024a 100644 --- a/Projects/Domains/ChartDomain/Interface/UseCase/FetchChartRankingUseCase.swift +++ b/Projects/Domains/ChartDomain/Interface/UseCase/FetchChartRankingUseCase.swift @@ -2,5 +2,5 @@ import Foundation import RxSwift public protocol FetchChartRankingUseCase { - func execute(type: ChartDateType, limit: Int) -> Single<[ChartRankingEntity]> + func execute(type: ChartDateType) -> Single<[ChartRankingEntity]> } diff --git a/Projects/Domains/ChartDomain/Sources/API/ChartAPI.swift b/Projects/Domains/ChartDomain/Sources/API/ChartAPI.swift index 79f19aee1..ad186a345 100644 --- a/Projects/Domains/ChartDomain/Sources/API/ChartAPI.swift +++ b/Projects/Domains/ChartDomain/Sources/API/ChartAPI.swift @@ -5,7 +5,7 @@ import Foundation import Moya public enum ChartAPI { - case fetchChartRanking(type: ChartDateType, limit: Int) + case fetchChartRanking(type: ChartDateType) case fetchChartUpdateTime(type: ChartDateType) } @@ -16,8 +16,8 @@ extension ChartAPI: WMAPI { public var urlPath: String { switch self { - case .fetchChartRanking: - return "/" + case let .fetchChartRanking(type): + return "/\(type.rawValue)" case let .fetchChartUpdateTime(type): return "/updated/\(type.rawValue)" } @@ -29,11 +29,8 @@ extension ChartAPI: WMAPI { public var task: Moya.Task { switch self { - case let .fetchChartRanking(type, limit): - return .requestParameters(parameters: [ - "type": type.rawValue, - "limit": limit - ], encoding: URLEncoding.queryString) + case .fetchChartRanking: + return .requestPlain case .fetchChartUpdateTime: return .requestPlain diff --git a/Projects/Domains/ChartDomain/Sources/DataSource/RemoteChartDataSourceImpl.swift b/Projects/Domains/ChartDomain/Sources/DataSource/RemoteChartDataSourceImpl.swift index 9b7f32431..a7bb57729 100644 --- a/Projects/Domains/ChartDomain/Sources/DataSource/RemoteChartDataSourceImpl.swift +++ b/Projects/Domains/ChartDomain/Sources/DataSource/RemoteChartDataSourceImpl.swift @@ -4,8 +4,8 @@ import Foundation import RxSwift public final class RemoteChartDataSourceImpl: BaseRemoteDataSource, RemoteChartDataSource { - public func fetchChartRanking(type: ChartDateType, limit: Int) -> Single<[ChartRankingEntity]> { - request(.fetchChartRanking(type: type, limit: limit)) + public func fetchChartRanking(type: ChartDateType) -> Single<[ChartRankingEntity]> { + request(.fetchChartRanking(type: type)) .map([SingleChartRankingResponseDTO].self) .map { $0.map { $0.toDomain(type: type) } } } diff --git a/Projects/Domains/ChartDomain/Sources/Repository/ChartRepositoryImpl.swift b/Projects/Domains/ChartDomain/Sources/Repository/ChartRepositoryImpl.swift index d2a82a3e2..e5bdb6467 100644 --- a/Projects/Domains/ChartDomain/Sources/Repository/ChartRepositoryImpl.swift +++ b/Projects/Domains/ChartDomain/Sources/Repository/ChartRepositoryImpl.swift @@ -11,11 +11,8 @@ public final class ChartRepositoryImpl: ChartRepository { self.remoteChartDataSource = remoteChartDataSource } - public func fetchChartRanking( - type: ChartDateType, - limit: Int - ) -> Single<[ChartRankingEntity]> { - remoteChartDataSource.fetchChartRanking(type: type, limit: limit) + public func fetchChartRanking(type: ChartDateType) -> Single<[ChartRankingEntity]> { + remoteChartDataSource.fetchChartRanking(type: type) } public func fetchChartUpdateTime(type: ChartDateType) -> Single { diff --git a/Projects/Domains/ChartDomain/Sources/ResponseDTO/FetchChartRankingResponseDTO.swift b/Projects/Domains/ChartDomain/Sources/ResponseDTO/FetchChartRankingResponseDTO.swift index e0d7e9c56..5052a9801 100644 --- a/Projects/Domains/ChartDomain/Sources/ResponseDTO/FetchChartRankingResponseDTO.swift +++ b/Projects/Domains/ChartDomain/Sources/ResponseDTO/FetchChartRankingResponseDTO.swift @@ -3,65 +3,32 @@ import Foundation import Utility public struct SingleChartRankingResponseDTO: Decodable, Equatable { - public let id, title, artist, remix, reaction: String - public let date, start, end: Int - public let monthly, weekly, daily, hourly, total: SingleChartRankingResponseDTO.ChartInfo? + let songID, title: String + let artists: [String] + let date: Int + let last, increase, views: Int? public static func == (lhs: Self, rhs: Self) -> Bool { - return lhs.id == rhs.id + return lhs.songID == rhs.songID } enum CodingKeys: String, CodingKey { - case id = "songId" - case title, artist, remix, reaction, date, start, end - case monthly, weekly, daily, hourly, total - } -} - -public extension SingleChartRankingResponseDTO { - struct ChartInfo: Codable { - public let views, last: Int - public let increase: Int? + case songID = "videoId" + case title, artists, views, date + case last = "previousOrder" + case increase = "viewsIncrement" } } public extension SingleChartRankingResponseDTO { func toDomain(type: ChartDateType) -> ChartRankingEntity { - var views: Int = 0 - var last: Int = 0 - var increase: Int = 0 - switch type { - case .monthly: - views = monthly?.views ?? 0 - last = monthly?.last ?? 0 - increase = monthly?.increase ?? 0 - case .weekly: - views = weekly?.views ?? 0 - last = weekly?.last ?? 0 - increase = weekly?.increase ?? 0 - case .daily: - views = daily?.views ?? 0 - last = daily?.last ?? 0 - increase = daily?.increase ?? 0 - case .hourly: - views = hourly?.views ?? 0 - last = hourly?.last ?? 0 - increase = hourly?.increase ?? 0 - case .total: - views = total?.views ?? 0 - last = total?.last ?? 0 - increase = total?.increase ?? 0 - } - return ChartRankingEntity( - id: id, + id: songID, title: title, - artist: artist, - remix: remix, - reaction: reaction, - views: views, - last: last, - increase: increase, + artist: artists.joined(separator: ", "), + views: views ?? 0, + last: last ?? 0, + increase: increase ?? 0, date: date.changeDateFormat(origin: "yyMMdd", result: "yyyy.MM.dd") ) } diff --git a/Projects/Domains/ChartDomain/Sources/UseCase/FetchChartRankingUseCaseImpl.swift b/Projects/Domains/ChartDomain/Sources/UseCase/FetchChartRankingUseCaseImpl.swift index 330e77460..97ab3ae0a 100644 --- a/Projects/Domains/ChartDomain/Sources/UseCase/FetchChartRankingUseCaseImpl.swift +++ b/Projects/Domains/ChartDomain/Sources/UseCase/FetchChartRankingUseCaseImpl.swift @@ -10,7 +10,7 @@ public struct FetchChartRankingUseCaseImpl: FetchChartRankingUseCase { self.chartRepository = chartRepository } - public func execute(type: ChartDateType, limit: Int) -> Single<[ChartRankingEntity]> { - chartRepository.fetchChartRanking(type: type, limit: limit) + public func execute(type: ChartDateType) -> Single<[ChartRankingEntity]> { + chartRepository.fetchChartRanking(type: type) } } diff --git a/Projects/Features/ChartFeature/Sources/ViewModels/ChartContentViewModel.swift b/Projects/Features/ChartFeature/Sources/ViewModels/ChartContentViewModel.swift index 4334a83d7..d44fed2ef 100644 --- a/Projects/Features/ChartFeature/Sources/ViewModels/ChartContentViewModel.swift +++ b/Projects/Features/ChartFeature/Sources/ViewModels/ChartContentViewModel.swift @@ -47,7 +47,8 @@ public final class ChartContentViewModel: ViewModelType { .catchAndReturn("팬치들 미안해요 ㅠㅠ 잠시만 기다려주세요") // 이스터에그 🥰 .asObservable(), fetchChartRankingUseCase - .execute(type: type, limit: 100) + .execute(type: type) + .debug("fetchChartRankingUseCase") .catchAndReturn([]) .asObservable() ) @@ -119,8 +120,8 @@ public final class ChartContentViewModel: ViewModelType { id: dataSource[$0].id, title: dataSource[$0].title, artist: dataSource[$0].artist, - remix: dataSource[$0].remix, - reaction: dataSource[$0].reaction, + remix: "", + reaction: "", views: dataSource[$0].views, last: dataSource[$0].last, date: dataSource[$0].date @@ -138,8 +139,8 @@ public final class ChartContentViewModel: ViewModelType { id: $0.id, title: $0.title, artist: $0.artist, - remix: $0.remix, - reaction: $0.reaction, + remix: "", + reaction: "", views: $0.views, last: $0.last, date: $0.date diff --git a/Projects/Features/ChartFeature/Sources/Views/ChartContentTableViewCell.swift b/Projects/Features/ChartFeature/Sources/Views/ChartContentTableViewCell.swift index b20d5f4c7..88df47a81 100644 --- a/Projects/Features/ChartFeature/Sources/Views/ChartContentTableViewCell.swift +++ b/Projects/Features/ChartFeature/Sources/Views/ChartContentTableViewCell.swift @@ -339,8 +339,8 @@ extension ChartContentTableViewCell { id: song.id, title: song.title, artist: song.artist, - remix: song.remix, - reaction: song.reaction, + remix: "", + reaction: "", views: song.views, last: song.last, date: song.date From 067af09eec5951a548b9664e1bccbaa9574db6ac Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 01:41:02 +0900 Subject: [PATCH 02/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#512]=20?= =?UTF-8?q?=EB=A9=8D=EC=B2=AD=ED=95=9C=20=EC=97=91=EC=8A=A4=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ViewControllers/HomeViewController.swift | 5 +++-- .../HomeFeature/Sources/ViewModels/HomeViewModel.swift | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/ViewControllers/HomeViewController.swift b/Projects/Features/HomeFeature/Sources/ViewControllers/HomeViewController.swift index 469727a89..77f174be9 100644 --- a/Projects/Features/HomeFeature/Sources/ViewControllers/HomeViewController.swift +++ b/Projects/Features/HomeFeature/Sources/ViewControllers/HomeViewController.swift @@ -1,4 +1,5 @@ import BaseFeature +import ChartDomainInterface import DesignSystem import NVActivityIndicatorView import PanModal @@ -125,8 +126,8 @@ extension HomeViewController { id: $0.1[$0.0.row].id, title: $0.1[$0.0.row].title, artist: $0.1[$0.0.row].artist, - remix: $0.1[$0.0.row].remix, - reaction: $0.1[$0.0.row].reaction, + remix: "", + reaction: "", views: $0.1[$0.0.row].views, last: $0.1[$0.0.row].last, date: $0.1[$0.0.row].date diff --git a/Projects/Features/HomeFeature/Sources/ViewModels/HomeViewModel.swift b/Projects/Features/HomeFeature/Sources/ViewModels/HomeViewModel.swift index dc27ec1a6..9b1eb8f5f 100644 --- a/Projects/Features/HomeFeature/Sources/ViewModels/HomeViewModel.swift +++ b/Projects/Features/HomeFeature/Sources/ViewModels/HomeViewModel.swift @@ -50,7 +50,7 @@ public final class HomeViewModel: ViewModelType { let playListDataSource: BehaviorRelay<[RecommendPlayListEntity]> = BehaviorRelay(value: []) let chart = self.fetchChartRankingUseCase - .execute(type: .hourly, limit: 100) + .execute(type: .hourly) .catchAndReturn([]) .asObservable() @@ -91,8 +91,8 @@ public final class HomeViewModel: ViewModelType { id: $0.id, title: $0.title, artist: $0.artist, - remix: $0.remix, - reaction: $0.reaction, + remix: "", + reaction: "", views: $0.views, last: $0.last, date: $0.date From 0b60c3212e8e0d698c5a379f49b8493ff7002fe5 Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 01:44:05 +0900 Subject: [PATCH 03/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#512]=20?= =?UTF-8?q?=EB=A6=B0=ED=8A=B8=20=EA=B2=BD=EA=B3=A0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ViewControllers/NewSongsContentViewController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Projects/Features/HomeFeature/Sources/ViewControllers/NewSongsContentViewController.swift b/Projects/Features/HomeFeature/Sources/ViewControllers/NewSongsContentViewController.swift index f28fa0497..7f141645c 100644 --- a/Projects/Features/HomeFeature/Sources/ViewControllers/NewSongsContentViewController.swift +++ b/Projects/Features/HomeFeature/Sources/ViewControllers/NewSongsContentViewController.swift @@ -1,4 +1,3 @@ - import BaseFeature import BaseFeatureInterface import DesignSystem From ddc83f22247a08a274f5abf9878a90c2d6f8bb79 Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 02:15:03 +0900 Subject: [PATCH 04/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#507]=20Single?= =?UTF-8?q?SongResponseDTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResponseDTO/SingleSongResponseDTO.swift | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SingleSongResponseDTO.swift b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SingleSongResponseDTO.swift index 2966eef6b..5f9c20a25 100644 --- a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SingleSongResponseDTO.swift +++ b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SingleSongResponseDTO.swift @@ -11,33 +11,26 @@ import SongsDomainInterface import Utility public struct SingleSongResponseDTO: Decodable { - public let id, title, artist, remix, reaction: String - public let date, start, end: Int - public let total: SingleSongResponseDTO.Total? + let songID, title: String + let artists: [String] + let date, views, likes: Int enum CodingKeys: String, CodingKey { - case title, artist, remix, reaction, date, start, end, total - case id = "songId" - } -} - -public extension SingleSongResponseDTO { - struct Total: Decodable { - public let views, last: Int - public let increase: Int? + case title, artists, date, views, likes + case songID = "videoId" } } public extension SingleSongResponseDTO { func toDomain() -> SongEntity { - SongEntity( - id: id, + return SongEntity( + id: songID, title: title, - artist: artist, - remix: remix, - reaction: reaction, - views: total?.views ?? 0, - last: total?.last ?? 0, + artist: artists.joined(separator: ", "), + remix: "", + reaction: "", + views: views, + last: 0, date: date.changeDateFormat(origin: "yyMMdd", result: "yyyy.MM.dd") ) } From 698b928cee9d9788593cbdfbd77b1d010e339fcc Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 02:25:57 +0900 Subject: [PATCH 05/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#507]=20Lyrics?= =?UTF-8?q?ResponseDTO,=20LyricsEntity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SongsDomain/Interface/Entity/LyricsEntity.swift | 13 ++----------- .../Domains/SongsDomain/Sources/API/SongsAPI.swift | 4 ++-- .../Sources/ResponseDTO/LyricsResponseDTO.swift | 11 ++--------- .../Sources/ViewModels/PlayerViewModel+API.swift | 2 +- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/Projects/Domains/SongsDomain/Interface/Entity/LyricsEntity.swift b/Projects/Domains/SongsDomain/Interface/Entity/LyricsEntity.swift index d7c676c12..283b2291a 100644 --- a/Projects/Domains/SongsDomain/Interface/Entity/LyricsEntity.swift +++ b/Projects/Domains/SongsDomain/Interface/Entity/LyricsEntity.swift @@ -10,19 +10,10 @@ import Foundation public struct LyricsEntity: Equatable { public init( - identifier: String, - start: Double, - end: Double, - text: String, - styles: String + text: String ) { - self.identifier = identifier - self.start = start - self.end = end self.text = text - self.styles = styles } - public let identifier, text, styles: String - public let start, end: Double + public let text: String } diff --git a/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift b/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift index e6ab468af..6f43bd8fd 100644 --- a/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift +++ b/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift @@ -19,8 +19,8 @@ extension SongsAPI: WMAPI { switch self { case .fetchSearchSong: return "/search/all" - case let .fetchLyrics(id: id): - return "/lyrics/\(id)" + case let .fetchLyrics(id): + return "/\(id)/lyrics" case let .fetchNewSongs(type, _, _): return "/new/\(type.apiKey)" } diff --git a/Projects/Domains/SongsDomain/Sources/ResponseDTO/LyricsResponseDTO.swift b/Projects/Domains/SongsDomain/Sources/ResponseDTO/LyricsResponseDTO.swift index 3eb6a4e3b..6f7385c74 100644 --- a/Projects/Domains/SongsDomain/Sources/ResponseDTO/LyricsResponseDTO.swift +++ b/Projects/Domains/SongsDomain/Sources/ResponseDTO/LyricsResponseDTO.swift @@ -10,18 +10,11 @@ import Foundation import SongsDomainInterface public struct LyricsResponseDTO: Decodable { - public let identifier, text, styles: String - public let start, end: Double + let text: String } public extension LyricsResponseDTO { func toDomain() -> LyricsEntity { - LyricsEntity( - identifier: identifier, - start: start, - end: end, - text: text, - styles: styles - ) + return LyricsEntity(text: text) } } diff --git a/Projects/Features/PlayerFeature/Sources/ViewModels/PlayerViewModel+API.swift b/Projects/Features/PlayerFeature/Sources/ViewModels/PlayerViewModel+API.swift index cc3069794..50b81caf1 100644 --- a/Projects/Features/PlayerFeature/Sources/ViewModels/PlayerViewModel+API.swift +++ b/Projects/Features/PlayerFeature/Sources/ViewModels/PlayerViewModel+API.swift @@ -22,7 +22,7 @@ extension PlayerViewModel { guard let self else { return } self.lyricsDict.removeAll() self.sortedLyrics.removeAll() - lyricsEntityArray.forEach { self.lyricsDict.updateValue($0.text, forKey: Float($0.start)) } + lyricsEntityArray.forEach { self.lyricsDict.updateValue($0.text, forKey: Float(0)) } self.sortedLyrics = self.lyricsDict.sorted { $0.key < $1.key }.map { $0.value } } onFailure: { [weak self] error in guard let self else { return } From e8a1b2c7401f10bd61a8527e8d4d30cc119c57f4 Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 02:57:13 +0900 Subject: [PATCH 06/12] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20::=20[#507]=20SongCr?= =?UTF-8?q?editsResponseDTO,=20SongCreditsEntity,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlayListDetailResponseDTO.swift | 12 ++--- .../Interface/Entity/SongCreditsEntity.swift | 49 +++++++++++++++++++ .../SongsDomain/Sources/API/SongsAPI.swift | 5 +- .../ResponseDTO/SingleSongResponseDTO.swift | 6 +-- .../ResponseDTO/SongCreditsResponseDTO.swift | 38 ++++++++++++++ 5 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift create mode 100644 Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift diff --git a/Projects/Domains/PlayListDomain/Sources/ResponseDTO/PlayListDetailResponseDTO.swift b/Projects/Domains/PlayListDomain/Sources/ResponseDTO/PlayListDetailResponseDTO.swift index b2f66866e..e7152ef60 100644 --- a/Projects/Domains/PlayListDomain/Sources/ResponseDTO/PlayListDetailResponseDTO.swift +++ b/Projects/Domains/PlayListDomain/Sources/ResponseDTO/PlayListDetailResponseDTO.swift @@ -35,13 +35,13 @@ public extension SinglePlayListDetailResponseDTO { title: title, songs: (songs ?? []).map { dto in return SongEntity( - id: dto.id, + id: dto.songID, title: dto.title, - artist: dto.artist, - remix: dto.remix, - reaction: dto.reaction, - views: dto.total?.views ?? 0, - last: dto.total?.last ?? 0, + artist: dto.artists.joined(separator: ", "), + remix: "", + reaction: "", + views: dto.views, + last: 0, date: dto.date.changeDateFormat(origin: "yyMMdd", result: "yyyy.MM.dd") ) }, diff --git a/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift b/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift new file mode 100644 index 000000000..d8ae29680 --- /dev/null +++ b/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift @@ -0,0 +1,49 @@ +// +// SongCreditsEntity.swift +// SongsDomain +// +// Created by KTH on 5/14/24. +// Copyright © 2024 yongbeomkwak. All rights reserved. +// + +import Foundation + +public struct SongCreditsEntity { + init( + vocal: String, + featuring: String, + original: String, + producing: String, + lyrics: String, + relyrics: String, + compose: String, + arrange: String, + mixing: String, + mastering: String, + session: String, + chorus: String, + vocalGuide: String, + trainer: String + ) { + self.vocal = vocal + self.featuring = featuring + self.original = original + self.producing = producing + self.lyrics = lyrics + self.relyrics = relyrics + self.compose = compose + self.arrange = arrange + self.mixing = mixing + self.mastering = mastering + self.session = session + self.chorus = chorus + self.vocalGuide = vocalGuide + self.trainer = trainer + } + + public let vocal, featuring: String + public let original: String + public let producing, lyrics, relyrics, compose: String + public let arrange, mixing, mastering, session: String + public let chorus, vocalGuide, trainer: String +} diff --git a/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift b/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift index 6f43bd8fd..b83a0f8d4 100644 --- a/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift +++ b/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift @@ -7,6 +7,7 @@ import SongsDomainInterface public enum SongsAPI { case fetchSearchSong(keyword: String) case fetchLyrics(id: String) + case fetchCredits(id: String) case fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) } @@ -21,6 +22,8 @@ extension SongsAPI: WMAPI { return "/search/all" case let .fetchLyrics(id): return "/\(id)/lyrics" + case let .fetchCredits(id): + return "/\(id)/credits" case let .fetchNewSongs(type, _, _): return "/new/\(type.apiKey)" } @@ -38,7 +41,7 @@ extension SongsAPI: WMAPI { "keyword": keyword ], encoding: URLEncoding.queryString) - case .fetchLyrics: + case .fetchLyrics, .fetchCredits: return .requestPlain case let .fetchNewSongs(_, page, limit): diff --git a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SingleSongResponseDTO.swift b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SingleSongResponseDTO.swift index 5f9c20a25..5088d85aa 100644 --- a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SingleSongResponseDTO.swift +++ b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SingleSongResponseDTO.swift @@ -11,9 +11,9 @@ import SongsDomainInterface import Utility public struct SingleSongResponseDTO: Decodable { - let songID, title: String - let artists: [String] - let date, views, likes: Int + public let songID, title: String + public let artists: [String] + public let date, views, likes: Int enum CodingKeys: String, CodingKey { case title, artists, date, views, likes diff --git a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift new file mode 100644 index 000000000..4f0e413d2 --- /dev/null +++ b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift @@ -0,0 +1,38 @@ +// +// FetchSongCreditsResponseDTO.swift +// SongsDomain +// +// Created by KTH on 5/14/24. +// Copyright © 2024 yongbeomkwak. All rights reserved. +// + +import Foundation + +public struct SongCreditsResponseDTO: Decodable { + let vocal, featuring: [String]? + let original: String? + let producing, lyrics, relyrics, compose: [String]? + let arrange, mixing, mastering, session: [String]? + let chorus, vocalGuide, trainer: [String]? +} + +public extension SongCreditsResponseDTO { + func toDomain() -> SongCreditsEntity { + return SongCreditsEntity( + vocal: (vocal ?? []).joined(separator: ", "), + featuring: (featuring ?? []).joined(separator: ", "), + original: original ?? "", + producing: (producing ?? []).joined(separator: ", "), + lyrics: (lyrics ?? []).joined(separator: ", "), + relyrics: (relyrics ?? []).joined(separator: ", "), + compose: (compose ?? []).joined(separator: ", "), + arrange: (arrange ?? []).joined(separator: ", "), + mixing: (mixing ?? []).joined(separator: ", "), + mastering: (mastering ?? []).joined(separator: ", "), + session: (session ?? []).joined(separator: ", "), + chorus: (chorus ?? []).joined(separator: ", "), + vocalGuide: (vocalGuide ?? []).joined(separator: ", "), + trainer: (trainer ?? []).joined(separator: ", ") + ) + } +} From 1f4d2d0e5eed36de7b28e40030edbcbd038468d2 Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 03:09:23 +0900 Subject: [PATCH 07/12] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20::=20[#507]=20FetchS?= =?UTF-8?q?ongCreditsUseCase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSource/RemoteSongsDataSource.swift | 1 + .../Interface/Entity/SongCreditsEntity.swift | 2 +- .../Repository/SongsRepository.swift | 1 + .../UseCase/FetchSongCreditsUseCase.swift | 14 +++++++++++ .../RemoteSongsDataSourceImpl.swift | 6 +++++ .../Repository/SongsRepositoryImpl.swift | 4 ++++ .../ResponseDTO/SongCreditsResponseDTO.swift | 1 + .../UseCase/FetchSongCreditsUseCaseImpl.swift | 24 +++++++++++++++++++ 8 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 Projects/Domains/SongsDomain/Interface/UseCase/FetchSongCreditsUseCase.swift create mode 100644 Projects/Domains/SongsDomain/Sources/UseCase/FetchSongCreditsUseCaseImpl.swift diff --git a/Projects/Domains/SongsDomain/Interface/DataSource/RemoteSongsDataSource.swift b/Projects/Domains/SongsDomain/Interface/DataSource/RemoteSongsDataSource.swift index 0d7cd1f38..ed5f99f75 100644 --- a/Projects/Domains/SongsDomain/Interface/DataSource/RemoteSongsDataSource.swift +++ b/Projects/Domains/SongsDomain/Interface/DataSource/RemoteSongsDataSource.swift @@ -4,5 +4,6 @@ import RxSwift public protocol RemoteSongsDataSource { func fetchSearchSong(keyword: String) -> Single func fetchLyrics(id: String) -> Single<[LyricsEntity]> + func fetchSongCredits(id: String) -> Single func fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) -> Single<[NewSongsEntity]> } diff --git a/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift b/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift index d8ae29680..587e4b68a 100644 --- a/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift +++ b/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift @@ -9,7 +9,7 @@ import Foundation public struct SongCreditsEntity { - init( + public init( vocal: String, featuring: String, original: String, diff --git a/Projects/Domains/SongsDomain/Interface/Repository/SongsRepository.swift b/Projects/Domains/SongsDomain/Interface/Repository/SongsRepository.swift index 24f1ab859..dbf017397 100644 --- a/Projects/Domains/SongsDomain/Interface/Repository/SongsRepository.swift +++ b/Projects/Domains/SongsDomain/Interface/Repository/SongsRepository.swift @@ -4,5 +4,6 @@ import RxSwift public protocol SongsRepository { func fetchSearchSong(keyword: String) -> Single func fetchLyrics(id: String) -> Single<[LyricsEntity]> + func fetchSongCredits(id: String) -> Single func fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) -> Single<[NewSongsEntity]> } diff --git a/Projects/Domains/SongsDomain/Interface/UseCase/FetchSongCreditsUseCase.swift b/Projects/Domains/SongsDomain/Interface/UseCase/FetchSongCreditsUseCase.swift new file mode 100644 index 000000000..5e09c657e --- /dev/null +++ b/Projects/Domains/SongsDomain/Interface/UseCase/FetchSongCreditsUseCase.swift @@ -0,0 +1,14 @@ +// +// FetchSongCreditsUseCase.swift +// SongsDomain +// +// Created by KTH on 5/14/24. +// Copyright © 2024 yongbeomkwak. All rights reserved. +// + +import Foundation +import RxSwift + +public protocol FetchSongCreditsUseCase { + func execute(id: String) -> Single +} diff --git a/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift b/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift index fb21cc1be..3dcdc2785 100644 --- a/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift +++ b/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift @@ -15,6 +15,12 @@ public final class RemoteSongsDataSourceImpl: BaseRemoteDataSource, Re .map([LyricsResponseDTO].self) .map { $0.map { $0.toDomain() }} } + + public func fetchSongCredits(id: String) -> Single { + request(.fetchCredits(id: id)) + .map(SongCreditsResponseDTO.self) + .map { $0.toDomain() } + } public func fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) -> Single<[NewSongsEntity]> { request(.fetchNewSongs(type: type, page: page, limit: limit)) diff --git a/Projects/Domains/SongsDomain/Sources/Repository/SongsRepositoryImpl.swift b/Projects/Domains/SongsDomain/Sources/Repository/SongsRepositoryImpl.swift index b0699057f..fbe5e0bbf 100644 --- a/Projects/Domains/SongsDomain/Sources/Repository/SongsRepositoryImpl.swift +++ b/Projects/Domains/SongsDomain/Sources/Repository/SongsRepositoryImpl.swift @@ -18,6 +18,10 @@ public final class SongsRepositoryImpl: SongsRepository { remoteSongsDataSource.fetchLyrics(id: id) } + public func fetchSongCredits(id: String) -> Single { + remoteSongsDataSource.fetchSongCredits(id: id) + } + public func fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) -> Single<[NewSongsEntity]> { remoteSongsDataSource.fetchNewSongs(type: type, page: page, limit: limit) } diff --git a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift index 4f0e413d2..c9a4a2f12 100644 --- a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift +++ b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift @@ -7,6 +7,7 @@ // import Foundation +import SongsDomainInterface public struct SongCreditsResponseDTO: Decodable { let vocal, featuring: [String]? diff --git a/Projects/Domains/SongsDomain/Sources/UseCase/FetchSongCreditsUseCaseImpl.swift b/Projects/Domains/SongsDomain/Sources/UseCase/FetchSongCreditsUseCaseImpl.swift new file mode 100644 index 000000000..3133895f6 --- /dev/null +++ b/Projects/Domains/SongsDomain/Sources/UseCase/FetchSongCreditsUseCaseImpl.swift @@ -0,0 +1,24 @@ +// +// FetchSongCreditsUseCaseImpl.swift +// SongsDomain +// +// Created by KTH on 5/14/24. +// Copyright © 2024 yongbeomkwak. All rights reserved. +// + +import RxSwift +import SongsDomainInterface + +public struct FetchSongCreditsUseCaseImpl: FetchSongCreditsUseCase { + private let songsRepository: any SongsRepository + + public init( + songsRepository: SongsRepository + ) { + self.songsRepository = songsRepository + } + + public func execute(id: String) -> RxSwift.Single { + songsRepository.fetchSongCredits(id: id) + } +} From fbb06d0239cdd3525881f616ca5ac0e4e97247e8 Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 03:11:23 +0900 Subject: [PATCH 08/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#507]=20?= =?UTF-8?q?=EB=A6=B0=ED=8A=B8=20=EA=B2=BD=EA=B3=A0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/DataSource/RemoteSongsDataSourceImpl.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift b/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift index 3dcdc2785..317d57b49 100644 --- a/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift +++ b/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift @@ -15,7 +15,7 @@ public final class RemoteSongsDataSourceImpl: BaseRemoteDataSource, Re .map([LyricsResponseDTO].self) .map { $0.map { $0.toDomain() }} } - + public func fetchSongCredits(id: String) -> Single { request(.fetchCredits(id: id)) .map(SongCreditsResponseDTO.self) From c548473fb5bd6e77a6741ddaa263d0eee39b781a Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 03:17:54 +0900 Subject: [PATCH 09/12] =?UTF-8?q?=F0=9F=94=A5=20::=20[#507]=20FetchSearchS?= =?UTF-8?q?ongUseCase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/AppComponent+Songs.swift | 6 ---- .../Sources/Application/NeedleGenerated.swift | 5 ---- .../DataSource/RemoteSongsDataSource.swift | 1 - .../Repository/SongsRepository.swift | 1 - .../UseCase/FetchSeachSongUseCase.swift | 6 ---- .../SongsDomain/Sources/API/SongsAPI.swift | 9 ------ .../RemoteSongsDataSourceImpl.swift | 6 ---- .../Repository/SongsRepositoryImpl.swift | 4 --- .../ResponseDTO/SearchResultResponseDTO.swift | 28 ------------------- .../UseCase/FetchSearchSongUseCaseImpl.swift | 16 ----------- .../Components/AfterSearchComponent.swift | 3 +- .../Sources/Reactors/AfterSearchReactor.swift | 7 ++--- .../ViewModels/AfterSearchViewModel.swift | 7 ++--- 13 files changed, 5 insertions(+), 94 deletions(-) delete mode 100644 Projects/Domains/SongsDomain/Interface/UseCase/FetchSeachSongUseCase.swift delete mode 100644 Projects/Domains/SongsDomain/Sources/ResponseDTO/SearchResultResponseDTO.swift delete mode 100644 Projects/Domains/SongsDomain/Sources/UseCase/FetchSearchSongUseCaseImpl.swift diff --git a/Projects/App/Sources/Application/AppComponent+Songs.swift b/Projects/App/Sources/Application/AppComponent+Songs.swift index fd69502b6..1bba26c0a 100644 --- a/Projects/App/Sources/Application/AppComponent+Songs.swift +++ b/Projects/App/Sources/Application/AppComponent+Songs.swift @@ -28,12 +28,6 @@ public extension AppComponent { } } - var fetchSearchSongUseCase: any FetchSearchSongUseCase { - shared { - FetchSearchSongUseCaseImpl(songsRepository: songsRepository) - } - } - var fetchLyricsUseCase: any FetchLyricsUseCase { shared { FetchLyricsUseCaseImpl(songsRepository: songsRepository) diff --git a/Projects/App/Sources/Application/NeedleGenerated.swift b/Projects/App/Sources/Application/NeedleGenerated.swift index 20314defc..2c352901b 100644 --- a/Projects/App/Sources/Application/NeedleGenerated.swift +++ b/Projects/App/Sources/Application/NeedleGenerated.swift @@ -672,9 +672,6 @@ private class AfterSearchDependency61822c19bc2eb46d7c52Provider: AfterSearchDepe var afterSearchContentComponent: AfterSearchContentComponent { return appComponent.afterSearchContentComponent } - var fetchSearchSongUseCase: any FetchSearchSongUseCase { - return appComponent.fetchSearchSongUseCase - } var containSongsFactory: any ContainSongsFactory { return appComponent.containSongsFactory } @@ -794,7 +791,6 @@ extension AppComponent: Registration { localTable["newSongsContentComponent-NewSongsContentComponent"] = { self.newSongsContentComponent as Any } localTable["remoteSongsDataSource-any RemoteSongsDataSource"] = { self.remoteSongsDataSource as Any } localTable["songsRepository-any SongsRepository"] = { self.songsRepository as Any } - localTable["fetchSearchSongUseCase-any FetchSearchSongUseCase"] = { self.fetchSearchSongUseCase as Any } localTable["fetchLyricsUseCase-any FetchLyricsUseCase"] = { self.fetchLyricsUseCase as Any } localTable["fetchNewSongsUseCase-any FetchNewSongsUseCase"] = { self.fetchNewSongsUseCase as Any } localTable["signInFactory-any SignInFactory"] = { self.signInFactory as Any } @@ -1120,7 +1116,6 @@ extension NewSongsContentComponent: Registration { extension AfterSearchComponent: Registration { public func registerItems() { keyPathToName[\AfterSearchDependency.afterSearchContentComponent] = "afterSearchContentComponent-AfterSearchContentComponent" - keyPathToName[\AfterSearchDependency.fetchSearchSongUseCase] = "fetchSearchSongUseCase-any FetchSearchSongUseCase" keyPathToName[\AfterSearchDependency.containSongsFactory] = "containSongsFactory-any ContainSongsFactory" } } diff --git a/Projects/Domains/SongsDomain/Interface/DataSource/RemoteSongsDataSource.swift b/Projects/Domains/SongsDomain/Interface/DataSource/RemoteSongsDataSource.swift index ed5f99f75..ab6070c6a 100644 --- a/Projects/Domains/SongsDomain/Interface/DataSource/RemoteSongsDataSource.swift +++ b/Projects/Domains/SongsDomain/Interface/DataSource/RemoteSongsDataSource.swift @@ -2,7 +2,6 @@ import Foundation import RxSwift public protocol RemoteSongsDataSource { - func fetchSearchSong(keyword: String) -> Single func fetchLyrics(id: String) -> Single<[LyricsEntity]> func fetchSongCredits(id: String) -> Single func fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) -> Single<[NewSongsEntity]> diff --git a/Projects/Domains/SongsDomain/Interface/Repository/SongsRepository.swift b/Projects/Domains/SongsDomain/Interface/Repository/SongsRepository.swift index dbf017397..02d1b8b02 100644 --- a/Projects/Domains/SongsDomain/Interface/Repository/SongsRepository.swift +++ b/Projects/Domains/SongsDomain/Interface/Repository/SongsRepository.swift @@ -2,7 +2,6 @@ import Foundation import RxSwift public protocol SongsRepository { - func fetchSearchSong(keyword: String) -> Single func fetchLyrics(id: String) -> Single<[LyricsEntity]> func fetchSongCredits(id: String) -> Single func fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) -> Single<[NewSongsEntity]> diff --git a/Projects/Domains/SongsDomain/Interface/UseCase/FetchSeachSongUseCase.swift b/Projects/Domains/SongsDomain/Interface/UseCase/FetchSeachSongUseCase.swift deleted file mode 100644 index 38647e62a..000000000 --- a/Projects/Domains/SongsDomain/Interface/UseCase/FetchSeachSongUseCase.swift +++ /dev/null @@ -1,6 +0,0 @@ -import Foundation -import RxSwift - -public protocol FetchSearchSongUseCase { - func execute(keyword: String) -> Single -} diff --git a/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift b/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift index b83a0f8d4..58728b945 100644 --- a/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift +++ b/Projects/Domains/SongsDomain/Sources/API/SongsAPI.swift @@ -5,7 +5,6 @@ import Moya import SongsDomainInterface public enum SongsAPI { - case fetchSearchSong(keyword: String) case fetchLyrics(id: String) case fetchCredits(id: String) case fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) @@ -18,8 +17,6 @@ extension SongsAPI: WMAPI { public var urlPath: String { switch self { - case .fetchSearchSong: - return "/search/all" case let .fetchLyrics(id): return "/\(id)/lyrics" case let .fetchCredits(id): @@ -35,12 +32,6 @@ extension SongsAPI: WMAPI { public var task: Moya.Task { switch self { - case let .fetchSearchSong(keyword): - return .requestParameters(parameters: [ - "sort": "popular", // 기본 인기순으로 - "keyword": keyword - ], encoding: URLEncoding.queryString) - case .fetchLyrics, .fetchCredits: return .requestPlain diff --git a/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift b/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift index 317d57b49..ab618e9c3 100644 --- a/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift +++ b/Projects/Domains/SongsDomain/Sources/DataSource/RemoteSongsDataSourceImpl.swift @@ -4,12 +4,6 @@ import RxSwift import SongsDomainInterface public final class RemoteSongsDataSourceImpl: BaseRemoteDataSource, RemoteSongsDataSource { - public func fetchSearchSong(keyword: String) -> Single { - request(.fetchSearchSong(keyword: keyword)) - .map(SearchResultResponseDTO.self) - .map { $0.toDomain() } - } - public func fetchLyrics(id: String) -> Single<[LyricsEntity]> { request(.fetchLyrics(id: id)) .map([LyricsResponseDTO].self) diff --git a/Projects/Domains/SongsDomain/Sources/Repository/SongsRepositoryImpl.swift b/Projects/Domains/SongsDomain/Sources/Repository/SongsRepositoryImpl.swift index fbe5e0bbf..66bb5fc27 100644 --- a/Projects/Domains/SongsDomain/Sources/Repository/SongsRepositoryImpl.swift +++ b/Projects/Domains/SongsDomain/Sources/Repository/SongsRepositoryImpl.swift @@ -10,10 +10,6 @@ public final class SongsRepositoryImpl: SongsRepository { self.remoteSongsDataSource = remoteSongsDataSource } - public func fetchSearchSong(keyword: String) -> Single { - remoteSongsDataSource.fetchSearchSong(keyword: keyword) - } - public func fetchLyrics(id: String) -> Single<[LyricsEntity]> { remoteSongsDataSource.fetchLyrics(id: id) } diff --git a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SearchResultResponseDTO.swift b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SearchResultResponseDTO.swift deleted file mode 100644 index 06e22de38..000000000 --- a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SearchResultResponseDTO.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// SearchResultResponseDTO.swift -// DataMappingModule -// -// Created by yongbeomkwak on 12/9/23. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - -import Foundation -import SongsDomainInterface - -public struct SearchResultResponseDTO: Decodable { - public let song: [SingleSongResponseDTO] - public let artist: [SingleSongResponseDTO] - public let remix: [ - SingleSongResponseDTO - ] -} - -public extension SearchResultResponseDTO { - func toDomain() -> SearchResultEntity { - SearchResultEntity( - song: song.map { $0.toDomain() }, - artist: artist.map { $0.toDomain() }, - remix: remix.map { $0.toDomain() } - ) - } -} diff --git a/Projects/Domains/SongsDomain/Sources/UseCase/FetchSearchSongUseCaseImpl.swift b/Projects/Domains/SongsDomain/Sources/UseCase/FetchSearchSongUseCaseImpl.swift deleted file mode 100644 index d2b651dc5..000000000 --- a/Projects/Domains/SongsDomain/Sources/UseCase/FetchSearchSongUseCaseImpl.swift +++ /dev/null @@ -1,16 +0,0 @@ -import RxSwift -import SongsDomainInterface - -public struct FetchSearchSongUseCaseImpl: FetchSearchSongUseCase { - private let songsRepository: any SongsRepository - - public init( - songsRepository: SongsRepository - ) { - self.songsRepository = songsRepository - } - - public func execute(keyword: String) -> Single { - songsRepository.fetchSearchSong(keyword: keyword) - } -} diff --git a/Projects/Features/SearchFeature/Sources/Components/AfterSearchComponent.swift b/Projects/Features/SearchFeature/Sources/Components/AfterSearchComponent.swift index 91d3cb97d..c27f92c98 100644 --- a/Projects/Features/SearchFeature/Sources/Components/AfterSearchComponent.swift +++ b/Projects/Features/SearchFeature/Sources/Components/AfterSearchComponent.swift @@ -6,7 +6,6 @@ import SongsDomainInterface public protocol AfterSearchDependency: Dependency { var afterSearchContentComponent: AfterSearchContentComponent { get } - var fetchSearchSongUseCase: any FetchSearchSongUseCase { get } var containSongsFactory: any ContainSongsFactory { get } } @@ -15,7 +14,7 @@ public final class AfterSearchComponent: Component { return AfterSearchViewController.viewController( afterSearchContentComponent: dependency.afterSearchContentComponent, containSongsFactory: dependency.containSongsFactory, - reactor: .init(fetchSearchSongUseCase: dependency.fetchSearchSongUseCase) + reactor: .init() ) } } diff --git a/Projects/Features/SearchFeature/Sources/Reactors/AfterSearchReactor.swift b/Projects/Features/SearchFeature/Sources/Reactors/AfterSearchReactor.swift index 34d7a1b04..3ca133d57 100644 --- a/Projects/Features/SearchFeature/Sources/Reactors/AfterSearchReactor.swift +++ b/Projects/Features/SearchFeature/Sources/Reactors/AfterSearchReactor.swift @@ -6,7 +6,6 @@ import SongsDomainInterface public final class AfterSearchReactor: Reactor { var disposeBag: DisposeBag = DisposeBag() - private let fetchSearchSongUseCase: FetchSearchSongUseCase public enum Action { case fetchData(String) @@ -23,8 +22,7 @@ public final class AfterSearchReactor: Reactor { public var initialState: State - init(fetchSearchSongUseCase: FetchSearchSongUseCase) { - self.fetchSearchSongUseCase = fetchSearchSongUseCase + init() { self.initialState = State( dataSource: [], text: "" @@ -56,8 +54,7 @@ public final class AfterSearchReactor: Reactor { private extension AfterSearchReactor { func fetchData(_ text: String) -> Observable { - return fetchSearchSongUseCase - .execute(keyword: text) + return Observable.just(SearchResultEntity(song: [], artist: [], remix: [])) .asObservable() .map { res in diff --git a/Projects/Features/SearchFeature/Sources/ViewModels/AfterSearchViewModel.swift b/Projects/Features/SearchFeature/Sources/ViewModels/AfterSearchViewModel.swift index 21265c2c7..aa5f44a87 100644 --- a/Projects/Features/SearchFeature/Sources/ViewModels/AfterSearchViewModel.swift +++ b/Projects/Features/SearchFeature/Sources/ViewModels/AfterSearchViewModel.swift @@ -15,11 +15,9 @@ import Utility public final class AfterSearchViewModel: ViewModelType { var disposeBag = DisposeBag() - var fetchSearchSongUseCase: FetchSearchSongUseCase! - public init(fetchSearchSongUseCase: FetchSearchSongUseCase) { + public init() { DEBUG_LOG("✅ AfterSearchViewModel 생성") - self.fetchSearchSongUseCase = fetchSearchSongUseCase } public struct Input { @@ -47,8 +45,7 @@ public final class AfterSearchViewModel: ViewModelType { guard let self = self else { return Observable.empty() } - return self.fetchSearchSongUseCase - .execute(keyword: str) + return Observable.just(SearchResultEntity(song: [], artist: [], remix: [])) .asObservable() } .map { res in From 103b0466be5cc0376cfde8b7a4ff8679dd9a9ad1 Mon Sep 17 00:00:00 2001 From: KTH Date: Tue, 14 May 2024 13:11:43 +0900 Subject: [PATCH 10/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#507]=20?= =?UTF-8?q?=EC=98=B5=EC=85=94=EB=84=90=20=EC=A0=9C=EA=B1=B0,=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EC=88=98=EC=A0=95=20=EB=93=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interface/Entity/ArtistListEntity.swift | 8 ++-- .../ResponseDTO/ArtistListResponseDTO.swift | 2 +- .../FetchChartRankingResponseDTO.swift | 8 ++-- .../Interface/Entity/SongCreditsEntity.swift | 34 ++++++++--------- .../ResponseDTO/SongCreditsResponseDTO.swift | 38 +++++++++---------- .../Sources/Reactors/ArtistReactor.swift | 2 +- .../ArtistMusicContentViewModel.swift | 2 +- .../Tests/ArtistReactorTests.swift | 6 +-- 8 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Projects/Domains/ArtistDomain/Interface/Entity/ArtistListEntity.swift b/Projects/Domains/ArtistDomain/Interface/Entity/ArtistListEntity.swift index 77361d231..2bc8e164b 100644 --- a/Projects/Domains/ArtistDomain/Interface/Entity/ArtistListEntity.swift +++ b/Projects/Domains/ArtistDomain/Interface/Entity/ArtistListEntity.swift @@ -10,7 +10,7 @@ import Foundation public struct ArtistListEntity: Equatable { public init( - ID: String, + id: String, krName: String, enName: String, groupName: String, @@ -22,7 +22,7 @@ public struct ArtistListEntity: Equatable { graduated: Bool, isHiddenItem: Bool ) { - self.ID = ID + self.id = id self.krName = krName self.enName = enName self.groupName = groupName @@ -36,10 +36,10 @@ public struct ArtistListEntity: Equatable { } public static func == (lhs: Self, rhs: Self) -> Bool { - return lhs.ID == rhs.ID + return lhs.id == rhs.id } - public let ID, krName, enName, groupName: String + public let id, krName, enName, groupName: String public let title, description: String public let personalColor: String public let roundImage, squareImage: String diff --git a/Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistListResponseDTO.swift b/Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistListResponseDTO.swift index 81551541c..42a1d6f6b 100644 --- a/Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistListResponseDTO.swift +++ b/Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistListResponseDTO.swift @@ -70,7 +70,7 @@ public extension ArtistListResponseDTO.Info { public extension ArtistListResponseDTO { func toDomain() -> ArtistListEntity { ArtistListEntity( - ID: group?.id ?? "", + id: group?.id ?? "", krName: name?.krName ?? "", enName: name?.enName ?? "", groupName: group?.name ?? "", diff --git a/Projects/Domains/ChartDomain/Sources/ResponseDTO/FetchChartRankingResponseDTO.swift b/Projects/Domains/ChartDomain/Sources/ResponseDTO/FetchChartRankingResponseDTO.swift index 5052a9801..8a3986507 100644 --- a/Projects/Domains/ChartDomain/Sources/ResponseDTO/FetchChartRankingResponseDTO.swift +++ b/Projects/Domains/ChartDomain/Sources/ResponseDTO/FetchChartRankingResponseDTO.swift @@ -5,8 +5,8 @@ import Utility public struct SingleChartRankingResponseDTO: Decodable, Equatable { let songID, title: String let artists: [String] - let date: Int - let last, increase, views: Int? + let increase, views, date: Int + let last: Int? public static func == (lhs: Self, rhs: Self) -> Bool { return lhs.songID == rhs.songID @@ -26,9 +26,9 @@ public extension SingleChartRankingResponseDTO { id: songID, title: title, artist: artists.joined(separator: ", "), - views: views ?? 0, + views: views, last: last ?? 0, - increase: increase ?? 0, + increase: increase, date: date.changeDateFormat(origin: "yyMMdd", result: "yyyy.MM.dd") ) } diff --git a/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift b/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift index 587e4b68a..77ef6ba47 100644 --- a/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift +++ b/Projects/Domains/SongsDomain/Interface/Entity/SongCreditsEntity.swift @@ -10,20 +10,20 @@ import Foundation public struct SongCreditsEntity { public init( - vocal: String, - featuring: String, + vocal: [String], + featuring: [String], original: String, - producing: String, - lyrics: String, - relyrics: String, - compose: String, - arrange: String, - mixing: String, - mastering: String, - session: String, - chorus: String, - vocalGuide: String, - trainer: String + producing: [String], + lyrics: [String], + relyrics: [String], + compose: [String], + arrange: [String], + mixing: [String], + mastering: [String], + session: [String], + chorus: [String], + vocalGuide: [String], + trainer: [String] ) { self.vocal = vocal self.featuring = featuring @@ -41,9 +41,9 @@ public struct SongCreditsEntity { self.trainer = trainer } - public let vocal, featuring: String + public let vocal, featuring: [String] public let original: String - public let producing, lyrics, relyrics, compose: String - public let arrange, mixing, mastering, session: String - public let chorus, vocalGuide, trainer: String + public let producing, lyrics, relyrics, compose: [String] + public let arrange, mixing, mastering, session: [String] + public let chorus, vocalGuide, trainer: [String] } diff --git a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift index c9a4a2f12..c347dbd2f 100644 --- a/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift +++ b/Projects/Domains/SongsDomain/Sources/ResponseDTO/SongCreditsResponseDTO.swift @@ -10,30 +10,30 @@ import Foundation import SongsDomainInterface public struct SongCreditsResponseDTO: Decodable { - let vocal, featuring: [String]? - let original: String? - let producing, lyrics, relyrics, compose: [String]? - let arrange, mixing, mastering, session: [String]? - let chorus, vocalGuide, trainer: [String]? + let vocal, featuring: [String] + let original: String + let producing, lyrics, relyrics, compose: [String] + let arrange, mixing, mastering, session: [String] + let chorus, vocalGuide, trainer: [String] } public extension SongCreditsResponseDTO { func toDomain() -> SongCreditsEntity { return SongCreditsEntity( - vocal: (vocal ?? []).joined(separator: ", "), - featuring: (featuring ?? []).joined(separator: ", "), - original: original ?? "", - producing: (producing ?? []).joined(separator: ", "), - lyrics: (lyrics ?? []).joined(separator: ", "), - relyrics: (relyrics ?? []).joined(separator: ", "), - compose: (compose ?? []).joined(separator: ", "), - arrange: (arrange ?? []).joined(separator: ", "), - mixing: (mixing ?? []).joined(separator: ", "), - mastering: (mastering ?? []).joined(separator: ", "), - session: (session ?? []).joined(separator: ", "), - chorus: (chorus ?? []).joined(separator: ", "), - vocalGuide: (vocalGuide ?? []).joined(separator: ", "), - trainer: (trainer ?? []).joined(separator: ", ") + vocal: vocal, + featuring: featuring, + original: original, + producing: producing, + lyrics: lyrics, + relyrics: relyrics, + compose: compose, + arrange: arrange, + mixing: mixing, + mastering: mastering, + session: session, + chorus: chorus, + vocalGuide: vocalGuide, + trainer: trainer ) } } diff --git a/Projects/Features/ArtistFeature/Sources/Reactors/ArtistReactor.swift b/Projects/Features/ArtistFeature/Sources/Reactors/ArtistReactor.swift index b6c310f96..9c2bbcf65 100644 --- a/Projects/Features/ArtistFeature/Sources/Reactors/ArtistReactor.swift +++ b/Projects/Features/ArtistFeature/Sources/Reactors/ArtistReactor.swift @@ -75,7 +75,7 @@ private extension ArtistReactor { private extension ArtistReactor { func makeHiddenArtistEntity() -> ArtistListEntity { ArtistListEntity( - ID: "", + id: "", krName: "", enName: "", groupName: "", diff --git a/Projects/Features/ArtistFeature/Sources/ViewModels/ArtistMusicContentViewModel.swift b/Projects/Features/ArtistFeature/Sources/ViewModels/ArtistMusicContentViewModel.swift index 054b584ab..1315b18f6 100644 --- a/Projects/Features/ArtistFeature/Sources/ViewModels/ArtistMusicContentViewModel.swift +++ b/Projects/Features/ArtistFeature/Sources/ViewModels/ArtistMusicContentViewModel.swift @@ -45,7 +45,7 @@ public final class ArtistMusicContentViewModel: ViewModelType { public func transform(from input: Input) -> Output { let output = Output() - let ID: String = model?.ID ?? "" + let ID: String = model?.id ?? "" let type: ArtistSongSortType = self.type let fetchArtistSongListUseCase: FetchArtistSongListUseCase = self.fetchArtistSongListUseCase diff --git a/Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift b/Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift index c66cbd7ac..a66b83cb9 100644 --- a/Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift +++ b/Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift @@ -32,7 +32,7 @@ final class ArtistReactorTests: XCTestCase { // Then XCTAssertEqual(fetchArtistListUseCase.callCount, 1) XCTAssertEqual(sut.currentState.artistList[0], dummyArtistList.first) - XCTAssertEqual(sut.currentState.artistList[0].ID, "") + XCTAssertEqual(sut.currentState.artistList[0].id, "") XCTAssertEqual(sut.currentState.artistList[0].isHiddenItem, true) } @@ -59,7 +59,7 @@ final class ArtistReactorTests: XCTestCase { private func makeTwoDummyArtistList() -> [ArtistListEntity] { [ ArtistListEntity( - ID: "", + id: "", krName: "", enName: "", groupName: "", @@ -72,7 +72,7 @@ final class ArtistReactorTests: XCTestCase { isHiddenItem: false ), ArtistListEntity( - ID: "2", + id: "2", krName: "nam2", enName: "eng2", groupName: "group2", From e29f6897fd3abe8cbba8445a380612b31d3cb49e Mon Sep 17 00:00:00 2001 From: "pikagreen@nate.com" Date: Tue, 14 May 2024 15:07:05 +0900 Subject: [PATCH 11/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#507]=20id?= =?UTF-8?q?=EA=B0=92=EC=9C=BC=EB=A1=9C=20name.kr=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ResponseDTO/ArtistListResponseDTO.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistListResponseDTO.swift b/Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistListResponseDTO.swift index 42a1d6f6b..d427ca397 100644 --- a/Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistListResponseDTO.swift +++ b/Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistListResponseDTO.swift @@ -17,7 +17,7 @@ public struct ArtistListResponseDTO: Decodable, Equatable { let graduated: Bool? public static func == (lhs: Self, rhs: Self) -> Bool { - return lhs.group?.id == rhs.group?.id + return lhs.name?.id == rhs.name?.id } private enum CodingKeys: String, CodingKey { @@ -31,17 +31,18 @@ public struct ArtistListResponseDTO: Decodable, Equatable { public extension ArtistListResponseDTO { struct Name: Decodable { + let id: String let krName: String let enName: String private enum CodingKeys: String, CodingKey { + case id = "kr" case krName = "krShort" case enName = "en" } } struct Group: Decodable { - let id: String let name: String } @@ -70,7 +71,7 @@ public extension ArtistListResponseDTO.Info { public extension ArtistListResponseDTO { func toDomain() -> ArtistListEntity { ArtistListEntity( - id: group?.id ?? "", + id: name?.id ?? "", krName: name?.krName ?? "", enName: name?.enName ?? "", groupName: group?.name ?? "", From 5190c53ad9a4bf7426ea052f45c538a8f273a7e7 Mon Sep 17 00:00:00 2001 From: "pikagreen@nate.com" Date: Tue, 14 May 2024 16:16:48 +0900 Subject: [PATCH 12/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#507]=20Artist?= =?UTF-8?q?ReactorTests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Features/ArtistFeature/Tests/ArtistReactorTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift b/Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift index a66b83cb9..f30135599 100644 --- a/Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift +++ b/Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift @@ -33,7 +33,7 @@ final class ArtistReactorTests: XCTestCase { XCTAssertEqual(fetchArtistListUseCase.callCount, 1) XCTAssertEqual(sut.currentState.artistList[0], dummyArtistList.first) XCTAssertEqual(sut.currentState.artistList[0].id, "") - XCTAssertEqual(sut.currentState.artistList[0].isHiddenItem, true) + XCTAssertEqual(sut.currentState.artistList[0].isHiddenItem, false) } func test_when_viewDidLoad_action_and_artist_count_greater_than_2_then_swap_index_0_and_1() { @@ -69,7 +69,7 @@ final class ArtistReactorTests: XCTestCase { roundImage: "", squareImage: "", graduated: false, - isHiddenItem: false + isHiddenItem: true ), ArtistListEntity( id: "2",