From db0d9589f5b43cf196b70053285d910c6490d593 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Tue, 10 Jan 2023 01:37:16 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[Feat]=20#63=20-=20CourseDrawingRequestDto?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS.xcodeproj/project.pbxproj | 26 ++++++++++++++++++- .../Global/Utils/convertLocationObject.swift | 4 +++ .../RequestDto/CourseDrawingRequestDto.swift | 23 ++++++++++++++++ .../DepartureSearchingResponseDto.swift | 0 .../CourseDrawingModel/RNLocationModel.swift | 13 ++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.swift rename Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/{ => ResponseDto}/DepartureSearchingResponseDto.swift (100%) create mode 100644 Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/RNLocationModel.swift diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 35936682..52b4057e 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ CE17F0352961BEF800E1DED0 /* Pretendard-SemiBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = CE17F0312961BEF800E1DED0 /* Pretendard-SemiBold.otf */; }; CE17F0362961BEF800E1DED0 /* Pretendard-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = CE17F0322961BEF800E1DED0 /* Pretendard-Regular.otf */; }; CE17F0382961BF8B00E1DED0 /* FontLiterals.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE17F0372961BF8B00E1DED0 /* FontLiterals.swift */; }; + CE18E890296C76C100FEB569 /* RNLocationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE18E88F296C76C100FEB569 /* RNLocationModel.swift */; }; + CE18E894296C79B900FEB569 /* CourseDrawingRequestDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE18E893296C79B900FEB569 /* CourseDrawingRequestDto.swift */; }; CE29D582296402B500F47542 /* CourseDrawingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE29D581296402B500F47542 /* CourseDrawingVC.swift */; }; CE29D584296416D800F47542 /* caculateStatusBarHeight.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE29D583296416D800F47542 /* caculateStatusBarHeight.swift */; }; CE3A53C5296C6017003D518C /* KeychainManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3A53C4296C6017003D518C /* KeychainManager.swift */; }; @@ -172,6 +174,8 @@ CE17F0312961BEF800E1DED0 /* Pretendard-SemiBold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-SemiBold.otf"; sourceTree = ""; }; CE17F0322961BEF800E1DED0 /* Pretendard-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Regular.otf"; sourceTree = ""; }; CE17F0372961BF8B00E1DED0 /* FontLiterals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontLiterals.swift; sourceTree = ""; }; + CE18E88F296C76C100FEB569 /* RNLocationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNLocationModel.swift; sourceTree = ""; }; + CE18E893296C79B900FEB569 /* CourseDrawingRequestDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDrawingRequestDto.swift; sourceTree = ""; }; CE29D581296402B500F47542 /* CourseDrawingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDrawingVC.swift; sourceTree = ""; }; CE29D583296416D800F47542 /* caculateStatusBarHeight.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = caculateStatusBarHeight.swift; sourceTree = ""; }; CE3A53C4296C6017003D518C /* KeychainManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainManager.swift; sourceTree = ""; }; @@ -409,7 +413,8 @@ CE10063729680C2400FD31FB /* CourseDrawingDto */ = { isa = PBXGroup; children = ( - CE10065429680F7000FD31FB /* DepartureSearchingResponseDto.swift */, + CE18E891296C799900FEB569 /* RequestDto */, + CE18E892296C79A100FEB569 /* ResponseDto */, ); path = CourseDrawingDto; sourceTree = ""; @@ -466,6 +471,7 @@ isa = PBXGroup; children = ( CE1006562968230800FD31FB /* DepartureLocationModel.swift */, + CE18E88F296C76C100FEB569 /* RNLocationModel.swift */, ); path = CourseDrawingModel; sourceTree = ""; @@ -660,6 +666,22 @@ path = Views; sourceTree = ""; }; + CE18E891296C799900FEB569 /* RequestDto */ = { + isa = PBXGroup; + children = ( + CE18E893296C79B900FEB569 /* CourseDrawingRequestDto.swift */, + ); + path = RequestDto; + sourceTree = ""; + }; + CE18E892296C79A100FEB569 /* ResponseDto */ = { + isa = PBXGroup; + children = ( + CE10065429680F7000FD31FB /* DepartureSearchingResponseDto.swift */, + ); + path = ResponseDto; + sourceTree = ""; + }; CE40BB25296807FC0030ABCA /* SignInRouter */ = { isa = PBXGroup; children = ( @@ -1261,6 +1283,7 @@ CE6655D0295D85FF00C64E12 /* CancelBag.swift in Sources */, DA20D83F296696A000F1581F /* MapModel.swift in Sources */, A3BC2F432966A93100198261 /* CourseDetailVC.swift in Sources */, + CE18E890296C76C100FEB569 /* RNLocationModel.swift in Sources */, A3BC2F3D296468E500198261 /* UploadedCourseInfoModel.swift in Sources */, DA20D8502966C0D500F1581F /* MapCollectionViewController.swift in Sources */, CE6655DC295D873500C64E12 /* UIButton+.swift in Sources */, @@ -1268,6 +1291,7 @@ CE0D9FD329648DA300CEB5CD /* CustomAlertVC.swift in Sources */, CEB841702963360800BF8080 /* CountDownVC.swift in Sources */, DA20D84E2966A9B300F1581F /* SearchVC.swift in Sources */, + CE18E894296C79B900FEB569 /* CourseDrawingRequestDto.swift in Sources */, CE1006572968230800FD31FB /* DepartureLocationModel.swift in Sources */, CE6655EC295D88D000C64E12 /* UITableView+.swift in Sources */, CECBAD2F296C2F3C00AC8976 /* SignInRouter.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Global/Utils/convertLocationObject.swift b/Runnect-iOS/Runnect-iOS/Global/Utils/convertLocationObject.swift index 0c475e9f..e06f2fe6 100644 --- a/Runnect-iOS/Runnect-iOS/Global/Utils/convertLocationObject.swift +++ b/Runnect-iOS/Runnect-iOS/Global/Utils/convertLocationObject.swift @@ -26,6 +26,10 @@ extension NMGLatLng { func toCLLocation() -> CLLocation { return CLLocation(latitude: lat, longitude: lng) } + + func toRNLocationModel() -> RNLocationModel { + return RNLocationModel(lat: self.lat, long: self.lng) + } } extension DepartureLocationModel { diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.swift new file mode 100644 index 00000000..75000491 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.swift @@ -0,0 +1,23 @@ +// +// CourseDrawingRequestDto.swift +// Runnect-iOS +// +// Created by sejin on 2023/01/10. +// + +import Foundation + +// MARK: - CourseDrawingRequestDto + +struct CourseDrawingRequestDto: Codable { + let image: Data + let data: CourseDrawingRequestData +} + +// MARK: - CourseDrawingRequestData + +struct CourseDrawingRequestData: Codable { + let path: [RNLocationModel] + let distance: Float + let departureAddress, departureName: String +} diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/DepartureSearchingResponseDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/DepartureSearchingResponseDto.swift similarity index 100% rename from Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/DepartureSearchingResponseDto.swift rename to Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/DepartureSearchingResponseDto.swift diff --git a/Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/RNLocationModel.swift b/Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/RNLocationModel.swift new file mode 100644 index 00000000..736e2712 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/RNLocationModel.swift @@ -0,0 +1,13 @@ +// +// RNLocationModel.swift +// Runnect-iOS +// +// Created by sejin on 2023/01/10. +// + +import Foundation + +struct RNLocationModel: Codable { + let lat: Double + let long: Double +} From bb5104898dd49bc7a0d5c3bf7deacde65ed611ad Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Tue, 10 Jan 2023 03:34:52 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[Feat]=20#63=20-=20=EA=B7=B8=EB=A6=B0=20?= =?UTF-8?q?=EC=BD=94=EC=8A=A4=20=EC=97=85=EB=A1=9C=EB=93=9C=20API=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS.xcodeproj/project.pbxproj | 16 +++- .../CourseDrawingResponseData.swift | 22 ++++++ .../Network/Model/RunningModel/.gitkeep | 0 .../Model/RunningModel/RunningModel.swift | 18 +++++ .../CourseDrawingRouter.swift | 79 +++++++++++++++++++ .../Network/Router/SignInRouter/.gitkeep | 0 .../CourseDrawing/VC/CourseDrawingVC.swift | 67 ++++++++++++++-- 7 files changed, 193 insertions(+), 9 deletions(-) create mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.swift delete mode 100644 Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/.gitkeep create mode 100644 Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift create mode 100644 Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.swift delete mode 100644 Runnect-iOS/Runnect-iOS/Network/Router/SignInRouter/.gitkeep diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 52b4057e..c3e29e6c 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ CE14677829658C7200DCEA1B /* Stopwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14677729658C7200DCEA1B /* Stopwatch.swift */; }; CE14677A2965A80700DCEA1B /* CustomBottomSheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1467792965A80700DCEA1B /* CustomBottomSheetVC.swift */; }; CE14677C2965C1B100DCEA1B /* RunningRecordVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14677B2965C1B100DCEA1B /* RunningRecordVC.swift */; }; + CE15F5A4296C932E0023827C /* RunningModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE15F5A3296C932E0023827C /* RunningModel.swift */; }; CE17F02D2961BBA100E1DED0 /* ColorLiterals.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE17F02C2961BBA100E1DED0 /* ColorLiterals.swift */; }; CE17F0332961BEF800E1DED0 /* Pretendard-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = CE17F02F2961BEF800E1DED0 /* Pretendard-Medium.otf */; }; CE17F0342961BEF800E1DED0 /* Pretendard-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = CE17F0302961BEF800E1DED0 /* Pretendard-Bold.otf */; }; @@ -39,6 +40,8 @@ CE18E894296C79B900FEB569 /* CourseDrawingRequestDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE18E893296C79B900FEB569 /* CourseDrawingRequestDto.swift */; }; CE29D582296402B500F47542 /* CourseDrawingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE29D581296402B500F47542 /* CourseDrawingVC.swift */; }; CE29D584296416D800F47542 /* caculateStatusBarHeight.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE29D583296416D800F47542 /* caculateStatusBarHeight.swift */; }; + CE320F36296C8EAB009F89A7 /* CourseDrawingRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE320F35296C8EAB009F89A7 /* CourseDrawingRouter.swift */; }; + CE320F38296C8FAB009F89A7 /* CourseDrawingResponseData.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE320F37296C8FAB009F89A7 /* CourseDrawingResponseData.swift */; }; CE3A53C5296C6017003D518C /* KeychainManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3A53C4296C6017003D518C /* KeychainManager.swift */; }; CE40BB1C2967E4910030ABCA /* RunningWaitingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE40BB1B2967E4910030ABCA /* RunningWaitingVC.swift */; }; CE40BB1E2968054F0030ABCA /* BaseResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE40BB1D2968054F0030ABCA /* BaseResponse.swift */; }; @@ -150,7 +153,6 @@ CE10063D29680C8100FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10063E29680C8800FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10063F29680C9800FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE10064029680C9F00FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10064129680CA700FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10064229680CAD00FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10064329680CB400FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; @@ -161,13 +163,13 @@ CE10065029680D3800FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10065129680D3F00FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10065229680D4400FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE10065329680D5400FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10065429680F7000FD31FB /* DepartureSearchingResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DepartureSearchingResponseDto.swift; sourceTree = ""; }; CE1006562968230800FD31FB /* DepartureLocationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DepartureLocationModel.swift; sourceTree = ""; }; CE14676F296568DC00DCEA1B /* RunTrackingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunTrackingVC.swift; sourceTree = ""; }; CE14677729658C7200DCEA1B /* Stopwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stopwatch.swift; sourceTree = ""; }; CE1467792965A80700DCEA1B /* CustomBottomSheetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBottomSheetVC.swift; sourceTree = ""; }; CE14677B2965C1B100DCEA1B /* RunningRecordVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunningRecordVC.swift; sourceTree = ""; }; + CE15F5A3296C932E0023827C /* RunningModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunningModel.swift; sourceTree = ""; }; CE17F02C2961BBA100E1DED0 /* ColorLiterals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorLiterals.swift; sourceTree = ""; }; CE17F02F2961BEF800E1DED0 /* Pretendard-Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Medium.otf"; sourceTree = ""; }; CE17F0302961BEF800E1DED0 /* Pretendard-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Bold.otf"; sourceTree = ""; }; @@ -178,6 +180,8 @@ CE18E893296C79B900FEB569 /* CourseDrawingRequestDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDrawingRequestDto.swift; sourceTree = ""; }; CE29D581296402B500F47542 /* CourseDrawingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDrawingVC.swift; sourceTree = ""; }; CE29D583296416D800F47542 /* caculateStatusBarHeight.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = caculateStatusBarHeight.swift; sourceTree = ""; }; + CE320F35296C8EAB009F89A7 /* CourseDrawingRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDrawingRouter.swift; sourceTree = ""; }; + CE320F37296C8FAB009F89A7 /* CourseDrawingResponseData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDrawingResponseData.swift; sourceTree = ""; }; CE3A53C4296C6017003D518C /* KeychainManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainManager.swift; sourceTree = ""; }; CE40BB1B2967E4910030ABCA /* RunningWaitingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunningWaitingVC.swift; sourceTree = ""; }; CE40BB1D2968054F0030ABCA /* BaseResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseResponse.swift; sourceTree = ""; }; @@ -430,7 +434,7 @@ CE10064629680CE600FD31FB /* RunningModel */ = { isa = PBXGroup; children = ( - CE10065329680D5400FD31FB /* .gitkeep */, + CE15F5A3296C932E0023827C /* RunningModel.swift */, ); path = RunningModel; sourceTree = ""; @@ -678,6 +682,7 @@ isa = PBXGroup; children = ( CE10065429680F7000FD31FB /* DepartureSearchingResponseDto.swift */, + CE320F37296C8FAB009F89A7 /* CourseDrawingResponseData.swift */, ); path = ResponseDto; sourceTree = ""; @@ -685,7 +690,6 @@ CE40BB25296807FC0030ABCA /* SignInRouter */ = { isa = PBXGroup; children = ( - CE10064029680C9F00FD31FB /* .gitkeep */, CECBAD2E296C2F3C00AC8976 /* SignInRouter.swift */, ); path = SignInRouter; @@ -695,6 +699,7 @@ isa = PBXGroup; children = ( CE40BB2C296808B00030ABCA /* DepartureSearchingRouter.swift */, + CE320F35296C8EAB009F89A7 /* CourseDrawingRouter.swift */, ); path = CourseDrawingRouter; sourceTree = ""; @@ -1235,6 +1240,7 @@ CE665602295D918000C64E12 /* JsonCoder.swift in Sources */, CE4545CD295D7AF4003201E1 /* TaBarController.swift in Sources */, CE6655F4295D898400C64E12 /* UIViewController+.swift in Sources */, + CE320F36296C8EAB009F89A7 /* CourseDrawingRouter.swift in Sources */, CE14677829658C7200DCEA1B /* Stopwatch.swift in Sources */, CE40BB22296806140030ABCA /* NetworkHelper.swift in Sources */, CE5645162961B72E000A2856 /* ImageLiterals.swift in Sources */, @@ -1291,6 +1297,7 @@ CE0D9FD329648DA300CEB5CD /* CustomAlertVC.swift in Sources */, CEB841702963360800BF8080 /* CountDownVC.swift in Sources */, DA20D84E2966A9B300F1581F /* SearchVC.swift in Sources */, + CE320F38296C8FAB009F89A7 /* CourseDrawingResponseData.swift in Sources */, CE18E894296C79B900FEB569 /* CourseDrawingRequestDto.swift in Sources */, CE1006572968230800FD31FB /* DepartureLocationModel.swift in Sources */, CE6655EC295D88D000C64E12 /* UITableView+.swift in Sources */, @@ -1321,6 +1328,7 @@ CE14677A2965A80700DCEA1B /* CustomBottomSheetVC.swift in Sources */, CEEC6B4B2961D89700D00E1E /* CustomNavigationBar.swift in Sources */, CE40BB2D296808B00030ABCA /* DepartureSearchingRouter.swift in Sources */, + CE15F5A4296C932E0023827C /* RunningModel.swift in Sources */, CE17F02D2961BBA100E1DED0 /* ColorLiterals.swift in Sources */, CEC2A68E2962AF2C00160BF7 /* RNMarker.swift in Sources */, CE6655D2295D862A00C64E12 /* Publisher+Driver.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.swift new file mode 100644 index 00000000..2b89aa09 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.swift @@ -0,0 +1,22 @@ +// +// CourseDrawingResponseData.swift +// Runnect-iOS +// +// Created by sejin on 2023/01/10. +// + +import Foundation + + +// MARK: - DataClass + +struct CourseDrawingResponseData: Codable { + let course: CourseDrawingResponse +} + +// MARK: - Course + +struct CourseDrawingResponse: Codable { + let id: Int + let createdAt: String +} diff --git a/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/.gitkeep b/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift b/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift new file mode 100644 index 00000000..512ac56f --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift @@ -0,0 +1,18 @@ +// +// RunningModel.swift +// Runnect-iOS +// +// Created by sejin on 2023/01/10. +// + +import Foundation + +import NMapsMap + +struct RunningModel { + var courseId: Int? + var publicCourseId: Int? + var locations: [NMGLatLng] + var distance: String? + var pathImage: UIImage? +} diff --git a/Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.swift b/Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.swift new file mode 100644 index 00000000..972c407a --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.swift @@ -0,0 +1,79 @@ +// +// CourseDrawingRouter.swift +// Runnect-iOS +// +// Created by sejin on 2023/01/10. +// + +import Foundation + +import Moya + +enum CourseDrawingRouter { + case uploadCourseDrawing(param: CourseDrawingRequestDto) +} + +extension CourseDrawingRouter: TargetType { + var baseURL: URL { + guard let url = URL(string: Config.baseURL) else { + fatalError("baseURL could not be configured") + } + + return url + } + + var path: String { + switch self { + case .uploadCourseDrawing: + return "/course" + } + } + + var method: Moya.Method { + switch self { + case .uploadCourseDrawing: + return .post + } + } + + var task: Moya.Task { + switch self { + case .uploadCourseDrawing(let param): + var multipartFormData: [MultipartFormData] = [] + + let imageData = MultipartFormData(provider: .data(param.image), + name: "image", fileName: "image.jpeg", + mimeType: "image/jpeg") + + multipartFormData.append(imageData) + + var content = [String: Any]() + + var path = [[String: Any]]() + + for location in param.data.path { + let locationData = try! location.asParameter() + path.append(locationData) + } + + content["path"] = path + content["distance"] = param.data.distance + content["departureAddress"] = param.data.departureAddress + content["departureName"] = param.data.departureName + + let jsonData = try! JSONSerialization.data(withJSONObject: content) + let formData = MultipartFormData(provider: .data(jsonData), name: "data", mimeType: "application/json") + multipartFormData.append(formData) + + return .uploadMultipart(multipartFormData) + } + } + + var headers: [String: String]? { + switch self { + case .uploadCourseDrawing: + return ["Content-Type": "multipart/form-data", + "machineId": Config.deviceId] + } + } +} diff --git a/Runnect-iOS/Runnect-iOS/Network/Router/SignInRouter/.gitkeep b/Runnect-iOS/Runnect-iOS/Network/Router/SignInRouter/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift index 432139a3..96c7be23 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift @@ -8,13 +8,20 @@ import UIKit import Combine +import Moya + final class CourseDrawingVC: UIViewController { // MARK: - Properties + private let courseDrawingProvider = MoyaProvider( + plugins: [NetworkLoggerPlugin(verbose: true)] + ) + private var departureLocationModel: DepartureLocationModel? var pathImage: UIImage? + var distance: Float = 0.0 private var cancelBag = CancelBag() @@ -129,6 +136,7 @@ extension CourseDrawingVC { guard let self = self else { return } let kilometers = String(format: "%.1f", distance/1000) self.distanceLabel.text = kilometers + self.distance = Float(kilometers) ?? 0.0 }.store(in: cancelBag) mapView.$markerCount.sink { [weak self] count in @@ -140,7 +148,7 @@ extension CourseDrawingVC { mapView.pathImage.sink { [weak self] image in guard let self = self else { return } self.pathImage = image - self.presentAlertVC() + self.uploadCourseDrawing() }.store(in: cancelBag) } @@ -148,7 +156,7 @@ extension CourseDrawingVC { navigationController?.interactivePopGestureRecognizer?.isEnabled = isEnabled } - private func presentAlertVC() { + private func presentAlertVC(courseId: Int) { let alertVC = CustomAlertVC() alertVC.modalPresentationStyle = .overFullScreen @@ -162,9 +170,10 @@ extension CourseDrawingVC { alertVC.rightButtonTapped.sink { [weak self] _ in guard let self = self else { return } let countDownVC = CountDownVC() - countDownVC.setData(locations: self.mapView.getMarkersLatLng(), - distance: self.distanceLabel.text, - pathImage: self.pathImage) + let runninModel = RunningModel(locations: self.mapView.getMarkersLatLng(), + distance: self.distanceLabel.text, + pathImage: self.pathImage) + countDownVC.setData(runningModel: runninModel) self.navigationController?.pushViewController(countDownVC, animated: true) alertVC.dismiss(animated: true) }.store(in: cancelBag) @@ -303,3 +312,51 @@ extension CourseDrawingVC { } } } + +// MARK: - Network + +extension CourseDrawingVC { + private func makecourseDrawingRequestDto() -> CourseDrawingRequestDto? { + guard let image = self.pathImage else { return nil } + guard let imageData = image.jpegData(compressionQuality: 1.0) else { return nil } + guard let departureLocationModel = self.departureLocationModel else { return nil } + let path = mapView.getMarkersLatLng().map { $0.toRNLocationModel() } + let courseDrawingRequestData = CourseDrawingRequestData(path: path, + distance: self.distance, + departureAddress: departureLocationModel.departureAddress, + departureName: departureLocationModel.departureName) + + let courseDrawingRequestDto = CourseDrawingRequestDto(image: imageData, data: courseDrawingRequestData) + + return courseDrawingRequestDto + } + + private func uploadCourseDrawing() { + guard let requestDto = makecourseDrawingRequestDto() else { return } + + LoadingIndicator.showLoading() + courseDrawingProvider.request(.uploadCourseDrawing(param: requestDto)) {[weak self] response in + guard let self = self else { return } + LoadingIndicator.hideLoading() + switch response { + case .success(let result): + let status = result.statusCode + if 200..<300 ~= status { + do { + let responseDto = try result.map(BaseResponse.self) + guard let data = responseDto.data else { return } + self.presentAlertVC(courseId: data.course.id) + } catch { + print(error.localizedDescription) + } + } + if status >= 400 { + print("400 error") + } + case .failure(let error): + print(error.localizedDescription) + self.showNetworkFailureToast() + } + } + } +} From 230898768a4b6e3de7c7351cd939e7b3acf5b2f7 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Tue, 10 Jan 2023 03:38:09 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[Feat]=20#63=20-=20RunningModel=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=84?= =?UTF-8?q?=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResponseDto/CourseDrawingResponseData.swift | 1 - .../CourseDetail/VC/CourseDetailVC.swift | 5 ++++- .../CourseDrawing/VC/CourseDrawingVC.swift | 4 ++-- .../Presentation/Running/VC/CountDownVC.swift | 14 +++++--------- .../Presentation/Running/VC/RunTrackingVC.swift | 13 ++++++++++--- .../Presentation/Running/VC/RunningWaitingVC.swift | 8 +++++--- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.swift index 2b89aa09..66ec9ee9 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.swift @@ -7,7 +7,6 @@ import Foundation - // MARK: - DataClass struct CourseDrawingResponseData: Codable { diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift index e3e6c9ed..7c528f91 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift @@ -101,7 +101,10 @@ extension CourseDetailVC { @objc private func pushToCountDownVC() { let countDownVC = CountDownVC() - countDownVC.setData(locations: [], distance: "1.0", pathImage: UIImage()) + let runningModel = RunningModel(locations: [], + distance: "1.0", + pathImage: UIImage()) + countDownVC.setData(runningModel: runningModel) self.navigationController?.pushViewController(countDownVC, animated: true) } } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift index 96c7be23..7e591309 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift @@ -170,10 +170,10 @@ extension CourseDrawingVC { alertVC.rightButtonTapped.sink { [weak self] _ in guard let self = self else { return } let countDownVC = CountDownVC() - let runninModel = RunningModel(locations: self.mapView.getMarkersLatLng(), + let runningModel = RunningModel(locations: self.mapView.getMarkersLatLng(), distance: self.distanceLabel.text, pathImage: self.pathImage) - countDownVC.setData(runningModel: runninModel) + countDownVC.setData(runningModel: runningModel) self.navigationController?.pushViewController(countDownVC, animated: true) alertVC.dismiss(animated: true) }.store(in: cancelBag) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/CountDownVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/CountDownVC.swift index a0b258be..e79d7e0b 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/CountDownVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/CountDownVC.swift @@ -12,10 +12,8 @@ final class CountDownVC: UIViewController { // MARK: - Properties + private var runningModel: RunningModel? private var count = 3 - var locations = [NMGLatLng]() - var distance: String? - var pathImage: UIImage? // MARK: - UI Components @@ -59,9 +57,9 @@ extension CountDownVC { if self.count > 0 { self.animateTimeLabel() } else { + guard let runningModel = self.runningModel else { return } let runTrackingVC = RunTrackingVC() - runTrackingVC.makePath(locations: self.locations, distance: self.distance ?? "0.0") - runTrackingVC.pathImage = self.pathImage + runTrackingVC.setData(runningModel: runningModel) self.navigationController?.pushViewController(runTrackingVC, animated: true) // CountDownVC를 navigationController 스택에서 제거하여 pop 하였을 때 더 이전 뷰로 넘어가지도록 함 @@ -72,10 +70,8 @@ extension CountDownVC { }) } - func setData(locations: [NMGLatLng], distance: String?, pathImage: UIImage?) { - self.locations = locations - self.distance = distance - self.pathImage = pathImage + func setData(runningModel: RunningModel) { + self.runningModel = runningModel } } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunTrackingVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunTrackingVC.swift index 762faf89..41d03747 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunTrackingVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunTrackingVC.swift @@ -14,11 +14,12 @@ final class RunTrackingVC: UIViewController { // MARK: - Properties + private var runningModel: RunningModel? + private let stopwatch = Stopwatch() private var cancelBag = CancelBag() var totalTime: Int = 0 var distance: String = "0.0" - var pathImage: UIImage? // MARK: - UI Components @@ -134,6 +135,11 @@ final class RunTrackingVC: UIViewController { // MARK: - Methods extension RunTrackingVC { + func setData(runningModel: RunningModel) { + self.runningModel = runningModel + makePath(locations: runningModel.locations, distance: runningModel.distance ?? "0.0") + } + func makePath(locations: [NMGLatLng], distance: String) { self.mapView.makeMarkersWithStartMarker(at: locations, moveCameraToStartMarker: true) self.totalDistanceLabel.attributedText = makeAttributedLabelForDistance(distance: distance) @@ -178,8 +184,8 @@ extension RunTrackingVC { } private func pushToRunningRecordVC() { - guard let pathImage = pathImage else { return } guard let distance = Float(self.distance) else { return } + guard let runningModel = self.runningModel else { return } let averagePaceSeconds = round(Float(self.totalTime) / distance) let averagePaceSecondsInt = Int(averagePaceSeconds) let formatedAveragePace = "\(averagePaceSecondsInt / 60)'\(averagePaceSecondsInt % 60)''" @@ -187,7 +193,8 @@ extension RunTrackingVC { let runningRecordVC = RunningRecordVC() runningRecordVC.setData(distance: self.distance, totalTime: RNTimeFormatter.secondsToHHMMSS(seconds: self.totalTime), - averagePace: formatedAveragePace, pathImage: pathImage) + averagePace: formatedAveragePace, + pathImage: runningModel.pathImage) self.navigationController?.pushViewController(runningRecordVC, animated: true) } } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningWaitingVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningWaitingVC.swift index 474e8f1e..221f7a90 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningWaitingVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningWaitingVC.swift @@ -73,9 +73,11 @@ extension RunningWaitingVC { } let countDownVC = CountDownVC() - countDownVC.setData(locations: self.mapView.getMarkersLatLng(), - distance: self.distanceLabel.text, - pathImage: UIImage()) + + let runningModel = RunningModel(locations: self.mapView.getMarkersLatLng(), + distance: self.distanceLabel.text, + pathImage: UIImage()) + countDownVC.setData(runningModel: runningModel) self.navigationController?.pushViewController(countDownVC, animated: true) } } From 383096c9c12473141cd234e81253f8ea59217c07 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Tue, 10 Jan 2023 03:42:23 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[Fix]=20#63=20-=20force=20try=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CourseDrawingRouter.swift | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.swift b/Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.swift index 972c407a..946c81d3 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.swift @@ -51,20 +51,24 @@ extension CourseDrawingRouter: TargetType { var path = [[String: Any]]() - for location in param.data.path { - let locationData = try! location.asParameter() - path.append(locationData) + do { + for location in param.data.path { + let locationData = try location.asParameter() + path.append(locationData) + } + + content["path"] = path + content["distance"] = param.data.distance + content["departureAddress"] = param.data.departureAddress + content["departureName"] = param.data.departureName + + let jsonData = try JSONSerialization.data(withJSONObject: content) + let formData = MultipartFormData(provider: .data(jsonData), name: "data", mimeType: "application/json") + multipartFormData.append(formData) + } catch { + print(error.localizedDescription) } - content["path"] = path - content["distance"] = param.data.distance - content["departureAddress"] = param.data.departureAddress - content["departureName"] = param.data.departureName - - let jsonData = try! JSONSerialization.data(withJSONObject: content) - let formData = MultipartFormData(provider: .data(jsonData), name: "data", mimeType: "application/json") - multipartFormData.append(formData) - return .uploadMultipart(multipartFormData) } } From 58789d114d8b5dec79700e772e9ebf95e15e9cc5 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Tue, 10 Jan 2023 03:54:30 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[Chore]=20#63=20-=20=EB=84=A4=ED=8A=B8?= =?UTF-8?q?=EC=9B=8C=ED=81=AC=20=EC=97=B0=EA=B2=B0=20=EC=8B=A4=ED=8C=A8=20?= =?UTF-8?q?=EC=8B=9C=20=ED=86=A0=EC=8A=A4=ED=8A=B8=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/CourseDrawing/VC/CourseDrawingVC.swift | 1 + Runnect-iOS/Runnect-iOS/Presentation/SignIn/VC/SignInVC.swift | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift index 7e591309..6fe848ec 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift @@ -352,6 +352,7 @@ extension CourseDrawingVC { } if status >= 400 { print("400 error") + self.showNetworkFailureToast() } case .failure(let error): print(error.localizedDescription) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/SignIn/VC/SignInVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/SignIn/VC/SignInVC.swift index 0f4dffcf..f2e39cc8 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/SignIn/VC/SignInVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/SignIn/VC/SignInVC.swift @@ -172,10 +172,11 @@ extension SignInVC { } if status >= 400 { print("400 error") + self.showNetworkFailureToast() } case .failure(let error): print(error.localizedDescription) - self.showToast(message: "네트워크 통신 실패") + self.showNetworkFailureToast() } } }