Skip to content

Commit

Permalink
[Feat] #275 - Best Response DTO 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Jul 9, 2024
1 parent 762214e commit 0a80187
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// BestBakeryDTO.swift
// GEON-PPANG-iOS
//
// Created by JEONGEUN KIM on 6/29/24.
//
import Foundation

struct BestBakeryResponseDTO: Decodable {

let bakeryID: Int
let bakeryName: String
let bakeryPicture: String
let isHACCP, isVegan, isNonGMO: Bool
let firstNearStation: String
let secondNearStation: String
let reviewCount, bookMarkCount: Int

enum CodingKeys: String, CodingKey {
case bakeryID = "bakeryId"
case bakeryName
case bakeryPicture
case isHACCP, isVegan, isNonGMO
case firstNearStation, secondNearStation
case reviewCount
case bookMarkCount
}

}

extension BestBakeryResponseDTO {

func toDomain() -> BestBakery {
let overview: BakeryOverview = .init(
id: bakeryID,
name: bakeryName,
image: bakeryPicture
)
let certifications: Certifications = .init(
isHaccp: isHACCP,
isVegan: isVegan,
isNonGMO: isNonGMO
)
let regions: Regions = .init(
firstRegion: firstNearStation,
secondRegion: secondNearStation
)

return BestBakery(
overview: overview,
certifications: certifications,
bookmarkCount: bookMarkCount,
reviewCount: reviewCount,
regions: regions
)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// BestReviewDTO.swift
// GEON-PPANG-iOS
//
// Created by JEONGEUN KIM on 6/29/24.
//

import Foundation

struct BestReviewResponseDTO: Decodable {
let bakeryID: Int
let bakeryName: String
let bakeryPicture: String
let isHACCP, isVegan, isNonGMO: Bool
let firstNearStation, secondNearStation: String
let reviewCount: Int
let reviewText: String
let firstMaxRecommendKeyword: String
let secondMaxRecommendKeyword: String?
let bookMarkCount: Int

enum CodingKeys: String, CodingKey {
case bakeryID = "bakeryId"
case bakeryName, bakeryPicture, isHACCP, isVegan, isNonGMO, firstNearStation, secondNearStation, reviewCount, reviewText, firstMaxRecommendKeyword, secondMaxRecommendKeyword, bookMarkCount
}
}

extension BestReviewResponseDTO {

func toDomain() -> BestReview {
let overview: BakeryOverview = .init(id: bakeryID, name: bakeryName, image: bakeryPicture)

return BestReview(overview: overview,
reviewOverview: reviewText,
recommendKeywords: [firstMaxRecommendKeyword, secondNearStation],
bookmarkCount: bookMarkCount,
reviewCount: reviewCount)
}
}

0 comments on commit 0a80187

Please sign in to comment.