From daaee9baacc51419090a33385b0df703506ff651 Mon Sep 17 00:00:00 2001 From: hryeong66 Date: Tue, 26 Jul 2022 21:45:33 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=85[CHORE]=20#285=20-=20postDetail=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=ED=86=B5=EC=8B=A0=20dataModel=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Models/PostDetailDataModel.swift | 62 +++++++++++-------- .../Source/Services/PostResultService.swift | 6 +- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Models/PostDetailDataModel.swift b/ChaRo-iOS/ChaRo-iOS/Source/Models/PostDetailDataModel.swift index b84e3e4d..c0c4367b 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Models/PostDetailDataModel.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Models/PostDetailDataModel.swift @@ -7,33 +7,45 @@ import Foundation import TMapSDK - -// MARK: - Welcome -struct PostDatailDataModel: Codable { - let success: Bool - let msg: String - let data: PostDetailData? -} +import UIKit //// MARK: - Datum -struct PostDetail: Codable { - let title, author: String - let isAuthor: Bool - let profileImage: String - let postingYear, postingMonth, postingDay: String - let isStored, isFavorite: Bool - let likesCount: Int - let images: [String] - let province, city: String - let themes: [String] - let source: String - let wayPoint: [String] - let destination: String - let longtitude, latitude: [String] - let isParking: Bool - let parkingDesc: String - let warnings: [Bool] - let courseDesc: String +struct PostDetailDataModel: Codable { + let postId: Int? + let title: String? + let author: String? + let authorEmail: String? + let profileImage: String? + + let isAuthor: Bool? + let isStored: Int? + let isFavorite: Int? + let isParking: Bool? + + let parkingDesc: String? + let courseDesc: String? + + let province: String? + let region: String? + let themes: [String]? + + let likesCount: Int? + + let createdAt: String? + let images: [String]? + let course: [Course]? + let warnings: [Bool]? + + //2022-06-13T16:35:31.000Z + func getCreatedTimeText() -> String { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy년 MM월 dd일" + dateFormatter.locale = Locale(identifier:"ko_KR") + let convertDate = dateFormatter.date(from: createdAt ?? "") ?? Date() + let dateString = dateFormatter.string(from: convertDate) + return dateString + } + } // MARK: - DataClass diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Services/PostResultService.swift b/ChaRo-iOS/ChaRo-iOS/Source/Services/PostResultService.swift index b7055052..68face9b 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Services/PostResultService.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Services/PostResultService.swift @@ -55,9 +55,9 @@ struct PostResultService { dataRequeat.responseData{ dataResponse in switch dataResponse.result { case .success: - guard let statusCode = dataResponse.response?.statusCode else { return} - guard let value = dataResponse.value else {return} - let networkResult = self.judgeStatus(type: PostDetailData.self, by: statusCode, value) + guard let statusCode = dataResponse.response?.statusCode else { return } + guard let value = dataResponse.value else { return } + let networkResult = self.judgeStatus(type: PostDetailDataModel.self, by: statusCode, value) completion(networkResult) case .failure(_): completion(.pathErr)