Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: 둜그인 μ‹œ μœ μ € κΆŒν•œ 정보 μ €μž₯ #163

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ public extension TargetDependency.Feature {
}

public extension TargetDependency.Domain {
static let UserDomainTesting = TargetDependency.project(
target: ModulePaths.Domain.UserDomain.targetName(type: .testing),
path: .relativeToDomain(ModulePaths.Domain.UserDomain.rawValue)
)
static let UserDomainInterface = TargetDependency.project(
target: ModulePaths.Domain.UserDomain.targetName(type: .interface),
path: .relativeToDomain(ModulePaths.Domain.UserDomain.rawValue)
)
static let UserDomain = TargetDependency.project(
target: ModulePaths.Domain.UserDomain.targetName(type: .sources),
path: .relativeToDomain(ModulePaths.Domain.UserDomain.rawValue)
)
static let FileDomainTesting = TargetDependency.project(
target: ModulePaths.Domain.FileDomain.targetName(type: .testing),
path: .relativeToDomain(ModulePaths.Domain.FileDomain.rawValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public extension ModulePaths {

public extension ModulePaths {
enum Domain: String {
case UserDomain
case FileDomain
case MajorDomain
case StudentDomain
Expand Down
1 change: 1 addition & 0 deletions Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ let targets: [Target] = [
.Domain.StudentDomain,
.Domain.FileDomain,
.Domain.MajorDomain,
.Domain.UserDomain,
.Core.JwtStore,
.Shared.KeychainModule
],
Expand Down
18 changes: 12 additions & 6 deletions Projects/App/Sources/Application/DI/AppComponent.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import AuthDomain
import AuthDomainInterface
import StudentDomain
import StudentDomainInterface
import BaseDomain
import FileDomain
import FileDomainInterface
import MajorDomain
import MajorDomainInterface
import BaseDomain
import InputCertificateInfoFeature
import InputCertificateInfoFeatureInterface
import InputInformationFeature
Expand All @@ -21,15 +17,21 @@ import InputSchoolLifeInfoFeature
import InputSchoolLifeInfoFeatureInterface
import InputWorkInfoFeature
import InputWorkInfoFeatureInterface
import RootFeature
import JwtStore
import JwtStoreInterface
import KeychainModule
import KeychainModuleInterface
import MajorDomain
import MajorDomainInterface
import NeedleFoundation
import RootFeature
import SigninFeature
import SigninFeatureInterface
import StudentDomain
import StudentDomainInterface
import SwiftUI
import UserDomain
import UserDomainInterface

final class AppComponent: BootstrapComponent {
func makeRootView() -> some View {
Expand Down Expand Up @@ -88,6 +90,10 @@ final class AppComponent: BootstrapComponent {
FileDomainComponent(parent: self)
}

var userDomainBuildable: any UserDomainBuildable {
UserDomainComponent(parent: self)
}

var jwtStoreBuildable: any JwtStoreBuildable {
JwtStoreComponent(parent: self)
}
Expand Down
23 changes: 23 additions & 0 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import SigninFeatureInterface
import StudentDomain
import StudentDomainInterface
import SwiftUI
import UserDomain
import UserDomainInterface

// swiftlint:disable unused_declaration
private let needleDependenciesHash : String? = nil
Expand Down Expand Up @@ -102,6 +104,9 @@ private class SigninDependencyde06a9d0b22764487733Provider: SigninDependency {
var authDomainBuildable: any AuthDomainBuildable {
return appComponent.authDomainBuildable
}
var userDomainBuildable: any UserDomainBuildable {
return appComponent.userDomainBuildable
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
Expand Down Expand Up @@ -243,6 +248,17 @@ private class MajorDomainDependency4dd341ec0ebe68acad8bProvider: MajorDomainDepe
private func factoryc6563cd3e82b012ec3bef47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return MajorDomainDependency4dd341ec0ebe68acad8bProvider(appComponent: parent1(component) as! AppComponent)
}
private class UserDomainDependencyf39d2a2922733361cbe1Provider: UserDomainDependency {


init() {

}
}
/// ^->AppComponent->UserDomainComponent
private func factory46488402f315d7f9530ce3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject {
return UserDomainDependencyf39d2a2922733361cbe1Provider()
}

#else
extension JwtStoreComponent: Registration {
Expand Down Expand Up @@ -280,6 +296,7 @@ extension RootComponent: Registration {
extension SigninComponent: Registration {
public func registerItems() {
keyPathToName[\SigninDependency.authDomainBuildable] = "authDomainBuildable-any AuthDomainBuildable"
keyPathToName[\SigninDependency.userDomainBuildable] = "userDomainBuildable-any UserDomainBuildable"
}
}
extension InputMilitaryInfoComponent: Registration {
Expand Down Expand Up @@ -334,6 +351,11 @@ extension MajorDomainComponent: Registration {
keyPathToName[\MajorDomainDependency.jwtStoreBuildable] = "jwtStoreBuildable-any JwtStoreBuildable"
}
}
extension UserDomainComponent: Registration {
public func registerItems() {

}
}


#endif
Expand Down Expand Up @@ -366,6 +388,7 @@ private func registerProviderFactory(_ componentPath: String, _ factory: @escapi
registerProviderFactory("^->AppComponent->StudentDomainComponent", factory2686a7e321a220c3265af47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->AuthDomainComponent", factoryc9b20c320bb79402d4c1f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->MajorDomainComponent", factoryc6563cd3e82b012ec3bef47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->UserDomainComponent", factory46488402f315d7f9530ce3b0c44298fc1c149afb)
}
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

public protocol RemoteAuthDataSource {
func login(code: String) async throws -> IsAlreadySignUp
func login(code: String) async throws -> UserSignupInfoEntity
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation
import UserDomainInterface

public struct UserSignupInfoEntity: Equatable {
public let isAlreadySignup: Bool
public let userRole: UserRoleType

public init(isAlreadySignup: Bool, userRole: UserRoleType) {
self.isAlreadySignup = isAlreadySignup
self.userRole = userRole
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

public protocol AuthRepository {
func login(code: String) async throws -> IsAlreadySignUp
func login(code: String) async throws -> UserSignupInfoEntity
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

public protocol LoginUseCase {
func execute(code: String) async throws -> IsAlreadySignUp
func execute(code: String) async throws -> UserSignupInfoEntity
}
6 changes: 5 additions & 1 deletion Projects/Domain/AuthDomain/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ let project = Project.makeModule(
product: .staticLibrary,
targets: [.interface, .testing, .unitTest],
internalDependencies: [
.Domain.BaseDomain
.Domain.BaseDomain,
.Domain.UserDomainInterface
],
interfaceDependencies: [
.Domain.UserDomainInterface
]
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import AuthDomainInterface
import Foundation
import UserDomainInterface

struct SigninResponseDTO: Decodable {
let isExist: Bool
let role: UserRoleType
}

extension SigninResponseDTO {
func toDomain() -> UserSignupInfoEntity {
UserSignupInfoEntity(
isAlreadySignup: isExist,
userRole: role
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import AuthDomainInterface
import BaseDomain

final class RemoteAuthDataSourceImpl: BaseRemoteDataSource<AuthEndpoint>, RemoteAuthDataSource {
func login(code: String) async throws -> IsAlreadySignUp {
func login(code: String) async throws -> UserSignupInfoEntity {
try await request(.signin(code: code), dto: SigninResponseDTO.self)
.isExist
.toDomain()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct AuthRepositoryImpl: AuthRepository {
self.remoteAuthDataSource = remoteAuthDataSource
}

func login(code: String) async throws -> IsAlreadySignUp {
func login(code: String) async throws -> UserSignupInfoEntity {
try await remoteAuthDataSource.login(code: code)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct LoginUseCaseImpl: LoginUseCase {
self.authRepository = authRepository
}

func execute(code: String) async throws -> IsAlreadySignUp {
func execute(code: String) async throws -> UserSignupInfoEntity {
try await authRepository.login(code: code)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import AuthDomainInterface
import UserDomainInterface

final class RemoteAuthDataSourceSpy: RemoteAuthDataSource {
var loginCallCount = 0
func login(code: String) async throws -> IsAlreadySignUp {
func login(code: String) async throws -> UserSignupInfoEntity {
loginCallCount += 1
if code.isEmpty {
throw AuthDomainError.failedToGAuthSignin
}
return true
return .init(isAlreadySignup: true, userRole: .guest)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import AuthDomainInterface

final class AuthRepositorySpy: AuthRepository {
var loginCallCount = 0
func login(code: String) async throws -> IsAlreadySignUp {
func login(code: String) async throws -> UserSignupInfoEntity {
loginCallCount += 1
if code.isEmpty {
throw AuthDomainError.failedToGAuthSignin
}
return true
return .init(isAlreadySignup: true, userRole: .guest)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import AuthDomainInterface

final class LoginUseCaseSpy: LoginUseCase {
var callCount = 0
func execute(code: String) async throws -> IsAlreadySignUp {
func execute(code: String) async throws -> UserSignupInfoEntity {
callCount += 1
if code.isEmpty {
throw AuthDomainError.failedToGAuthSignin
}
return true
return .init(isAlreadySignup: true, userRole: .guest)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
19 changes: 19 additions & 0 deletions Projects/Domain/UserDomain/Demo/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import UIKit

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let viewController = UIViewController()
viewController.view.backgroundColor = .yellow
window?.rootViewController = viewController
window?.makeKeyAndVisible()

return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public protocol UserDomainBuildable {
var userRepository: any UserRepository { get }
var loadUserRoleUseCase: any LoadUserRoleUseCase { get }
var saveUserRoleUseCase: any SaveUserRoleUseCase { get }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public protocol LocalUserDataSource {
func saveUserRole(role: UserRoleType)
func loadUserRole() -> UserRoleType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation

public enum UserRoleType: String, Codable {
case student = "ROLE_STUDENT"
case teacher = "ROLE_TEACHER"
case guest
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public protocol UserRepository {
func saveUserRole(role: UserRoleType)
func loadUserRole() -> UserRoleType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public protocol LoadUserRoleUseCase {
func execute() -> UserRoleType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

public protocol SaveUserRoleUseCase {
func execute(role: UserRoleType)
}
12 changes: 12 additions & 0 deletions Projects/Domain/UserDomain/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.makeModule(
name: ModulePaths.Domain.UserDomain.rawValue,
product: .staticLibrary,
targets: [.interface, .testing, .unitTest, .demo],
internalDependencies: [
.Domain.BaseDomain
]
)
Loading