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
Changes from 1 commit
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
48 changes: 48 additions & 0 deletions HomeCafeRecipes/HomeCafeRecipes/Data/Network/DTO/RecipeDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// RecipeDTO.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/10/24.
//

import Foundation

struct RecipesResponseDTO: Decodable {
let statusCode: Int
let message: String
let data: [RecipeDTO]

Choose a reason for hiding this comment

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

이건 공통적으로 네트워킹에 사용하는 DTO 인 것 같은데, 네트워크 레이어에서 따로 관리하는건 어때요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

8afc27b
따로 분리 시켜두었습니다

}

struct RecipeDTO: Decodable {
let recipeId: Int
let recipeType: String
let recipeName: String
let recipeDescription: String
let recipeLikesCnt: Int

Choose a reason for hiding this comment

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

단순 의견) 전부 prefix로 recipe가 붙어있네요. Recipe DTO라서 불필요하지 않을까 싶은데 검토 부탁드릴게요.

필수) Id는 ID 로 작성 부탁드려요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

56c5ae6
prefix를 제거 하였습니다!

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 recipeImgUrls: [RecipeImageDTO]
}

struct RecipeImageDTO: Decodable {

Choose a reason for hiding this comment

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

이미지DTO도 따로 분리되면 다른 곳에서 image를 내려 받을 때 재사용할 수 있을 것 같아요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

56c5ae6
이미지 DTO 따로 분리 시켰습니다

let recipeImgId: Int
let recipeImgUrl: String
}

extension RecipeDTO {
func toDomain() -> Recipe {
return Recipe(
id: recipeId,
type: RecipeType(rawValue: recipeType) ?? .dessert,

Choose a reason for hiding this comment

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

type의 기본값이 dessert인가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

56c5ae6
coffee로 변경시켰습니다!

name: recipeName,
description: recipeDescription,
writer: writer.toDomain(),
imageUrls: recipeImgUrls.map { $0.recipeImgUrl },
isLiked: false,
likeCount: recipeLikesCnt,
createdAt: DateFormatter.iso8601.date(from: createdAt) ?? Date()
)
}
}


Loading