Skip to content

Commit a188266

Browse files
committed
[Pl-29] Entity 모듈 적용, 모델 프로퍼티 수정
1 parent 43fd31a commit a188266

6 files changed

Lines changed: 58 additions & 97 deletions

File tree

AppPackage/Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ let package = Package(
7979
name: "TimeTableFeature",
8080
dependencies: [
8181
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
82-
.product(name: "APIClient", package: "Planz-iOS-APIClient")
82+
"APIClient",
83+
"APIClientLive"
8384
]
8485
),
8586
.target(

AppPackage/Sources/Entity/Model.swift

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,31 @@ public struct UpdateUsernameRequest: Encodable, Equatable {
3030
public struct CreatePromisingRequest: Encodable, Equatable {
3131
private enum CodingKeys: String, CodingKey {
3232
case name = "promisingName"
33-
case startDate = "minTime"
34-
case endDate = "maxTime"
33+
case minTime
34+
case maxTime
3535
case categoryID = "categoryId"
3636
case availableDates
3737
case place = "placeName"
3838
}
3939

4040
public let name: String
41-
public let startDate: Date
42-
public let endDate: Date
41+
public let minTime: String
42+
public let maxTime: String
4343
public let categoryID: Int
44-
public let availableDates: [Date]
44+
public let availableDates: [String]
4545
public let place: String
4646

4747
public init(
4848
name: String,
49-
startDate: Date,
50-
endDate: Date,
49+
minTime: String,
50+
maxTime: String,
5151
categoryID: Int,
52-
availableDates: [Date],
52+
availableDates: [String],
5353
place: String
5454
) {
5555
self.name = name
56-
self.startDate = startDate
57-
self.endDate = endDate
56+
self.minTime = minTime
57+
self.maxTime = maxTime
5858
self.categoryID = categoryID
5959
self.availableDates = availableDates
6060
self.place = place
@@ -74,29 +74,21 @@ public struct CreatePromisingResponse: Decodable, Equatable {
7474
}
7575

7676
public struct PromisingSessionResponse: Decodable, Equatable {
77-
private enum CodingKeys: String, CodingKey {
78-
case startDate = "minTime"
79-
case endDate = "maxTime"
80-
case totalCount
81-
case unit
82-
case availableDates
83-
}
84-
85-
public let startDate: Date
86-
public let endDate: Date
77+
public let minTime: String
78+
public let maxTime: String
8779
public let totalCount: Int
88-
public let unit: Int
89-
public let availableDates: [Date]
80+
public let unit: Double
81+
public let availableDates: [String]
9082

9183
public init(
92-
startDate: Date,
93-
endDate: Date,
84+
minTime: String,
85+
maxTime: String,
9486
totalCount: Int,
95-
unit: Int,
96-
availableDates: [Date]
87+
unit: Double,
88+
availableDates: [String]
9789
) {
98-
self.startDate = startDate
99-
self.endDate = endDate
90+
self.minTime = minTime
91+
self.maxTime = maxTime
10092
self.totalCount = totalCount
10193
self.unit = unit
10294
self.availableDates = availableDates
@@ -172,12 +164,28 @@ public struct PromisingSession: Codable, Equatable {
172164
}
173165

174166
public struct PromisingTime: Codable, Equatable {
175-
public let unit: Int
176-
public let timeTable: TimeTable
167+
public let unit: Double
168+
public let timeTable: [TimeTable]
177169

178170
public struct TimeTable: Codable, Equatable {
179-
public let date: Date
171+
public let date: String
180172
public let times: [Bool]
173+
174+
public init(
175+
date: String,
176+
times: [Bool]
177+
) {
178+
self.date = date
179+
self.times = times
180+
}
181+
}
182+
183+
public init(
184+
unit: Double,
185+
timeTable: [TimeTable]
186+
) {
187+
self.unit = unit
188+
self.timeTable = timeTable
181189
}
182190
}
183191

AppPackage/Sources/MakePromise/MakePromiseStore.swift

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import APIClient
1010
import CalendarFeature
1111
import ComposableArchitecture
12+
import Entity
1213
import Foundation
1314
import TimeTableFeature
1415

@@ -104,7 +105,7 @@ public struct MakePromise: ReducerProtocol {
104105
}
105106
}
106107

107-
var timeTable: TimeTable.State? {
108+
var timeTable: TimeTableFeature.TimeTable.State? {
108109
get {
109110
steps.compactMap { step in
110111
guard case let .timeTable(state) = step else {
@@ -148,7 +149,7 @@ public struct MakePromise: ReducerProtocol {
148149
case setNameAndPlace(SetNameAndPlace.State)
149150
case calendar(CalendarCore.State)
150151
case timeSelection(TimeSelection.State)
151-
case timeTable(TimeTable.State)
152+
case timeTable(TimeTableFeature.TimeTable.State)
152153
}
153154

154155
var isNextButtonEnable: Bool {
@@ -209,13 +210,13 @@ public struct MakePromise: ReducerProtocol {
209210
case dismiss
210211
case nextButtonTapped
211212
case backButtonTapped
212-
case temporaryPromisingResponse(TaskResult<SharedModels.CreatePromisingResponse>)
213-
case updatePromiseTimeRespose(TaskResult<SharedModels.UpdatePromiseTimeResponse>)
213+
case temporaryPromisingResponse(TaskResult<CreatePromisingResponse>)
214+
case updatePromiseTimeRespose(TaskResult<UpdatePromiseTimeResponse>)
214215
case selectTheme(SelectTheme.Action)
215216
case setNameAndPlace(SetNameAndPlace.Action)
216217
case calendar(CalendarCore.Action)
217218
case timeSelection(TimeSelection.Action)
218-
case timeTable(TimeTable.Action)
219+
case timeTable(TimeTableFeature.TimeTable.Action)
219220
case alert(PresentationAction<AlertAction>)
220221
}
221222

@@ -268,7 +269,7 @@ public struct MakePromise: ReducerProtocol {
268269
)
269270
)
270271
),
271-
as: SharedModels.UpdatePromiseTimeResponse.self
272+
as: UpdatePromiseTimeResponse.self
272273
)
273274
}
274275
)
@@ -329,7 +330,7 @@ public struct MakePromise: ReducerProtocol {
329330
)
330331
)
331332
),
332-
as: SharedModels.CreatePromisingResponse.self
333+
as: CreatePromisingResponse.self
333334
)
334335
}
335336
)
@@ -376,31 +377,6 @@ private enum Resource {
376377
}
377378
}
378379

379-
extension SharedModels.CreatePromisingResponse: Equatable {
380-
public static func == (lhs: SharedModels.CreatePromisingResponse, rhs: SharedModels.CreatePromisingResponse) -> Bool {
381-
lhs.id == rhs.id
382-
}
383-
}
384-
385-
extension SharedModels.PromisingTime: Equatable {
386-
public static func == (
387-
lhs: SharedModels.PromisingTime,
388-
rhs: SharedModels.PromisingTime
389-
) -> Bool {
390-
lhs.unit == rhs.unit
391-
&& lhs.timeTable.count == rhs.timeTable.count
392-
}
393-
}
394-
395-
extension SharedModels.UpdatePromiseTimeResponse: Equatable {
396-
public static func == (
397-
lhs: SharedModels.UpdatePromiseTimeResponse,
398-
rhs: SharedModels.UpdatePromiseTimeResponse
399-
) -> Bool {
400-
lhs.promiseID == rhs.promiseID
401-
}
402-
}
403-
404380
private var dateFormatter: DateFormatter = {
405381
let dateFormatter = DateFormatter()
406382
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"

AppPackage/Sources/MakePromise/SubViews/SelectThemeStore.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import APIClient
1010
import APIClientLive
1111
import ComposableArchitecture
12+
import Entity
1213
import Foundation
1314
import SwiftUI
1415

@@ -25,7 +26,7 @@ public struct SelectTheme: ReducerProtocol {
2526

2627
public enum Action: Equatable {
2728
case task
28-
case categoriesResponse(TaskResult<[SharedModels.Category]>)
29+
case categoriesResponse(TaskResult<[Entity.Category]>)
2930
case selectThemeItem(id: Int, action: SelectThemeItem.Action)
3031
}
3132

@@ -40,7 +41,7 @@ public struct SelectTheme: ReducerProtocol {
4041
TaskResult {
4142
try await apiClient.request(
4243
route: .promising(.fetchCategories),
43-
as: [SharedModels.Category].self
44+
as: [Entity.Category].self
4445
)
4546
}
4647
)
@@ -69,11 +70,3 @@ public struct SelectTheme: ReducerProtocol {
6970
}
7071
}
7172
}
72-
73-
extension SharedModels.Category: Equatable {
74-
public static func == (lhs: SharedModels.Category, rhs: SharedModels.Category) -> Bool {
75-
lhs.id == rhs.id
76-
&& lhs.keyword == rhs.keyword
77-
&& lhs.type == rhs.type
78-
}
79-
}

AppPackage/Sources/MakePromise/SubViews/SetNameAndPlaceStore.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import APIClient
1010
import APIClientLive
1111
import ComposableArchitecture
12+
import Entity
1213
import Foundation
1314

1415
public struct SetNameAndPlace: ReducerProtocol {
@@ -64,7 +65,7 @@ public struct SetNameAndPlace: ReducerProtocol {
6465

6566
public enum Action: Equatable {
6667
case task
67-
case placeHintResponse(TaskResult<SharedModels.CategoryName>)
68+
case placeHintResponse(TaskResult<CategoryName>)
6869
case filledPromiseName(String)
6970
case filledPromisePlace(String)
7071
}
@@ -80,7 +81,7 @@ public struct SetNameAndPlace: ReducerProtocol {
8081
TaskResult {
8182
try await apiClient.request(
8283
route: .promising(.randomName(id)),
83-
as: SharedModels.CategoryName.self
84+
as: CategoryName.self
8485
)
8586
}
8687
)
@@ -100,9 +101,3 @@ public struct SetNameAndPlace: ReducerProtocol {
100101
}
101102
}
102103
}
103-
104-
extension SharedModels.CategoryName: Equatable {
105-
public static func == (lhs: SharedModels.CategoryName, rhs: SharedModels.CategoryName) -> Bool {
106-
lhs.name == rhs.name
107-
}
108-
}

AppPackage/Sources/TimeTableFeature/TimeTableView.swift

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import APIClient
1010
import APIClientLive
1111
import ComposableArchitecture
12+
import Entity
1213
import SwiftUI
1314

1415
public struct TimeTable: ReducerProtocol {
@@ -98,7 +99,7 @@ public struct TimeTable: ReducerProtocol {
9899

99100
public enum Action: Equatable {
100101
case task
101-
case fetchSessionResponse(TaskResult<SharedModels.PromisingSessionResponse>)
102+
case fetchSessionResponse(TaskResult<PromisingSessionResponse>)
102103
case timeCellTapped(row: Int, column: Int)
103104
}
104105

@@ -116,7 +117,7 @@ public struct TimeTable: ReducerProtocol {
116117
TaskResult {
117118
try await apiClient.request(
118119
route: .promising(.fetchSession(id)),
119-
as: SharedModels.PromisingSessionResponse.self
120+
as: PromisingSessionResponse.self
120121
)
121122
}
122123
)
@@ -382,16 +383,3 @@ private var dateFormatter: DateFormatter = {
382383
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
383384
return dateFormatter
384385
}()
385-
386-
extension SharedModels.PromisingSessionResponse: Equatable {
387-
public static func == (
388-
lhs: SharedModels.PromisingSessionResponse,
389-
rhs: SharedModels.PromisingSessionResponse
390-
) -> Bool {
391-
lhs.minTime == rhs.minTime
392-
&& lhs.maxTime == rhs.maxTime
393-
&& lhs.totalCount == rhs.totalCount
394-
&& lhs.unit == rhs.unit
395-
&& lhs.availableDates == rhs.availableDates
396-
}
397-
}

0 commit comments

Comments
 (0)