refactor(home): 추천 데이터 계층을 정리한다
This commit is contained in:
@@ -2,7 +2,7 @@ import Foundation
|
||||
import Combine
|
||||
|
||||
final class MainHomeViewModel: ObservableObject {
|
||||
private let repository = MainHomeRepository()
|
||||
private let repository = MainHomeRecommendationRepository()
|
||||
private var subscription = Set<AnyCancellable>()
|
||||
|
||||
@Published var isLoading = false
|
||||
|
||||
@@ -2,7 +2,7 @@ import Foundation
|
||||
|
||||
struct HomeRecommendationResponse: Decodable {
|
||||
let lives: [HomeLiveItem]
|
||||
let banners: [HomeBannerItem]
|
||||
let banners: [RecommendationBannerResponse]
|
||||
let recentlyActiveCreators: [HomeActiveCreatorItem]
|
||||
let recentDebutCreators: [HomeCreatorItem]
|
||||
let firstAudioContents: [HomeFirstAudioContentItem]
|
||||
@@ -13,19 +13,12 @@ struct HomeRecommendationResponse: Decodable {
|
||||
}
|
||||
|
||||
struct HomeLiveItem: Decodable, Hashable {
|
||||
let liveRoomId: Int?
|
||||
let roomId: Int?
|
||||
let creatorId: Int?
|
||||
let creatorNickname: String?
|
||||
let title: String?
|
||||
let profileImageUrl: String?
|
||||
let thumbnailUrl: String?
|
||||
let imageUrl: String?
|
||||
let beginDateTime: String?
|
||||
let participantCount: Int?
|
||||
let creatorProfileImage: String?
|
||||
}
|
||||
|
||||
struct HomeBannerItem: Decodable, Hashable {
|
||||
struct RecommendationBannerResponse: Decodable, Hashable {
|
||||
let bannerId: Int?
|
||||
let type: String?
|
||||
let title: String?
|
||||
@@ -37,49 +30,42 @@ struct HomeBannerItem: Decodable, Hashable {
|
||||
}
|
||||
|
||||
struct HomeActiveCreatorItem: Decodable, Hashable {
|
||||
let creatorId: Int?
|
||||
let creatorNickname: String?
|
||||
let profileImageUrl: String?
|
||||
let creatorProfileImage: String?
|
||||
let activityType: RecommendedActivityType?
|
||||
let activityAt: String?
|
||||
let targetId: Int?
|
||||
}
|
||||
|
||||
struct HomeCreatorItem: Decodable, Hashable {
|
||||
let creatorId: Int?
|
||||
let creatorNickname: String?
|
||||
let nickname: String?
|
||||
let profileImageUrl: String?
|
||||
let imageUrl: String?
|
||||
let description: String?
|
||||
let followerCount: Int?
|
||||
let cheerCount: Int?
|
||||
let debutDate: String?
|
||||
let creatorProfileImage: String?
|
||||
}
|
||||
|
||||
struct HomeFirstAudioContentItem: Decodable, Hashable {
|
||||
let contentId: Int?
|
||||
let creatorId: Int?
|
||||
let creatorNickname: String?
|
||||
let creatorProfileImage: String?
|
||||
let title: String?
|
||||
let imageUrl: String?
|
||||
let coverImageUrl: String?
|
||||
let releaseDate: String?
|
||||
let price: Int?
|
||||
let coverImage: String?
|
||||
let isPointAvailable: Bool?
|
||||
}
|
||||
|
||||
struct HomeAiCharacterItem: Decodable, Hashable {
|
||||
let characterId: Int?
|
||||
let creatorId: Int?
|
||||
let name: String?
|
||||
let description: String?
|
||||
let profileImageUrl: String?
|
||||
let imageUrl: String?
|
||||
let chatCount: Int?
|
||||
let originalTitle: String?
|
||||
let profileImage: String?
|
||||
let totalChatCount: Int?
|
||||
let originalWorkTitle: String?
|
||||
}
|
||||
|
||||
struct HomeGenreCreatorGroupItem: Decodable, Hashable {
|
||||
let genreId: Int?
|
||||
let genreName: String?
|
||||
let title: String?
|
||||
let creators: [HomeCreatorItem]?
|
||||
}
|
||||
|
||||
@@ -87,9 +73,10 @@ struct HomePopularCommunityPostItem: Decodable, Hashable {
|
||||
let postId: Int?
|
||||
let creatorId: Int?
|
||||
let creatorNickname: String?
|
||||
let creatorProfileImageUrl: String?
|
||||
let creatorProfileImage: String?
|
||||
let content: String?
|
||||
let imageUrl: String?
|
||||
let audioUrl: String?
|
||||
let price: Int?
|
||||
let existOrdered: Bool?
|
||||
let likeCount: Int?
|
||||
@@ -1,12 +1,12 @@
|
||||
import Foundation
|
||||
import Moya
|
||||
|
||||
enum MainHomeApi {
|
||||
enum MainHomeRecommendationApi {
|
||||
case getRecommendations
|
||||
case followRecommendedCreators(request: FollowRecommendedCreatorsRequest)
|
||||
}
|
||||
|
||||
extension MainHomeApi: TargetType {
|
||||
extension MainHomeRecommendationApi: TargetType {
|
||||
var baseURL: URL {
|
||||
return URL(string: BASE_URL)!
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import CombineMoya
|
||||
import Combine
|
||||
import Moya
|
||||
|
||||
final class MainHomeRepository {
|
||||
private let api = MoyaProvider<MainHomeApi>()
|
||||
final class MainHomeRecommendationRepository {
|
||||
private let api = MoyaProvider<MainHomeRecommendationApi>()
|
||||
|
||||
func getRecommendations() -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getRecommendations)
|
||||
Reference in New Issue
Block a user