-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a99e1b0
Feat: Recipe,RecipeType 엔티티 정의
GeonH0 52c981f
Feat: FetchFeedListUseCase,SearchFeedListUseCase 정의
GeonH0 5fcb880
Feat: FeedListRepository,SearchFeedListRepository 정의
GeonH0 e9d4af2
Feat: RecipeDTO 정의
GeonH0 56c5ae6
Fix: 이미지DTO 분리, 레시피DTO prefix제거 id ID로 변경, type 기본값 coffee로 변경
GeonH0 8afc27b
Fix: RecipesResponseDTO 분리
GeonH0 d86703c
Fix: ResponseDTO로 네이밍 변경, DTO 폴더로 이동
GeonH0 628e0b7
Fix: img를 Image 줄임말 변경, recipeImageID로 네이밍 변경, ID를 id로 변경
GeonH0 a7e58be
Fix: Observable에서 단일 이벤트작업에 더 적합한 Single로 변경
GeonH0 bf60bc6
Fix: isLiked를 hasBeenLiked로 좀 더 명확히 네이밍 변경
GeonH0 84df58b
Fix: ResponseDTO를 NetworkResponseDTO로 네이밍 변경
GeonH0 506be99
Fix: RecipeImageDTO에 CodingKeys추가
GeonH0 8acf4c6
Fix: pagination을 위해 DTO구조를 변경
GeonH0 66312f1
Fix: pagination적용으로 FeedListRepository,SearchFeedListRepository 수정
GeonH0 e9763e8
Fix: pagination을 위해 FetchFeedListUseCase,SearchFeedListUseCase수정
GeonH0 b7981cc
Fix: hasBeenLiked를 isLikedByCurrentUser로 네이밍 변경
GeonH0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 14 additions & 0 deletions
14
HomeCafeRecipes/HomeCafeRecipes/Data/Network/DTO/NetworkResponseDTO.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,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
47
HomeCafeRecipes/HomeCafeRecipes/Data/Network/DTO/RecipeDTO.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,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 | ||
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() | ||
) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
HomeCafeRecipes/HomeCafeRecipes/Data/Network/DTO/RecipeImageDTO.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,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" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
HomeCafeRecipes/HomeCafeRecipes/Data/Network/DTO/RecipePageDTO.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,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" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/FeedListRepository.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,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) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/SearchFeedListRepository.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,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) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userDTO는 따로 파일을 분리하는게 어떠신가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userDTO는 따로 분리 시켜 두었습니다!