Skip to content

Commit

Permalink
[refactor] :refactor: PlanPreview 데이터모델 폴더링 및 구조 수정(#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
i-colours-u committed Jan 28, 2022
1 parent 0fa896c commit 6355f46
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension PlanPreview{
var budget : String
var transport : String
var month : String

}

enum SummaryCase{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ extension PlanPreview{
struct HeaderData{
var writer : String
var title : String


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import Foundation

protocol PlanPreviewServiceType{
func getPlanPreviewHeaderData(idx : Int,completion: @escaping (Result<PlanPreviewData.Header?, Error>) -> Void)
func getPlanPreviewDetailData(idx : Int,completion: @escaping (Result<[PlanPreviewData.Body]?, Error>) -> Void)
func getPlanPreviewHeaderData(idx : Int,completion: @escaping (Result<PlanPreviewEntity.Header?, Error>) -> Void)
func getPlanPreviewDetailData(idx : Int,completion: @escaping (Result<[PlanPreviewEntity.Body]?, Error>) -> Void)
}

extension BaseService : PlanPreviewServiceType{
func getPlanPreviewHeaderData(idx: Int, completion: @escaping (Result<PlanPreviewData.Header?, Error>) -> Void) {
func getPlanPreviewHeaderData(idx: Int, completion: @escaping (Result<PlanPreviewEntity.Header?, Error>) -> Void) {
requestObject(.getPlanPreviewHeaderData(idx: idx), completion: completion)
}

func getPlanPreviewDetailData(idx: Int, completion: @escaping (Result<[PlanPreviewData.Body]?, Error>) -> Void) {
func getPlanPreviewDetailData(idx: Int, completion: @escaping (Result<[PlanPreviewEntity.Body]?, Error>) -> Void) {
requestObject(.getPlanPreviewData(idx: idx), completion: completion)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation


struct PlanPreviewEntity :Codable{
struct Body :Codable{
let datumDescription: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,50 @@

import Foundation

struct PlanPreviewData :Codable{
struct Body :Codable{
let datumDescription: String
let photoUrls: [String]

enum CodingKeys: String, CodingKey {
case datumDescription = "description"
case photoUrls = "photo_urls"
}
struct PlanPreviewModel{ }


// MARK: - Header

extension PlanPreviewModel{
struct Header{
var writer : String
var title : String
}
}
// MARK: - Description

extension PlanPreviewModel{
struct Description{
var descriptionContent : String
var summary : IconData
}

struct Header: Codable {
let title, dataDescription: String
let price: Int
let tagTheme: String
let tagCountSpot, tagCountDay, tagCountRestaurant: Int
let tagPartner, tagMoney, tagMobility: String
let tagMonth: Int
let author: String
let authorID: Int

enum CodingKeys: String, CodingKey {
case title
case dataDescription = "description"
case price
case tagTheme = "tag_theme"
case tagCountSpot = "tag_count_spot"
case tagCountDay = "tag_count_day"
case tagCountRestaurant = "tag_count_restaurant"
case tagPartner = "tag_partner"
case tagMoney = "tag_money"
case tagMobility = "tag_mobility"
case tagMonth = "tag_month"
case author
case authorID = "author_id"
}
struct IconData{
var theme : String
var spotCount : String
var restaurantCount : String
var dayCount : String
var peopleCase : String
var budget : String
var transport : String
var month : String
}
}

// MARK: - Photo

extension PlanPreviewModel{
struct Photo{
var photo : String
var content : String
}
}

// MARK: - Summary

extension PlanPreviewModel{
struct Summary{
var content : String
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@

import Foundation

class PlanPreviewUseCase{
final class PlanPreviewUseCase{
let repository = BaseService.default


var headerData : PlanPreview.HeaderData?
var descriptionData : PlanPreview.DescriptionData?
var photoData : [PlanPreview.PhotoData]?
var summaryData : PlanPreview.SummaryData?
var recommendData : PlanPreview.RecommendData?

func fetchBodyData(idx: Int){
repository.getPlanPreviewDetailData(idx: idx) { result in
result.success { list in
Expand Down

0 comments on commit 6355f46

Please sign in to comment.