Skip to content

Commit 3cedb99

Browse files
authored
Merge pull request #200 from EAT-SSU/feat/#199
[#199] 고정/변동메뉴 조회 DTO 변경사항 prod 적용
2 parents 35cb05c + ac2c3db commit 3cedb99

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

EATSSU_MVC/EATSSU_MVC/Sources/Data/Network/DTO/Home/ChangeMenuTableResponse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import Foundation
1010
struct ChangeMenuTableResponse: Codable {
1111
let mealId: Int?
1212
let price: Int?
13-
let mainRating: Double?
14-
var menusInformationList: [MenusInformation]
13+
let rating: Double?
14+
let briefMenus: [BriefMenus]
1515
}
1616

17-
struct MenusInformation: Codable {
17+
struct BriefMenus: Codable {
1818
let menuId: Int
1919
let name: String
2020
}

EATSSU_MVC/EATSSU_MVC/Sources/Data/Network/DTO/Home/FixedMenuTableResponse.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
import Foundation
99

1010
struct FixedMenuTableResponse: Codable {
11-
let categoryMenuListCollection: [CategoryMenu]
11+
let categoryMenuListCollection: [CategoryMenuListCollection]
1212
}
1313

14-
struct CategoryMenu: Codable {
14+
struct CategoryMenuListCollection: Codable {
1515
let category: String
16-
let menuInformationList: [MenuInformation]
16+
let menus: [Menus]
1717
}
1818

19-
struct MenuInformation: Codable {
19+
struct Menus: Codable {
2020
let menuId: Int
2121
let name: String
22-
let mainRating: Double?
2322
let price: Int?
23+
let rating: Double?
2424
}

EATSSU_MVC/EATSSU_MVC/Sources/Presentation/Home/Enum/MenuTypeInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import Foundation
99

1010
enum MenuTypeInfo {
1111
case change(ChangeMenuTableResponse)
12-
case fix(MenuInformation)
12+
case fix(Menus)
1313
}

EATSSU_MVC/EATSSU_MVC/Sources/Presentation/Home/View/RestaurantTableView/RestaurantTableViewMenuCell.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,24 @@ extension RestaurantTableViewMenuCell {
9898
case .change(let data):
9999
priceLabel.text = data.price != nil ? data.price?.formattedWithCommas : ""
100100

101-
if data.mainRating != nil {
102-
let formatRating = String(format: "%.1f", data.mainRating ?? 0)
101+
if data.rating != nil {
102+
let formatRating = String(format: "%.1f", data.rating ?? 0)
103103
ratingLabel.text = formatRating
104104
} else {
105105
ratingLabel.text = TextLiteral.Home.emptyRating
106106
}
107107

108-
if data.menusInformationList.isEmpty {
108+
if data.briefMenus.isEmpty {
109109
// vc에서 이미 필터링되어 의미 없음. 리팩 필요
110110
nameLabel.text = "제공되는 메뉴가 없습니다"
111111
} else {
112-
nameLabel.text = data.menusInformationList.map { $0.name }.joined(separator: "+")
112+
nameLabel.text = data.briefMenus.map { $0.name }.joined(separator: "+")
113113
}
114114

115115
case .fix(let data):
116116
if let price = data.price {
117117
priceLabel.text = price.formattedWithCommas
118-
let formatRating = String(format: "%.1f", data.mainRating ?? 0)
118+
let formatRating = String(format: "%.1f", data.rating ?? 0)
119119
ratingLabel.text = formatRating != "0.0" ? formatRating : "-"
120120
nameLabel.text = data.name
121121
} else {

EATSSU_MVC/EATSSU_MVC/Sources/Presentation/Home/ViewController/HomeRestaurantViewController.swift

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,30 @@ final class HomeRestaurantViewController: BaseViewController {
3434
TextLiteral.studentRestaurant,
3535
TextLiteral.snackCorner]
3636
let restaurantButtonTitleToName = [TextLiteral.dormitoryRestaurant: "DORMITORY",
37-
TextLiteral.dodamRestaurant: "DODAM",
38-
TextLiteral.studentRestaurant: "HAKSIK",
39-
TextLiteral.snackCorner: "SNACK_CORNER"]
37+
TextLiteral.dodamRestaurant: "DODAM",
38+
TextLiteral.studentRestaurant: "HAKSIK",
39+
TextLiteral.snackCorner: "SNACK_CORNER"]
4040
var currentRestaurant = ""
4141
var isWeekend = false
4242
var isSelectable = false
43-
43+
4444
var changeMenuTableViewData: [String: [ChangeMenuTableResponse]] = [:] {
4545
didSet {
4646
// 빈 name을 가지지 않은 ChangeMenuTableResponse만 필터링
4747
changeMenuTableViewData = changeMenuTableViewData.mapValues { menuTableResponses in
4848
menuTableResponses.filter { response in
49-
!(response.menusInformationList.first?.name.isEmpty ?? true)
49+
!(response.briefMenus.first?.name.isEmpty ?? true)
5050
}
5151
}
52-
52+
5353
// 필터링된 데이터로 테이블 뷰 섹션을 새로고침
5454
if let sectionIndex = getSectionIndex(for: currentRestaurant) {
5555
restaurantView.restaurantTableView.reloadSections([sectionIndex], with: .automatic)
5656
}
5757
}
5858
}
59-
60-
var fixMenuTableViewData: [String: [MenuInformation]] = [:] {
59+
60+
var fixMenuTableViewData: [String: [Menus]] = [:] {
6161
didSet {
6262
if let sectionIndex = getSectionIndex(for: currentRestaurant) {
6363
restaurantView.restaurantTableView.reloadSections([sectionIndex], with: .automatic)
@@ -85,7 +85,7 @@ final class HomeRestaurantViewController: BaseViewController {
8585
override func configureUI() {
8686
view.addSubviews(restaurantView)
8787
}
88-
88+
8989
override func setLayout() {
9090
restaurantView.snp.makeConstraints {
9191
$0.edges.equalToSuperview()
@@ -121,7 +121,7 @@ final class HomeRestaurantViewController: BaseViewController {
121121
Restaurant.snackCorner.identifier]
122122
return restaurantRawValue[section]
123123
}
124-
124+
125125
func fetchData(date: Date, time: String) {
126126
let formatDate = changeDateFormat(date: date)
127127
getChageMenuData(date: formatDate, restaurant: Restaurant.dormitoryRestaurant.identifier, time: time) {}
@@ -130,14 +130,14 @@ final class HomeRestaurantViewController: BaseViewController {
130130

131131
let weekday = Weekday.from(date: date)
132132
isWeekend = weekday.isWeekend
133-
133+
134134
if time == TextLiteral.lunchRawValue {
135-
135+
136136
if !FirebaseRemoteConfig.shared.isVacationPeriod && !weekday.isWeekend {
137137
getFixMenuData(restaurant: TextLiteral.snackCornerRawValue) {}
138138
} else {
139139
currentRestaurant = Restaurant.snackCorner.identifier
140-
self.fixMenuTableViewData[Restaurant.snackCorner.identifier] = [MenuInformation(menuId: 0, name: "", mainRating: nil, price: nil)]
140+
self.fixMenuTableViewData[Restaurant.snackCorner.identifier] = [Menus(menuId: 0, name: "", price: nil, rating: nil)]
141141
}
142142
}
143143
}
@@ -170,7 +170,7 @@ extension HomeRestaurantViewController: UITableViewDataSource {
170170
}
171171

172172
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
173-
173+
174174
/// Menu Title Cell
175175
if indexPath.row == 0 {
176176
let cell = tableView.dequeueReusableCell(withIdentifier: RestaurantTableViewMenuTitleCell.identifier, for: indexPath)
@@ -209,12 +209,12 @@ extension HomeRestaurantViewController: UITableViewDataSource {
209209
return cell
210210
}
211211
}
212-
212+
213213
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
214214
guard let restaurantTableViewHeader = tableView.dequeueReusableHeaderFooterView(withIdentifier: RestaurantTableViewHeader.identifier) as? RestaurantTableViewHeader else {
215215
return nil
216216
}
217-
217+
218218
let restaurantName = sectionHeaderRestaurant[section]
219219
restaurantTableViewHeader.titleLabel.text = restaurantName
220220

@@ -241,7 +241,7 @@ extension HomeRestaurantViewController: UITableViewDataSource {
241241
}
242242

243243
}
244-
244+
245245
// MARK: - UITableViewDelegate
246246

247247
extension HomeRestaurantViewController: UITableViewDelegate {
@@ -255,15 +255,15 @@ extension HomeRestaurantViewController: UITableViewDelegate {
255255
if indexPath.row == 0 {
256256
return
257257
}
258-
258+
259259
let restaurant = getSectionKey(for: indexPath.section)
260260
/// bind Data
261261
var reviewMenuTypeInfo: ReviewMenuTypeInfo = ReviewMenuTypeInfo(menuType: "", menuID: 0)
262262

263263
if [0, 1, 2].contains(indexPath.section) {
264264
reviewMenuTypeInfo.menuType = "VARIABLE"
265265
reviewMenuTypeInfo.menuID = changeMenuTableViewData[restaurant]?[indexPath.row - restaurantTableViewMenuTitleCellCount].mealId ?? 100
266-
if let list = changeMenuTableViewData[restaurant]?[indexPath.row - restaurantTableViewMenuTitleCellCount].menusInformationList {
266+
if let list = changeMenuTableViewData[restaurant]?[indexPath.row - restaurantTableViewMenuTitleCellCount].briefMenus {
267267
reviewMenuTypeInfo.changeMenuIDList = list.compactMap { $0.menuId }
268268
}
269269
} else if [3, 4, 5].contains(indexPath.section) {
@@ -281,9 +281,9 @@ extension HomeRestaurantViewController: UITableViewDelegate {
281281

282282
delegate?.didDelegateReviewMenuTypeInfo(for: reviewMenuTypeInfo)
283283
}
284-
285-
}
286284

285+
}
286+
287287
// MARK: - Network
288288

289289
extension HomeRestaurantViewController {
@@ -315,9 +315,9 @@ extension HomeRestaurantViewController {
315315
let responseDetailDto = try responseData.map(BaseResponse<FixedMenuTableResponse>.self)
316316
let responseResult = responseDetailDto.result
317317

318-
var allMenuInformations = [MenuInformation]()
318+
var allMenuInformations = [Menus]()
319319
for categoryMenu in responseResult.categoryMenuListCollection {
320-
allMenuInformations += categoryMenu.menuInformationList
320+
allMenuInformations += categoryMenu.menus
321321
}
322322
self.fixMenuTableViewData[restaurant] = allMenuInformations
323323
} catch(let err) {

0 commit comments

Comments
 (0)