Skip to content

Commit

Permalink
Merge pull request #39 from f-lab-edu/refactor/RecipeDetailFetch
Browse files Browse the repository at this point in the history
레시피 상세페이지부분 서버 리팩토링으로 인한 DTO 수정
  • Loading branch information
GeonH0 authored Jan 13, 2025
2 parents 5bbc0ca + 40e0a68 commit 8207b1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ struct RecipeDetailDTO: Decodable {
let likesCount: Int
let createdAt: String
let writer: UserDTO
let imageUrls: [String] // 배열로 수신
let imageUrls: [RecipeImageDTO]
let isLikedByCurrentUser: Bool

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

extension RecipeDetailDTO {
func toDomain() -> Recipe {
return Recipe(
id: id,
id: id,
type: .coffee,
name: name,
description: description,
writer: writer.toDomain(),
imageUrls: imageUrls,
imageUrls: imageUrls.map{ $0.recipeImageUrl },
isLikedByCurrentUser: isLikedByCurrentUser,
likeCount: likesCount,
createdAt: DateFormatter.iso8601.date(from: createdAt) ?? Date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct RecipeImageDTO: Decodable {
let recipeImageUrl: String

private enum CodingKeys: String, CodingKey {
case recipeImageID = "recipeImgId"
case recipeImageUrl = "recipeImgUrl"
case recipeImageID = "recipeImageId"
case recipeImageUrl = "recipeImageUrl"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ extension RecipeDetailViewController: RecipeDetailViewDelegate {
print("Recipe ID is missing")
return
}
router.presentCommentViewModally(from: self, recipeID: recipeID)
print(recipeID)
router.presentCommentViewModally(from: self, recipeID: recipeID)
}

func didTapBookmarkButton() {
Expand Down

0 comments on commit 8207b1e

Please sign in to comment.