-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1068 from wakmusic/1067-connect-api-artist-detail
- Loading branch information
Showing
33 changed files
with
302 additions
and
68 deletions.
There are no files selected for viewing
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
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
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
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
6 changes: 6 additions & 0 deletions
6
Projects/Domains/ArtistDomain/Interface/UseCase/FetchArtistDetailUseCase.swift
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,6 @@ | ||
import Foundation | ||
import RxSwift | ||
|
||
public protocol FetchArtistDetailUseCase { | ||
func execute(id: String) -> Single<ArtistEntity> | ||
} |
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
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
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
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
89 changes: 89 additions & 0 deletions
89
Projects/Domains/ArtistDomain/Sources/ResponseDTO/ArtistDetailResponseDTO.swift
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,89 @@ | ||
import ArtistDomainInterface | ||
import Foundation | ||
|
||
public struct ArtistDetailResponseDTO: Decodable, Equatable { | ||
let id: String | ||
let name: ArtistDetailResponseDTO.Name | ||
let group: ArtistDetailResponseDTO.Group | ||
let info: ArtistDetailResponseDTO.Info | ||
let imageURL: ArtistDetailResponseDTO.ImageURL | ||
let graduated: Bool | ||
|
||
public static func == (lhs: Self, rhs: Self) -> Bool { | ||
return lhs.id == rhs.id | ||
} | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case id | ||
case name | ||
case group | ||
case info | ||
case imageURL = "imageUrl" | ||
case graduated | ||
} | ||
} | ||
|
||
public extension ArtistDetailResponseDTO { | ||
struct Name: Decodable { | ||
let krName: String | ||
let enName: String | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case krName = "krShort" | ||
case enName = "en" | ||
} | ||
} | ||
|
||
struct Group: Decodable { | ||
let name: String | ||
} | ||
|
||
struct Info: Decodable { | ||
let title: ArtistDetailResponseDTO.Info.Title | ||
let description: String | ||
let color: ArtistDetailResponseDTO.Info.Color | ||
let playlist: ArtistDetailResponseDTO.Info.Playlist | ||
} | ||
|
||
struct ImageURL: Decodable { | ||
let round: String | ||
let square: String | ||
} | ||
} | ||
|
||
public extension ArtistDetailResponseDTO.Info { | ||
struct Title: Decodable { | ||
let short: String | ||
} | ||
|
||
struct Color: Decodable { | ||
let background: [[String]] | ||
} | ||
|
||
struct Playlist: Decodable { | ||
let latest, popular, oldest: String | ||
} | ||
} | ||
|
||
public extension ArtistDetailResponseDTO { | ||
func toDomain() -> ArtistEntity { | ||
ArtistEntity( | ||
id: id, | ||
krName: name.krName, | ||
enName: name.enName, | ||
groupName: group.name, | ||
title: info.title.short, | ||
description: info.description, | ||
personalColor: info.color.background.flatMap { $0 }.first ?? "ffffff", | ||
roundImage: imageURL.round, | ||
squareImage: imageURL.square, | ||
graduated: graduated, | ||
playlist: ArtistEntity.Playlist( | ||
latest: info.playlist.latest, | ||
popular: info.playlist.popular, | ||
oldest: info.playlist.oldest | ||
), | ||
isHiddenItem: false | ||
) | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
Projects/Domains/ArtistDomain/Sources/UseCase/FetchArtistDetailUseCaseImpl.swift
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 @@ | ||
import ArtistDomainInterface | ||
import Foundation | ||
import RxSwift | ||
|
||
public struct FetchArtistDetailUseCaseImpl: FetchArtistDetailUseCase { | ||
private let artistRepository: any ArtistRepository | ||
|
||
public init( | ||
artistRepository: ArtistRepository | ||
) { | ||
self.artistRepository = artistRepository | ||
} | ||
|
||
public func execute(id: String) -> Single<ArtistEntity> { | ||
artistRepository.fetchArtistDetail(id: id) | ||
} | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.