From adf7037f9805b6b976f80a4401444b56857b534c Mon Sep 17 00:00:00 2001 From: Park Seo Yeon Date: Thu, 20 Jun 2024 21:13:14 +0900 Subject: [PATCH] :truck: [Feat] modifier folder structure & set network MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 폴더 구조 정리 - 기초 네트워크 작업 --- .../App/Sources/Application/AppDelegate.swift | 35 +++++++++++++++++ .../Sources/Application/SceneDelegate.swift | 39 +++++++++++++++++++ .../App/Sources/Data/EndPoint/EndPoint.swift | 24 ++++++++++++ .../App/Sources/Data/Error/NetworkError.swift | 17 ++++++++ .../Sources/Data/Mapper/ResultMapper.swift | 11 ++++++ .../Data/Repository/AuthRepository.swift | 20 ++++++++++ .../App/Sources/Data/Service/ApiService.swift | 31 +++++++++++++++ .../Repository/AuthRepositoryProtocol.swift | 15 +++++++ .../App/Sources/Domain/Usecase/Usecase.swift | 17 ++++++++ Projects/App/Sources/Extension/Common.swift | 15 ------- .../Categoery/{ => Main}/CategoeryMain.swift | 0 .../Detail/{ => Main}/NoneZeroView.swift | 0 .../Detail/{ => Main}/ProductDetailView.swift | 0 .../{ => Main}/SimiliarProductView.swift | 0 .../Home/{ => Main}/HomeMain.swift | 0 15 files changed, 209 insertions(+), 15 deletions(-) create mode 100644 Projects/App/Sources/Application/AppDelegate.swift create mode 100644 Projects/App/Sources/Application/SceneDelegate.swift create mode 100644 Projects/App/Sources/Data/EndPoint/EndPoint.swift create mode 100644 Projects/App/Sources/Data/Error/NetworkError.swift create mode 100644 Projects/App/Sources/Data/Mapper/ResultMapper.swift create mode 100644 Projects/App/Sources/Data/Repository/AuthRepository.swift create mode 100644 Projects/App/Sources/Data/Service/ApiService.swift create mode 100644 Projects/App/Sources/Domain/Repository/AuthRepositoryProtocol.swift create mode 100644 Projects/App/Sources/Domain/Usecase/Usecase.swift delete mode 100644 Projects/App/Sources/Extension/Common.swift rename Projects/App/Sources/Presentation/Categoery/{ => Main}/CategoeryMain.swift (100%) rename Projects/App/Sources/Presentation/Detail/{ => Main}/NoneZeroView.swift (100%) rename Projects/App/Sources/Presentation/Detail/{ => Main}/ProductDetailView.swift (100%) rename Projects/App/Sources/Presentation/Detail/{ => Main}/SimiliarProductView.swift (100%) rename Projects/App/Sources/Presentation/Home/{ => Main}/HomeMain.swift (100%) diff --git a/Projects/App/Sources/Application/AppDelegate.swift b/Projects/App/Sources/Application/AppDelegate.swift new file mode 100644 index 0000000..463dc64 --- /dev/null +++ b/Projects/App/Sources/Application/AppDelegate.swift @@ -0,0 +1,35 @@ +// +// AppDelegate.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation +import UIKit + +class AppDelegate: UIResponder, UIApplicationDelegate { + + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + return true + } + + // MARK: UISceneSession Lifecycle + + func application( + _ application: UIApplication, + configurationForConnecting connectingSceneSession: UISceneSession, + options: UIScene.ConnectionOptions + ) -> UISceneConfiguration { + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application( + _ application: UIApplication, + didDiscardSceneSessions sceneSessions: Set + ) {} +} diff --git a/Projects/App/Sources/Application/SceneDelegate.swift b/Projects/App/Sources/Application/SceneDelegate.swift new file mode 100644 index 0000000..99c56ef --- /dev/null +++ b/Projects/App/Sources/Application/SceneDelegate.swift @@ -0,0 +1,39 @@ +// +// SceneDelegate.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + guard let windowScene = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // 사용자가 앱을 종료할 때 실행되는 코드 + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // 앱이 활성화되어 사용 가능한 상태가 되었을 때 실행되는 코드 + } + + func sceneWillResignActive(_ scene: UIScene) { + // 앱이 비활성화되어 일시 중지된 상태가 될 때 실행되는 코드 + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // 앱이 백그라운드에서 포그라운드로 전환되기 직전에 실행되는 코드 + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // 앱이 백그라운드로 들어갔을 때 실행되는 코드 + } +} diff --git a/Projects/App/Sources/Data/EndPoint/EndPoint.swift b/Projects/App/Sources/Data/EndPoint/EndPoint.swift new file mode 100644 index 0000000..5ac0087 --- /dev/null +++ b/Projects/App/Sources/Data/EndPoint/EndPoint.swift @@ -0,0 +1,24 @@ +// +// EndPoint.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation + +struct APIEndPoint { + static let baseURL = "" + + enum Auth { + case login + case checkNickname + case join + case logout + } + + enum Home { + case product + } +} diff --git a/Projects/App/Sources/Data/Error/NetworkError.swift b/Projects/App/Sources/Data/Error/NetworkError.swift new file mode 100644 index 0000000..0ef78eb --- /dev/null +++ b/Projects/App/Sources/Data/Error/NetworkError.swift @@ -0,0 +1,17 @@ +// +// NetworkError.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation + +enum NetworkError: Error { + case notConnected + case response + case decode + case apiError + case urlError +} diff --git a/Projects/App/Sources/Data/Mapper/ResultMapper.swift b/Projects/App/Sources/Data/Mapper/ResultMapper.swift new file mode 100644 index 0000000..91bc3ef --- /dev/null +++ b/Projects/App/Sources/Data/Mapper/ResultMapper.swift @@ -0,0 +1,11 @@ +// +// ResultMapper.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation + +// Decoder 또는 옵셔널 Mapper 생성 diff --git a/Projects/App/Sources/Data/Repository/AuthRepository.swift b/Projects/App/Sources/Data/Repository/AuthRepository.swift new file mode 100644 index 0000000..307a610 --- /dev/null +++ b/Projects/App/Sources/Data/Repository/AuthRepository.swift @@ -0,0 +1,20 @@ +// +// DataRepository.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation + +class AuthRepository: AuthRepositoryProtocol { + + let apiService = ApiService() + + func kakaoLogin(_ token: String) async -> Result { + // TODO: - Implement Kakao Login + + return .success("success") + } +} diff --git a/Projects/App/Sources/Data/Service/ApiService.swift b/Projects/App/Sources/Data/Service/ApiService.swift new file mode 100644 index 0000000..6785151 --- /dev/null +++ b/Projects/App/Sources/Data/Service/ApiService.swift @@ -0,0 +1,31 @@ +// +// ApiService.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation + +enum ApiMethod { + case get + case put + case post + case patch + case delete +} + +class ApiService { + func request( + apiMethod: ApiMethod, + endPoint: String, + QueryParameter: [String : String]? = nil + ) async -> Result { + return .failure(.notConnected) + + // TODO: - Network 작업 + + } +} + diff --git a/Projects/App/Sources/Domain/Repository/AuthRepositoryProtocol.swift b/Projects/App/Sources/Domain/Repository/AuthRepositoryProtocol.swift new file mode 100644 index 0000000..f934b7d --- /dev/null +++ b/Projects/App/Sources/Domain/Repository/AuthRepositoryProtocol.swift @@ -0,0 +1,15 @@ +// +// AuthReposity.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation + +// Implement Auth Interface +protocol AuthRepositoryProtocol { + func kakaoLogin(_ token: String) async -> Result +} + diff --git a/Projects/App/Sources/Domain/Usecase/Usecase.swift b/Projects/App/Sources/Domain/Usecase/Usecase.swift new file mode 100644 index 0000000..04a0d67 --- /dev/null +++ b/Projects/App/Sources/Domain/Usecase/Usecase.swift @@ -0,0 +1,17 @@ +// +// Usecase.swift +// App +// +// Created by 박서연 on 2024/06/20. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation + +struct AuthUseCase { + let authRepositoryProtocol: AuthRepositoryProtocol + + func kakaoLogin(_ token: String) async -> Result { + return await authRepositoryProtocol.kakaoLogin(token) + } +} diff --git a/Projects/App/Sources/Extension/Common.swift b/Projects/App/Sources/Extension/Common.swift deleted file mode 100644 index 1b0862b..0000000 --- a/Projects/App/Sources/Extension/Common.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// Common.swift -// App -// -// Created by 박서연 on 2024/06/08. -// Copyright © 2024 iOS. All rights reserved. -// - -import Foundation -import SwiftUI - -struct Size { - static let width = UIScreen.main.bounds.width - static let height = UIScreen.main.bounds.height -} diff --git a/Projects/App/Sources/Presentation/Categoery/CategoeryMain.swift b/Projects/App/Sources/Presentation/Categoery/Main/CategoeryMain.swift similarity index 100% rename from Projects/App/Sources/Presentation/Categoery/CategoeryMain.swift rename to Projects/App/Sources/Presentation/Categoery/Main/CategoeryMain.swift diff --git a/Projects/App/Sources/Presentation/Detail/NoneZeroView.swift b/Projects/App/Sources/Presentation/Detail/Main/NoneZeroView.swift similarity index 100% rename from Projects/App/Sources/Presentation/Detail/NoneZeroView.swift rename to Projects/App/Sources/Presentation/Detail/Main/NoneZeroView.swift diff --git a/Projects/App/Sources/Presentation/Detail/ProductDetailView.swift b/Projects/App/Sources/Presentation/Detail/Main/ProductDetailView.swift similarity index 100% rename from Projects/App/Sources/Presentation/Detail/ProductDetailView.swift rename to Projects/App/Sources/Presentation/Detail/Main/ProductDetailView.swift diff --git a/Projects/App/Sources/Presentation/Detail/SimiliarProductView.swift b/Projects/App/Sources/Presentation/Detail/Main/SimiliarProductView.swift similarity index 100% rename from Projects/App/Sources/Presentation/Detail/SimiliarProductView.swift rename to Projects/App/Sources/Presentation/Detail/Main/SimiliarProductView.swift diff --git a/Projects/App/Sources/Presentation/Home/HomeMain.swift b/Projects/App/Sources/Presentation/Home/Main/HomeMain.swift similarity index 100% rename from Projects/App/Sources/Presentation/Home/HomeMain.swift rename to Projects/App/Sources/Presentation/Home/Main/HomeMain.swift