From 08d06d74fc03d73839fe97161207916bee1d4932 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Tue, 10 Jan 2023 16:42:14 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[Feat]=20#67=20-=20Dto=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS/Network/Dto/CourseDiscoveryDto/.gitkeep | 0 .../RequestDto/CourseDiscoveryRequestDto.swift | 8 ++++++++ .../ResponseDto/CourseDiscoveryResponsDto.swift | 8 ++++++++ 3 files changed, 16 insertions(+) delete mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/.gitkeep create mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/RequestDto/CourseDiscoveryRequestDto.swift create mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/.gitkeep b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/RequestDto/CourseDiscoveryRequestDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/RequestDto/CourseDiscoveryRequestDto.swift new file mode 100644 index 00000000..352ec3a5 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/RequestDto/CourseDiscoveryRequestDto.swift @@ -0,0 +1,8 @@ +// +// RequestDto.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/10. +// + +import Foundation diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift new file mode 100644 index 00000000..bbff0812 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift @@ -0,0 +1,8 @@ +// +// CourseDiscoveryResponsDto.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/10. +// + +import Foundation From 2e2025139053e30d5c13f42cdd3d99e1377ddca8 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Tue, 10 Jan 2023 16:42:33 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[Fix]=20#67=20-=20Dto=20=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS.xcodeproj/project.pbxproj | 26 ++++++++++++- .../CourseDiscoveryResponsDto.swift | 39 +++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index d3c9d6f3..6b325d2e 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -126,6 +126,8 @@ DAD5A3D8296C6D9600C8166B /* AdImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3D7296C6D9600C8166B /* AdImageCollectionViewCell.swift */; }; DAD5A3DA296C6DA500C8166B /* TitleCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3D9296C6DA500C8166B /* TitleCollectionViewCell.swift */; }; DAD5A3DC296C6DB800C8166B /* MapCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3DB296C6DB800C8166B /* MapCollectionViewCell.swift */; }; + DAD5A3DE296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3DD296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift */; }; + DAD5A3E2296D4C6500C8166B /* CourseDiscoveryResponsDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3E1296D4C6500C8166B /* CourseDiscoveryResponsDto.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -148,7 +150,6 @@ CE0D9FD229648DA300CEB5CD /* CustomAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertVC.swift; sourceTree = ""; }; CE10063929680C5700FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10063B29680C6800FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE10063C29680C7000FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; 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 = ""; }; @@ -274,6 +275,8 @@ DAD5A3D7296C6D9600C8166B /* AdImageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdImageCollectionViewCell.swift; sourceTree = ""; }; DAD5A3D9296C6DA500C8166B /* TitleCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleCollectionViewCell.swift; sourceTree = ""; }; DAD5A3DB296C6DB800C8166B /* MapCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapCollectionViewCell.swift; sourceTree = ""; }; + DAD5A3DD296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDiscoveryRequestDto.swift; sourceTree = ""; }; + DAD5A3E1296D4C6500C8166B /* CourseDiscoveryResponsDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDiscoveryResponsDto.swift; sourceTree = ""; }; E837271A78E1C0A0C30789BF /* Pods-Runnect-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runnect-iOS.release.xcconfig"; path = "Target Support Files/Pods-Runnect-iOS/Pods-Runnect-iOS.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -399,7 +402,8 @@ CE10063529680C0F00FD31FB /* CourseDiscoveryDto */ = { isa = PBXGroup; children = ( - CE10063C29680C7000FD31FB /* .gitkeep */, + DAD5A3E0296D4C2A00C8166B /* ResponseDto */, + DAD5A3DF296D4C1E00C8166B /* RequestDto */, ); path = CourseDiscoveryDto; sourceTree = ""; @@ -1081,6 +1085,22 @@ path = VC; sourceTree = ""; }; + DAD5A3DF296D4C1E00C8166B /* RequestDto */ = { + isa = PBXGroup; + children = ( + DAD5A3DD296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift */, + ); + path = RequestDto; + sourceTree = ""; + }; + DAD5A3E0296D4C2A00C8166B /* ResponseDto */ = { + isa = PBXGroup; + children = ( + DAD5A3E1296D4C6500C8166B /* CourseDiscoveryResponsDto.swift */, + ); + path = ResponseDto; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -1236,6 +1256,7 @@ CE6655CD295D856300C64E12 /* KeyPathFindable.swift in Sources */, CE29D582296402B500F47542 /* CourseDrawingVC.swift in Sources */, CE6655E4295D884600C64E12 /* UILabel+.swift in Sources */, + DAD5A3DE296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift in Sources */, CE6655FA295D90E000C64E12 /* applyShadow.swift in Sources */, A3BC2F2B2962C3D500198261 /* GoalRewardInfoVC.swift in Sources */, CE665606295D91C500C64E12 /* makeVibrate.swift in Sources */, @@ -1271,6 +1292,7 @@ CE40BB1C2967E4910030ABCA /* RunningWaitingVC.swift in Sources */, CE6B63D6296731F9003F900F /* ScrapCourseListView.swift in Sources */, CE6655F8295D90CF00C64E12 /* adjusted+.swift in Sources */, + DAD5A3E2296D4C6500C8166B /* CourseDiscoveryResponsDto.swift in Sources */, CE4545CB295D7AF4003201E1 /* SceneDelegate.swift in Sources */, A3BC2F3F2964706100198261 /* UploadedCourseInfoCVC.swift in Sources */, CE6655FE295D912300C64E12 /* calculateTopInset.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift index bbff0812..60830e45 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift @@ -6,3 +6,42 @@ // import Foundation + +// MARK: - CourseDiscoveryResponseDto +struct CourseDiscoveryResponseDto: Codable { + let status: Int + let success: Bool + let message: String + let data: DataClass +} + +// MARK: - DataClass +struct DataClass: Codable { + let publicCourses: [PublicCourse] +} + +// MARK: - PublicCourse +struct PublicCourse: Codable { + let id, courseID: Int + let title: String + let image: String + let scarp: Bool + let departure: Departure + + enum CodingKeys: String, CodingKey { + case id + case courseID = "courseId" + case title, image, scarp, departure + } +} + +// MARK: - Departure +struct Departure: Codable { + let region: Region + let city: String +} + +enum Region: String, Codable { + case 서울 = "서울" + case 전북 = "전북" +} From 86aaf82e9a4e541a3cdc61acc7960443a539f6a9 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Tue, 10 Jan 2023 18:53:03 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[Feat]=20#67=20-=20=EC=BD=94=EC=8A=A4=20?= =?UTF-8?q?=EB=B0=9C=EA=B2=AC=20API=20=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 | 26 ++---- .../CourseDiscoveryRequestDto.swift | 8 -- .../CourseDiscoveryResponsDto.swift | 47 ---------- .../PickedMapListResponseDto.swift | 31 +++++++ .../Router/CourseDiscoveryRouter/.gitkeep | 0 .../CourseDiscoveryRouter.swift | 52 ++++++++++++ .../Views/VC/CourseDiscoveryVC.swift | 85 +++++++++++++++---- 7 files changed, 158 insertions(+), 91 deletions(-) delete mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/RequestDto/CourseDiscoveryRequestDto.swift delete mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift create mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/PickedMapListResponseDto.swift delete mode 100644 Runnect-iOS/Runnect-iOS/Network/Router/CourseDiscoveryRouter/.gitkeep create mode 100644 Runnect-iOS/Runnect-iOS/Network/Router/CourseDiscoveryRouter/CourseDiscoveryRouter.swift diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 6b325d2e..7328eef0 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -126,8 +126,8 @@ DAD5A3D8296C6D9600C8166B /* AdImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3D7296C6D9600C8166B /* AdImageCollectionViewCell.swift */; }; DAD5A3DA296C6DA500C8166B /* TitleCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3D9296C6DA500C8166B /* TitleCollectionViewCell.swift */; }; DAD5A3DC296C6DB800C8166B /* MapCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3DB296C6DB800C8166B /* MapCollectionViewCell.swift */; }; - DAD5A3DE296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3DD296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift */; }; - DAD5A3E2296D4C6500C8166B /* CourseDiscoveryResponsDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3E1296D4C6500C8166B /* CourseDiscoveryResponsDto.swift */; }; + DAD5A3E2296D4C6500C8166B /* PickedMapListResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3E1296D4C6500C8166B /* PickedMapListResponseDto.swift */; }; + DAD5A3E4296D526D00C8166B /* CourseDiscoveryRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3E3296D526D00C8166B /* CourseDiscoveryRouter.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -154,7 +154,6 @@ CE10063E29680C8800FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10063F29680C9800FD31FB /* .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 = ""; }; CE10064429680CBC00FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10064529680CC300FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; @@ -275,8 +274,8 @@ DAD5A3D7296C6D9600C8166B /* AdImageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdImageCollectionViewCell.swift; sourceTree = ""; }; DAD5A3D9296C6DA500C8166B /* TitleCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleCollectionViewCell.swift; sourceTree = ""; }; DAD5A3DB296C6DB800C8166B /* MapCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapCollectionViewCell.swift; sourceTree = ""; }; - DAD5A3DD296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDiscoveryRequestDto.swift; sourceTree = ""; }; - DAD5A3E1296D4C6500C8166B /* CourseDiscoveryResponsDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDiscoveryResponsDto.swift; sourceTree = ""; }; + DAD5A3E1296D4C6500C8166B /* PickedMapListResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickedMapListResponseDto.swift; sourceTree = ""; }; + DAD5A3E3296D526D00C8166B /* CourseDiscoveryRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDiscoveryRouter.swift; sourceTree = ""; }; E837271A78E1C0A0C30789BF /* Pods-Runnect-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runnect-iOS.release.xcconfig"; path = "Target Support Files/Pods-Runnect-iOS/Pods-Runnect-iOS.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -403,7 +402,6 @@ isa = PBXGroup; children = ( DAD5A3E0296D4C2A00C8166B /* ResponseDto */, - DAD5A3DF296D4C1E00C8166B /* RequestDto */, ); path = CourseDiscoveryDto; sourceTree = ""; @@ -718,7 +716,7 @@ CE40BB28296808300030ABCA /* CourseDiscoveryRouter */ = { isa = PBXGroup; children = ( - CE10064229680CAD00FD31FB /* .gitkeep */, + DAD5A3E3296D526D00C8166B /* CourseDiscoveryRouter.swift */, ); path = CourseDiscoveryRouter; sourceTree = ""; @@ -1085,18 +1083,10 @@ path = VC; sourceTree = ""; }; - DAD5A3DF296D4C1E00C8166B /* RequestDto */ = { - isa = PBXGroup; - children = ( - DAD5A3DD296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift */, - ); - path = RequestDto; - sourceTree = ""; - }; DAD5A3E0296D4C2A00C8166B /* ResponseDto */ = { isa = PBXGroup; children = ( - DAD5A3E1296D4C6500C8166B /* CourseDiscoveryResponsDto.swift */, + DAD5A3E1296D4C6500C8166B /* PickedMapListResponseDto.swift */, ); path = ResponseDto; sourceTree = ""; @@ -1256,7 +1246,6 @@ CE6655CD295D856300C64E12 /* KeyPathFindable.swift in Sources */, CE29D582296402B500F47542 /* CourseDrawingVC.swift in Sources */, CE6655E4295D884600C64E12 /* UILabel+.swift in Sources */, - DAD5A3DE296D4C0F00C8166B /* CourseDiscoveryRequestDto.swift in Sources */, CE6655FA295D90E000C64E12 /* applyShadow.swift in Sources */, A3BC2F2B2962C3D500198261 /* GoalRewardInfoVC.swift in Sources */, CE665606295D91C500C64E12 /* makeVibrate.swift in Sources */, @@ -1273,6 +1262,7 @@ CEEC6B3C2961C51A00D00E1E /* CourseStorageVC.swift in Sources */, CE4545C9295D7AF4003201E1 /* AppDelegate.swift in Sources */, CE6655C8295D849F00C64E12 /* StringLiterals.swift in Sources */, + DAD5A3E4296D526D00C8166B /* CourseDiscoveryRouter.swift in Sources */, CEEC6B3E2961C53700D00E1E /* CourseDiscoveryVC.swift in Sources */, CE6655E0295D87D200C64E12 /* UIDevice+.swift in Sources */, CE40BB242968068E0030ABCA /* Config.swift in Sources */, @@ -1292,7 +1282,7 @@ CE40BB1C2967E4910030ABCA /* RunningWaitingVC.swift in Sources */, CE6B63D6296731F9003F900F /* ScrapCourseListView.swift in Sources */, CE6655F8295D90CF00C64E12 /* adjusted+.swift in Sources */, - DAD5A3E2296D4C6500C8166B /* CourseDiscoveryResponsDto.swift in Sources */, + DAD5A3E2296D4C6500C8166B /* PickedMapListResponseDto.swift in Sources */, CE4545CB295D7AF4003201E1 /* SceneDelegate.swift in Sources */, A3BC2F3F2964706100198261 /* UploadedCourseInfoCVC.swift in Sources */, CE6655FE295D912300C64E12 /* calculateTopInset.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/RequestDto/CourseDiscoveryRequestDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/RequestDto/CourseDiscoveryRequestDto.swift deleted file mode 100644 index 352ec3a5..00000000 --- a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/RequestDto/CourseDiscoveryRequestDto.swift +++ /dev/null @@ -1,8 +0,0 @@ -// -// RequestDto.swift -// Runnect-iOS -// -// Created by YEONOO on 2023/01/10. -// - -import Foundation diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift deleted file mode 100644 index 60830e45..00000000 --- a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/CourseDiscoveryResponsDto.swift +++ /dev/null @@ -1,47 +0,0 @@ -// -// CourseDiscoveryResponsDto.swift -// Runnect-iOS -// -// Created by YEONOO on 2023/01/10. -// - -import Foundation - -// MARK: - CourseDiscoveryResponseDto -struct CourseDiscoveryResponseDto: Codable { - let status: Int - let success: Bool - let message: String - let data: DataClass -} - -// MARK: - DataClass -struct DataClass: Codable { - let publicCourses: [PublicCourse] -} - -// MARK: - PublicCourse -struct PublicCourse: Codable { - let id, courseID: Int - let title: String - let image: String - let scarp: Bool - let departure: Departure - - enum CodingKeys: String, CodingKey { - case id - case courseID = "courseId" - case title, image, scarp, departure - } -} - -// MARK: - Departure -struct Departure: Codable { - let region: Region - let city: String -} - -enum Region: String, Codable { - case 서울 = "서울" - case 전북 = "전북" -} diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/PickedMapListResponseDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/PickedMapListResponseDto.swift new file mode 100644 index 00000000..bd9bff49 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/PickedMapListResponseDto.swift @@ -0,0 +1,31 @@ +// +// CourseDiscoveryResponsDto.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/10. +// + +import Foundation + +// MARK: - DataClass + +struct PickedMapListResponseDto: Codable { + let publicCourses: [PublicCourse] +} + +// MARK: - PublicCourse + +struct PublicCourse: Codable { + let id, courseId: Int + let title: String + let image: String + let scarp: Bool + let departure: CourseDiscoveryDeparture +} + +// MARK: - Departure + +struct CourseDiscoveryDeparture: Codable { + let region: String + let city: String +} diff --git a/Runnect-iOS/Runnect-iOS/Network/Router/CourseDiscoveryRouter/.gitkeep b/Runnect-iOS/Runnect-iOS/Network/Router/CourseDiscoveryRouter/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Runnect-iOS/Runnect-iOS/Network/Router/CourseDiscoveryRouter/CourseDiscoveryRouter.swift b/Runnect-iOS/Runnect-iOS/Network/Router/CourseDiscoveryRouter/CourseDiscoveryRouter.swift new file mode 100644 index 00000000..8d09ed2d --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Router/CourseDiscoveryRouter/CourseDiscoveryRouter.swift @@ -0,0 +1,52 @@ +// +// pickedMapListRouter.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/10. +// + +import Foundation + +import Moya + +enum pickedMapListRouter { + case getCourseData +} + +extension pickedMapListRouter: 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 .getCourseData: + return "/public-course" + } + } + + var method: Moya.Method { + switch self { + case .getCourseData: + return .get + } + } + + var task: Moya.Task { + switch self { + case .getCourseData: + return .requestPlain + } + } + + var headers: [String: String]? { + switch self { + case .getCourseData: + return Config.headerWithDeviceId + } + } +} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift index 9825c27a..a99b0c08 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift @@ -10,9 +10,17 @@ import UIKit import Then import SnapKit import Combine +import Moya final class CourseDiscoveryVC: UIViewController { - + // MARK: - Properties + + let pickedMapListProvider = MoyaProvider( + plugins: [NetworkLoggerPlugin(verbose: true)] + ) + + private var courseList = [PublicCourse]() + // MARK: - UIComponents private lazy var navibar = CustomNavigationBar(self, type: .title).setTitle("코스 발견") @@ -23,13 +31,13 @@ final class CourseDiscoveryVC: UIViewController { private let plusButton = UIButton(type: .system).then { $0.setImage(ImageLiterals.icPlus, for: .normal) } - + // MARK: - collectionview private lazy var mapCollectionView: UICollectionView = { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical - + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.backgroundColor = .clear collectionView.isScrollEnabled = true @@ -51,6 +59,7 @@ final class CourseDiscoveryVC: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.hideTabBar(wantsToHide: false) + self.getCourseData() } } @@ -58,6 +67,11 @@ final class CourseDiscoveryVC: UIViewController { extension CourseDiscoveryVC { + private func setData(courseList: [PublicCourse]) { + self.courseList = courseList + mapCollectionView.reloadData() + } + private func setDelegate() { mapCollectionView.delegate = self mapCollectionView.dataSource = self @@ -76,21 +90,22 @@ extension CourseDiscoveryVC { } } - - // MARK: - @objc Function - extension CourseDiscoveryVC { - @objc private func pushToSearchVC() { - let nextVC = CourseSearchVC() - self.navigationController?.pushViewController(nextVC, animated: true) - } - @objc private func pushToDiscoveryVC() { - let nextVC = MyCourseSelectVC() - self.navigationController?.pushViewController(nextVC, animated: true) - } +// MARK: - @objc Function + +extension CourseDiscoveryVC { + @objc private func pushToSearchVC() { + let nextVC = CourseSearchVC() + self.navigationController?.pushViewController(nextVC, animated: true) + } + @objc private func pushToDiscoveryVC() { + let nextVC = MyCourseSelectVC() + self.navigationController?.pushViewController(nextVC, animated: true) } +} + +// MARK: - UI & Layout - // MARK: - UI & Layout extension CourseDiscoveryVC { private func setNavigationBar() { view.addSubview(navibar) @@ -111,7 +126,7 @@ extension CourseDiscoveryVC { mapCollectionView.backgroundColor = .w1 view.addSubviews(plusButton, mapCollectionView) view.bringSubviewToFront(plusButton) - + mapCollectionView.snp.makeConstraints { $0.top.equalTo(self.navibar.snp.bottom) $0.leading.bottom.trailing.equalTo(view.safeAreaLayoutGuide) @@ -128,7 +143,7 @@ extension CourseDiscoveryVC { extension CourseDiscoveryVC: UICollectionViewDelegate, UICollectionViewDataSource { func numberOfSections(in collectionView: UICollectionView) -> Int { - 3 + return 3 } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { @@ -136,7 +151,7 @@ extension CourseDiscoveryVC: UICollectionViewDelegate, UICollectionViewDataSourc case 0, 1: return 1 case 2: - return 15 + return self.courseList.count default: return 0 } @@ -152,6 +167,9 @@ extension CourseDiscoveryVC: UICollectionViewDelegate, UICollectionViewDataSourc } else { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CourseListCVC.className, for: indexPath) as? CourseListCVC else { return UICollectionViewCell() } cell.setCellType(type: .all) + let model = self.courseList[indexPath.item] + let location = "\(model.departure.region) \(model.departure.city)" + cell.setData(imageURL: model.image, title: model.title, location: location, didLike: model.scarp) return cell } } @@ -208,3 +226,34 @@ extension CourseDiscoveryVC: UICollectionViewDelegateFlowLayout { } } } + +// MARK: - Network + +extension CourseDiscoveryVC { + private func getCourseData() { + LoadingIndicator.showLoading() + pickedMapListProvider.request(.getCourseData) { response in + 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.setData(courseList: data.publicCourses) + } catch { + print(error.localizedDescription) + } + } + if status >= 400 { + print("400 error") + self.showNetworkFailureToast() + } + case .failure(let error): + print(error.localizedDescription) + self.showNetworkFailureToast() + } + } + } +} From 55fb0ff039b8c33bec996d19978077c3a6ec6216 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Tue, 10 Jan 2023 19:04:38 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[Feat]=20#67=20-=20=EB=B3=B4=EA=B4=80?= =?UTF-8?q?=ED=95=A8=20=EC=97=A0=ED=8B=B0=EB=B7=B0=20=EB=B0=94=EC=9D=B8?= =?UTF-8?q?=EB=94=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/CourseListView/PrivateCourseListView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/Views/CourseListView/PrivateCourseListView.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/Views/CourseListView/PrivateCourseListView.swift index 1a29f45d..3e20bc09 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/Views/CourseListView/PrivateCourseListView.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/Views/CourseListView/PrivateCourseListView.swift @@ -58,6 +58,7 @@ extension PrivateCourseListView { func setData(courseList: [PrivateCourse]) { self.courseList = courseList self.courseListCollectionView.reloadData() + self.emptyView.isHidden = !courseList.isEmpty } private func setDelegate() { From 0aeb849bc43b9973de83ae843111706f970870f7 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Tue, 10 Jan 2023 19:06:07 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[Fix]=20#67=20-=20=EC=BD=94=EB=A9=98?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResponseDto/PickedMapListResponseDto.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/PickedMapListResponseDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/PickedMapListResponseDto.swift index bd9bff49..ed5b0f09 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/PickedMapListResponseDto.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDiscoveryDto/ResponseDto/PickedMapListResponseDto.swift @@ -7,7 +7,7 @@ import Foundation -// MARK: - DataClass +// MARK: - PickedMapListResponseDto struct PickedMapListResponseDto: Codable { let publicCourses: [PublicCourse] @@ -23,7 +23,7 @@ struct PublicCourse: Codable { let departure: CourseDiscoveryDeparture } -// MARK: - Departure +// MARK: - CourseDiscoveryDeparture struct CourseDiscoveryDeparture: Codable { let region: String