diff --git a/iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate b/iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate index f2ff49d80..401808047 100644 Binary files a/iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate and b/iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iOS/SideDish/SideDish/Data/Network/DataMapping/BanchanListDTO+Mapping.swift b/iOS/SideDish/SideDish/Data/Network/DataMapping/BanchanListDTO+Mapping.swift index dbff5f1d9..f22329e8a 100644 --- a/iOS/SideDish/SideDish/Data/Network/DataMapping/BanchanListDTO+Mapping.swift +++ b/iOS/SideDish/SideDish/Data/Network/DataMapping/BanchanListDTO+Mapping.swift @@ -13,41 +13,25 @@ struct BanchanListDTO: Codable { extension BanchanListDTO { struct BanchanListItemDTO: Codable { - let hash: String + let detailHash: String let image: String let alt: String let deliveryType: [String] let description: String let title: String - let normalPrice: String? - let salePrice: String + let nPrice: String? + let sPrice: String let badge: [String]? - private enum CodingKeys: String, CodingKey { - case hash = "detail_hash" - case image - case alt - case deliveryType = "delivery_type" - case description - case title - case normalPrice = "n_price" - case salePrice = "s_price" - case badge + func toDomain() -> Banchan { + return .init(detailHash: detailHash, image: image, alt: alt, title: title, description: description, nPrice: nPrice, sPrice: sPrice, badge: badge, deliveryType: deliveryType) } } -} - -extension BanchanListDTO { + func toDomain() -> [Banchan] { - let banchans = self.body.map { - $0.toDomain() + let banchans = self.body.map { banchanListitemDTO in + banchanListitemDTO.toDomain() } return banchans } } - -extension BanchanListDTO.BanchanListItemDTO { - func toDomain() -> Banchan { - return .init(hash: hash, image: image, alt: alt, title: title, description: description, netPrice: normalPrice, salePrice: salePrice, badge: badge, delivery_type: deliveryType) - } -} diff --git a/iOS/SideDish/SideDish/Domain/Entities/Banchan.swift b/iOS/SideDish/SideDish/Domain/Entities/Banchan.swift index 32a03c7be..7db9525d5 100644 --- a/iOS/SideDish/SideDish/Domain/Entities/Banchan.swift +++ b/iOS/SideDish/SideDish/Domain/Entities/Banchan.swift @@ -18,20 +18,20 @@ enum PriceType { } struct Banchan: Hashable { - private (set) var hash: String + private (set) var detailHash: String private (set) var image: String private (set) var alt: String private (set) var title: String private (set) var description: String - private (set) var netPrice: String? - private (set) var salePrice: String + private (set) var nPrice: String? + private (set) var sPrice: String private (set) var badge: [String]? - private (set) var delivery_type: [String] + private (set) var deliveryType: [String] func hash(into hasher: inout Hasher) { - hasher.combine(hash) + hasher.combine(detailHash) } static func == (lhs: Banchan, rhs: Banchan) -> Bool { - lhs.hash == rhs.hash + lhs.detailHash == rhs.detailHash } } diff --git a/iOS/SideDish/SideDish/Domain/UseCases/FetchBanchanListUseCase.swift b/iOS/SideDish/SideDish/Domain/UseCases/FetchBanchanListUseCase.swift index 9a687aa01..b31777c89 100644 --- a/iOS/SideDish/SideDish/Domain/UseCases/FetchBanchanListUseCase.swift +++ b/iOS/SideDish/SideDish/Domain/UseCases/FetchBanchanListUseCase.swift @@ -12,10 +12,12 @@ struct FetchBanchanListUseCase { static func fetchBanchanList(network: NetworkRequest,section: String, completion: @escaping ([Banchan]?) -> Void) { let url = baseURL+section + let decoder = JSONDecoder() + decoder.keyDecodingStrategy = .convertFromSnakeCase network.request(url: url, httpMethod: .get) { dataDummy in guard let data = dataDummy.data else { return } - guard let banchans = try? JSONDecoder().decode(BanchanListDTO.self, from: data) else { return } + guard let banchans = try? decoder.decode(BanchanListDTO.self, from: data) else { return } completion(banchans.toDomain()) } }