Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: (#512) v3.0 api 변경점 적용 - Chart Domain #540

Merged
merged 16 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
37523e4
πŸ‘½οΈ :: [#512] v3.0 api 변경사항 반영
KangTaeHoon May 13, 2024
067af09
♻️ :: [#512] λ©μ²­ν•œ μ—‘μŠ€μ½”λ“œλ‘œ μΈν•œ μˆ˜μ •
KangTaeHoon May 13, 2024
0b60c32
♻️ :: [#512] 린트 κ²½κ³  제거
KangTaeHoon May 13, 2024
ddc83f2
♻️ :: [#507] SingleSongResponseDTO
KangTaeHoon May 13, 2024
698b928
♻️ :: [#507] LyricsResponseDTO, LyricsEntity
KangTaeHoon May 13, 2024
5322f05
Merge branch '511-update-domain-artist' into 507-update-domain-song
KangTaeHoon May 13, 2024
154da0c
Merge branch '511-update-domain-artist' into 512-update-domain-chart
KangTaeHoon May 13, 2024
e8a1b2c
✏️ :: [#507] SongCreditsResponseDTO, SongCreditsEntity,
KangTaeHoon May 13, 2024
1f4d2d0
✏️ :: [#507] FetchSongCreditsUseCase
KangTaeHoon May 13, 2024
fbb06d0
♻️ :: [#507] 린트 κ²½κ³  제거
KangTaeHoon May 13, 2024
c548473
πŸ”₯ :: [#507] FetchSearchSongUseCase
KangTaeHoon May 13, 2024
103b046
♻️ :: [#507] μ˜΅μ…”λ„ 제거, 넀이밍 μˆ˜μ • λ“±
KangTaeHoon May 14, 2024
e29f689
♻️ :: [#507] idκ°’μœΌλ‘œ name.kr μ‚¬μš©
KangTaeHoon May 14, 2024
5190c53
♻️ :: [#507] ArtistReactorTests
KangTaeHoon May 14, 2024
e8d62b2
Merge branch '512-update-domain-chart' into 507-update-domain-song
KangTaeHoon May 15, 2024
7719a76
Merge pull request #541 from wakmusic/507-update-domain-song
KangTaeHoon May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Projects/App/Sources/Application/AppComponent+Songs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ public extension AppComponent {
}
}

var fetchSearchSongUseCase: any FetchSearchSongUseCase {
shared {
FetchSearchSongUseCaseImpl(songsRepository: songsRepository)
}
}

var fetchLyricsUseCase: any FetchLyricsUseCase {
shared {
FetchLyricsUseCaseImpl(songsRepository: songsRepository)
Expand Down
5 changes: 0 additions & 5 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

public struct ArtistListEntity: Equatable {
public init(
ID: String,
id: String,
krName: String,
enName: String,
groupName: String,
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down Expand Up @@ -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 ?? "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ public struct ChartRankingEntity: Equatable {
id: String,
title: String,
artist: String,
remix: String,
reaction: String,
views: Int,
last: Int,
increase: Int,
Expand All @@ -16,17 +14,14 @@ 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
self.date = date
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
Expand Down
18 changes: 9 additions & 9 deletions Projects/Domains/ChartDomain/Interface/Enum/ChartDateType.swift
Original file line number Diff line number Diff line change
@@ -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 "λˆ„μ μˆœ"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
}
13 changes: 5 additions & 8 deletions Projects/Domains/ChartDomain/Sources/API/ChartAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)"
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Foundation
import RxSwift

public final class RemoteChartDataSourceImpl: BaseRemoteDataSource<ChartAPI>, 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) } }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,31 @@ 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 increase, views, date: Int
let last: 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,
artist: artists.joined(separator: ", "),
views: views,
last: last,
last: last ?? 0,
increase: increase,
date: date.changeDateFormat(origin: "yyMMdd", result: "yyyy.MM.dd")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import RxSwift

public protocol RemoteSongsDataSource {
func fetchSearchSong(keyword: String) -> Single<SearchResultEntity>
func fetchLyrics(id: String) -> Single<[LyricsEntity]>
func fetchSongCredits(id: String) -> Single<SongCreditsEntity>
func fetchNewSongs(type: NewSongGroupType, page: Int, limit: Int) -> Single<[NewSongsEntity]>
}
13 changes: 2 additions & 11 deletions Projects/Domains/SongsDomain/Interface/Entity/LyricsEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading
Loading