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

피드리스트를 받기 위한 UseCase, Entities,Repository를 정의했습니다. #4

Merged
merged 16 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
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
162 changes: 162 additions & 0 deletions HomeCafeRecipes/HomeCafeRecipes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
objects = {

/* Begin PBXBuildFile section */
1D1283A22C15E94300C5A870 /* Recipe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283A12C15E94300C5A870 /* Recipe.swift */; };
1D1283A42C15EA8100C5A870 /* RecipeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283A32C15EA8100C5A870 /* RecipeType.swift */; };
1D1283A62C15EAA600C5A870 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283A52C15EAA600C5A870 /* User.swift */; };
1D1283A82C15EABB00C5A870 /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283A72C15EABB00C5A870 /* Comment.swift */; };
1D1283AA2C15EBCF00C5A870 /* SearchFeedUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283A92C15EBCF00C5A870 /* SearchFeedUseCase.swift */; };
1D1283AC2C15EBE600C5A870 /* FetchFeedListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283AB2C15EBE600C5A870 /* FetchFeedListUseCase.swift */; };
1D1283AF2C1697DB00C5A870 /* RxCocoa in Frameworks */ = {isa = PBXBuildFile; productRef = 1D1283AE2C1697DB00C5A870 /* RxCocoa */; };
1D1283B12C1697DB00C5A870 /* RxSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 1D1283B02C1697DB00C5A870 /* RxSwift */; };
1D1283B42C16983900C5A870 /* RxSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 1D1283B32C16983900C5A870 /* RxSwift */; };
1D1283B62C16984E00C5A870 /* RxCocoa in Frameworks */ = {isa = PBXBuildFile; productRef = 1D1283B52C16984E00C5A870 /* RxCocoa */; };
1D1283B82C169C0200C5A870 /* FeedListRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283B72C169C0200C5A870 /* FeedListRepository.swift */; };
1D1283BA2C16A62800C5A870 /* SearchFeedListRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283B92C16A62800C5A870 /* SearchFeedListRepository.swift */; };
1D1283C12C16B05800C5A870 /* RecipeDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283C02C16B05800C5A870 /* RecipeDTO.swift */; };
1D1283C32C16B06F00C5A870 /* UserDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283C22C16B06F00C5A870 /* UserDTO.swift */; };
1D1283C52C16B07D00C5A870 /* CommentDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283C42C16B07D00C5A870 /* CommentDTO.swift */; };
1D1283C82C16CE7C00C5A870 /* DateFormatter+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283C72C16CE7C00C5A870 /* DateFormatter+Extensions.swift */; };
1D1283CA2C16D9C600C5A870 /* RecipeFetchService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1283C92C16D9C600C5A870 /* RecipeFetchService.swift */; };
1D2C16E62BE532B700C04508 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D2C16E52BE532B700C04508 /* AppDelegate.swift */; };
1D2C16E82BE532B700C04508 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D2C16E72BE532B700C04508 /* SceneDelegate.swift */; };
1D2C16EA2BE532B700C04508 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D2C16E92BE532B700C04508 /* ViewController.swift */; };
Expand Down Expand Up @@ -35,6 +52,19 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1D1283A12C15E94300C5A870 /* Recipe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Recipe.swift; sourceTree = "<group>"; };
1D1283A32C15EA8100C5A870 /* RecipeType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecipeType.swift; sourceTree = "<group>"; };
1D1283A52C15EAA600C5A870 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
1D1283A72C15EABB00C5A870 /* Comment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Comment.swift; sourceTree = "<group>"; };
1D1283A92C15EBCF00C5A870 /* SearchFeedUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchFeedUseCase.swift; sourceTree = "<group>"; };
1D1283AB2C15EBE600C5A870 /* FetchFeedListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchFeedListUseCase.swift; sourceTree = "<group>"; };
1D1283B72C169C0200C5A870 /* FeedListRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListRepository.swift; sourceTree = "<group>"; };
1D1283B92C16A62800C5A870 /* SearchFeedListRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchFeedListRepository.swift; sourceTree = "<group>"; };
1D1283C02C16B05800C5A870 /* RecipeDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecipeDTO.swift; sourceTree = "<group>"; };
1D1283C22C16B06F00C5A870 /* UserDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDTO.swift; sourceTree = "<group>"; };
1D1283C42C16B07D00C5A870 /* CommentDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentDTO.swift; sourceTree = "<group>"; };
1D1283C72C16CE7C00C5A870 /* DateFormatter+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+Extensions.swift"; sourceTree = "<group>"; };
1D1283C92C16D9C600C5A870 /* RecipeFetchService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecipeFetchService.swift; sourceTree = "<group>"; };
1D2C16E22BE532B700C04508 /* HomeCafeRecipes.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HomeCafeRecipes.app; sourceTree = BUILT_PRODUCTS_DIR; };
1D2C16E52BE532B700C04508 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
1D2C16E72BE532B700C04508 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -54,6 +84,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1D1283B12C1697DB00C5A870 /* RxSwift in Frameworks */,
1D1283AF2C1697DB00C5A870 /* RxCocoa in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -68,19 +100,95 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1D1283B62C16984E00C5A870 /* RxCocoa in Frameworks */,
1D1283B42C16983900C5A870 /* RxSwift in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
1D12839F2C15E7A700C5A870 /* Entities */ = {
isa = PBXGroup;
children = (
1D1283A12C15E94300C5A870 /* Recipe.swift */,
1D1283A32C15EA8100C5A870 /* RecipeType.swift */,
1D1283A52C15EAA600C5A870 /* User.swift */,
1D1283A72C15EABB00C5A870 /* Comment.swift */,
);
path = Entities;
sourceTree = "<group>";
};
1D1283A02C15E92C00C5A870 /* UseCases */ = {
isa = PBXGroup;
children = (
1D1283A92C15EBCF00C5A870 /* SearchFeedUseCase.swift */,
1D1283AB2C15EBE600C5A870 /* FetchFeedListUseCase.swift */,
);
path = UseCases;
sourceTree = "<group>";
};
1D1283AD2C16974B00C5A870 /* Data */ = {
isa = PBXGroup;
children = (
1D1283BC2C16AA8100C5A870 /* Network */,
1D1283BB2C16AA6400C5A870 /* Repositories */,
);
path = Data;
sourceTree = "<group>";
};
1D1283B22C16983900C5A870 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
1D1283BB2C16AA6400C5A870 /* Repositories */ = {
isa = PBXGroup;
children = (
1D1283B72C169C0200C5A870 /* FeedListRepository.swift */,
1D1283B92C16A62800C5A870 /* SearchFeedListRepository.swift */,
);
name = Repositories;
path = "ㄲ데ㅐ냐새갿ㄴ";
sourceTree = "<group>";
};
1D1283BC2C16AA8100C5A870 /* Network */ = {
isa = PBXGroup;
children = (
1D1283BF2C16B02600C5A870 /* DTO */,
1D1283C92C16D9C600C5A870 /* RecipeFetchService.swift */,
);
path = Network;
sourceTree = "<group>";
};
1D1283BF2C16B02600C5A870 /* DTO */ = {
isa = PBXGroup;
children = (
1D1283C02C16B05800C5A870 /* RecipeDTO.swift */,
1D1283C22C16B06F00C5A870 /* UserDTO.swift */,
1D1283C42C16B07D00C5A870 /* CommentDTO.swift */,
);
path = DTO;
sourceTree = "<group>";
};
1D1283C62C16CD9200C5A870 /* Utilities */ = {
isa = PBXGroup;
children = (
1D1283C72C16CE7C00C5A870 /* DateFormatter+Extensions.swift */,
);
path = Utilities;
sourceTree = "<group>";
};
1D2C16D92BE532B700C04508 = {
isa = PBXGroup;
children = (
1D2C16E42BE532B700C04508 /* HomeCafeRecipes */,
1D2C16FB2BE532B800C04508 /* HomeCafeRecipesTests */,
1D2C17052BE532B800C04508 /* HomeCafeRecipesUITests */,
1D2C16E32BE532B700C04508 /* Products */,
1D1283B22C16983900C5A870 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -97,6 +205,9 @@
1D2C16E42BE532B700C04508 /* HomeCafeRecipes */ = {
isa = PBXGroup;
children = (
1D1283C62C16CD9200C5A870 /* Utilities */,
1D1283AD2C16974B00C5A870 /* Data */,
1D740B402C15E6680001B704 /* Domain */,
1D2C16E52BE532B700C04508 /* AppDelegate.swift */,
1D2C16E72BE532B700C04508 /* SceneDelegate.swift */,
1D2C16E92BE532B700C04508 /* ViewController.swift */,
Expand Down Expand Up @@ -124,6 +235,15 @@
path = HomeCafeRecipesUITests;
sourceTree = "<group>";
};
1D740B402C15E6680001B704 /* Domain */ = {
isa = PBXGroup;
children = (
1D1283A02C15E92C00C5A870 /* UseCases */,
1D12839F2C15E7A700C5A870 /* Entities */,
);
path = Domain;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -141,6 +261,8 @@
);
name = HomeCafeRecipes;
packageProductDependencies = (
1D1283AE2C1697DB00C5A870 /* RxCocoa */,
1D1283B02C1697DB00C5A870 /* RxSwift */,
);
productName = HomeCafeRecipes;
productReference = 1D2C16E22BE532B700C04508 /* HomeCafeRecipes.app */;
Expand Down Expand Up @@ -178,6 +300,10 @@
1D2C17042BE532B800C04508 /* PBXTargetDependency */,
);
name = HomeCafeRecipesUITests;
packageProductDependencies = (
1D1283B32C16983900C5A870 /* RxSwift */,
1D1283B52C16984E00C5A870 /* RxCocoa */,
);
productName = HomeCafeRecipesUITests;
productReference = 1D2C17022BE532B800C04508 /* HomeCafeRecipesUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
Expand Down Expand Up @@ -261,7 +387,20 @@
files = (
1D2C16EA2BE532B700C04508 /* ViewController.swift in Sources */,
1D2C16E62BE532B700C04508 /* AppDelegate.swift in Sources */,
1D1283A62C15EAA600C5A870 /* User.swift in Sources */,
1D1283C52C16B07D00C5A870 /* CommentDTO.swift in Sources */,
1D1283AC2C15EBE600C5A870 /* FetchFeedListUseCase.swift in Sources */,
1D1283A82C15EABB00C5A870 /* Comment.swift in Sources */,
1D1283C82C16CE7C00C5A870 /* DateFormatter+Extensions.swift in Sources */,
1D1283B82C169C0200C5A870 /* FeedListRepository.swift in Sources */,
1D1283A42C15EA8100C5A870 /* RecipeType.swift in Sources */,
1D1283AA2C15EBCF00C5A870 /* SearchFeedUseCase.swift in Sources */,
1D2C16E82BE532B700C04508 /* SceneDelegate.swift in Sources */,
1D1283BA2C16A62800C5A870 /* SearchFeedListRepository.swift in Sources */,
1D1283A22C15E94300C5A870 /* Recipe.swift in Sources */,
1D1283CA2C16D9C600C5A870 /* RecipeFetchService.swift in Sources */,
1D1283C32C16B06F00C5A870 /* UserDTO.swift in Sources */,
1D1283C12C16B05800C5A870 /* RecipeDTO.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -609,6 +748,29 @@
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
1D1283AE2C1697DB00C5A870 /* RxCocoa */ = {
isa = XCSwiftPackageProductDependency;
package = 1D740B3F2C15E1EC0001B704 /* XCRemoteSwiftPackageReference "RxSwift" */;
productName = RxCocoa;
};
1D1283B02C1697DB00C5A870 /* RxSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 1D740B3F2C15E1EC0001B704 /* XCRemoteSwiftPackageReference "RxSwift" */;
productName = RxSwift;
};
1D1283B32C16983900C5A870 /* RxSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 1D740B3F2C15E1EC0001B704 /* XCRemoteSwiftPackageReference "RxSwift" */;
productName = RxSwift;
};
1D1283B52C16984E00C5A870 /* RxCocoa */ = {
isa = XCSwiftPackageProductDependency;
package = 1D740B3F2C15E1EC0001B704 /* XCRemoteSwiftPackageReference "RxSwift" */;
productName = RxCocoa;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 1D2C16DA2BE532B700C04508 /* Project object */;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// RecipesResponseDTO.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/11/24.
//

import Foundation

struct NetworkResponseDTO<T: Decodable>: Decodable {
let statusCode: Int
let message: String
let data: T
}
47 changes: 47 additions & 0 deletions HomeCafeRecipes/HomeCafeRecipes/Data/Network/DTO/RecipeDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// RecipeDTO.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/10/24.
//

import Foundation

struct RecipeDTO: Decodable {

let id: Int
let type: String
let name: String
let description: String
let likesCount: Int
let createdAt: String
let writer: UserDTO

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userDTO는 따로 파일을 분리하는게 어떠신가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userDTO는 따로 분리 시켜 두었습니다!

let imageUrls: [RecipeImageDTO]

enum CodingKeys: String, CodingKey {
case id = "recipeId"
case type = "recipeType"
case name = "recipeName"
case description = "recipeDescription"
case likesCount = "recipeLikesCnt"
case createdAt = "createdAt"
case writer = "writer"
case imageUrls = "recipeImgUrls"
}
}

extension RecipeDTO {
func toDomain() -> Recipe {
return Recipe(
id: id,
type: RecipeType(rawValue: type) ?? .coffee,
name: name,
description: description,
writer: writer.toDomain(),
imageUrls: imageUrls.map { $0.recipeImageUrl },
hasBeenLiked: false,
likeCount: likesCount,
createdAt: DateFormatter.iso8601.date(from: createdAt) ?? Date()
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// RecipeImageDTO.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/11/24.
//

import Foundation

struct RecipeImageDTO: Decodable {
let recipeImageID: Int
let recipeImageUrl: String

private enum CodingKeys: String, CodingKey {
case recipeImageID = "recipeImgId"
case recipeImageUrl = "recipeImgUrl"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// RecipePageDTO.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/12/24.
//

import Foundation

struct RecipePageDTO: Decodable {
let totalPageNumber: Int
let pageNumber: Int
let recipes: [RecipeDTO]

private enum CodingKeys: String, CodingKey {
case totalPageNumber = "totalPageNumber"
case pageNumber = "pageNumber"
case recipes = "recipes"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// FeedListRepository.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/10/24.
//

import RxSwift

protocol FeedListRepository {
func fetchRecipes(pageNumber: Int) -> Single<[Recipe]>
}

class DefaultFeedListRepository: FeedListRepository {
private let networkService: RecipeFetchService

init(networkService: RecipeFetchService) {
self.networkService = networkService
}

func fetchRecipes(pageNumber: Int) -> Single<[Recipe]> {
return networkService.fetchRecipes(pageNumber: pageNumber)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// SearchFeedListRepository.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/10/24.
//

import RxSwift

protocol SearchFeedListRepository {
func searchRecipes(title: String, pageNumber: Int) -> Single<[Recipe]>
}

class DefaultSearchFeedRepository: SearchFeedListRepository {

private let networkService: RecipeFetchService

init(networkService: RecipeFetchService) {
self.networkService = networkService
}

func searchRecipes(title: String,pageNumber: Int) -> Single<[Recipe]> {
return networkService.searchRecipes(title: title, pageNumber: pageNumber)
}
}
Loading
Loading