Skip to content

Commit

Permalink
✅[CHORE] #285 - postDetail 서버통신 dataModel 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hryeong66 committed Jul 26, 2022
1 parent 7d7ee84 commit daaee9b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
62 changes: 37 additions & 25 deletions ChaRo-iOS/ChaRo-iOS/Source/Models/PostDetailDataModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ChaRo-iOS/ChaRo-iOS/Source/Services/PostResultService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit daaee9b

Please sign in to comment.