Skip to content

Commit

Permalink
#41 Wine Tasting Note DTO 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
doyeonk429 committed Aug 16, 2024
1 parent d1ac4a0 commit ba9ac64
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Drink-EG/Drink-EG.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
165401072C6BA5D8008A9DBF /* MemberInfoRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 165401062C6BA5D8008A9DBF /* MemberInfoRequest.swift */; };
165401092C6BA644008A9DBF /* MemberInfoAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 165401082C6BA644008A9DBF /* MemberInfoAPI.swift */; };
1654010B2C6BACDC008A9DBF /* SelectionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1654010A2C6BACDC008A9DBF /* SelectionManager.swift */; };
1654014E2C6F9582008A9DBF /* APIResponseNoteResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1654014D2C6F9582008A9DBF /* APIResponseNoteResponse.swift */; };
165401502C6F960A008A9DBF /* NoteResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1654014F2C6F960A008A9DBF /* NoteResponse.swift */; };
16752F9D2C5A7FB90001907D /* HexCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16752F9C2C5A7FB90001907D /* HexCode.swift */; };
16B97CD42C4BEB0900D8B453 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16B97CD32C4BEB0900D8B453 /* AppDelegate.swift */; };
16B97CD62C4BEB0900D8B453 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16B97CD52C4BEB0900D8B453 /* SceneDelegate.swift */; };
Expand Down Expand Up @@ -129,6 +131,8 @@
165401062C6BA5D8008A9DBF /* MemberInfoRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemberInfoRequest.swift; sourceTree = "<group>"; };
165401082C6BA644008A9DBF /* MemberInfoAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemberInfoAPI.swift; sourceTree = "<group>"; };
1654010A2C6BACDC008A9DBF /* SelectionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectionManager.swift; sourceTree = "<group>"; };
1654014D2C6F9582008A9DBF /* APIResponseNoteResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIResponseNoteResponse.swift; sourceTree = "<group>"; };
1654014F2C6F960A008A9DBF /* NoteResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteResponse.swift; sourceTree = "<group>"; };
16752F9C2C5A7FB90001907D /* HexCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexCode.swift; sourceTree = "<group>"; };
16B97CD02C4BEB0900D8B453 /* Drink-EG.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Drink-EG.app"; sourceTree = BUILT_PRODUCTS_DIR; };
16B97CD32C4BEB0900D8B453 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -227,6 +231,7 @@
165401012C69F297008A9DBF /* WineNews */,
1F205A322C69FE9800E80659 /* JoinNLoginRequest.swift */,
165401062C6BA5D8008A9DBF /* MemberInfoRequest.swift */,
1654014F2C6F960A008A9DBF /* NoteResponse.swift */,
);
path = Datas;
sourceTree = "<group>";
Expand Down Expand Up @@ -256,6 +261,7 @@
165400F92C69F15D008A9DBF /* APIResponseWineNewsResponse.swift */,
165400FD2C69F218008A9DBF /* APIResponseWineClassResponse.swift */,
1F205A362C6A71BC00E80659 /* APIResponseLoginResponse.swift */,
1654014D2C6F9582008A9DBF /* APIResponseNoteResponse.swift */,
);
path = APIResponseModels;
sourceTree = "<group>";
Expand Down Expand Up @@ -613,6 +619,7 @@
1F598F0F2C5CBE70000CE79F /* FirstTasteTestViewController.swift in Sources */,
5E2219562C69D5E7005849FB /* ChooseTasteViewController.swift in Sources */,
165400F62C69EF89008A9DBF /* WineNewsRequest.swift in Sources */,
1654014E2C6F9582008A9DBF /* APIResponseNoteResponse.swift in Sources */,
5E2219552C69D5E7005849FB /* CustomSlider.swift in Sources */,
1654010B2C6BACDC008A9DBF /* SelectionManager.swift in Sources */,
16752F9D2C5A7FB90001907D /* HexCode.swift in Sources */,
Expand Down Expand Up @@ -642,6 +649,7 @@
5E2219432C69D5D0005849FB /* ModalViewController.swift in Sources */,
165400FC2C69F1A3008A9DBF /* WineClassRequest.swift in Sources */,
165401002C69F251008A9DBF /* WineClassResponse.swift in Sources */,
165401502C6F960A008A9DBF /* NoteResponse.swift in Sources */,
5E2219482C69D5D0005849FB /* CommunityListViewController.swift in Sources */,
5E2219492C69D5D0005849FB /* CommunityMainViewController.swift in Sources */,
16B97CD42C4BEB0900D8B453 /* AppDelegate.swift in Sources */,
Expand Down
26 changes: 26 additions & 0 deletions Drink-EG/Drink-EG/Sources/Datas/NoteResponse.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// NoteResponse.swift
// Drink-EG
//
// Created by 김도연 on 8/16/24.
//

import Foundation

struct NoteResponse : Codable {
let noteId : Int
let wineId : Int
let name : String
let picture : String
let color : String
let sugarContent : Int
let acidity : Int
let tannin : Int
let body : Int
let alcohol : Int
let scentAroma : [String]
let scentTaste : [String]
let scentFinish : [String]
let satisfaction : Double
let review : String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// APIResponseNoteResponse.swift
// Drink-EG
//
// Created by 김도연 on 8/16/24.
//

import Foundation

struct APIResponseNoteResponse : Codable {
let isSuccess : Bool
let code : String
let message : String
let result : NoteResponse
}
13 changes: 12 additions & 1 deletion Drink-EG/Drink-EG/Sources/VCs/Login/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class LoginViewController: UIViewController, UITextFieldDelegate {
public var userID : String?
public var userPW : String?
var loginDTO : JoinNLoginRequest?
public static var isFirstLogin : Bool = false

let loginButton = UIButton(type: .system)
let joinButton = UIButton(type: .system)
Expand Down Expand Up @@ -212,7 +213,12 @@ class LoginViewController: UIViewController, UITextFieldDelegate {
assignUserData()
callLoginAPI { [weak self] isSuccess in
if isSuccess {
self?.goToNextView()
if LoginViewController.isFirstLogin {
self?.goToNextView()
} else {
self?.goToHomeView()
}

} else {
print("로그인 실패")
// 실패 시에 대한 처리 (예: 에러 메시지 표시)
Expand All @@ -225,6 +231,11 @@ class LoginViewController: UIViewController, UITextFieldDelegate {
navigationController?.pushViewController(enterTasteTestViewController, animated: true)
}

private func goToHomeView() {
let homeViewController = MainTabBarViewController()
navigationController?.pushViewController(homeViewController, animated: true)
}

private func configureJoinButton() {
joinButton.setTitle("회원가입", for: .normal)
joinButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 14)
Expand Down
11 changes: 10 additions & 1 deletion Drink-EG/Drink-EG/Sources/VCs/NoteListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,22 @@ class NoteListViewController: UIViewController, UICollectionViewDelegate, UIColl
provider.request(TastingNoteAPI.getNoteID(noteId: noteId)) { result in
switch result {
case .success(let response):
self.handleNoteDetailsResponse(response)
do {
let responseData = try JSONDecoder().decode(APIResponseNoteResponse.self, from: response.data)
self.handleNoteData(responseData.result)
} catch {
print("Failed to decode response: \(error)")
}
case .failure(let error):
print("Request failed: \(error)")
}
}
}

func handleNoteData(_ data: NoteResponse) {
// TODO : 여기에서 데이터 처리하기
}

func handleNoteDetailsResponse(_ response: Response) {
do {
if let jsonData = try response.mapJSON() as? [String: Any] {
Expand Down

0 comments on commit ba9ac64

Please sign in to comment.