Skip to content

Commit

Permalink
Merge pull request #430 from wakmusic/feature/425-setting-appdomain
Browse files Browse the repository at this point in the history
πŸ”€ :: (#425) AppDomain λͺ¨λ“ˆ μž‘μ—…
  • Loading branch information
KangTaeHoon authored Mar 7, 2024
2 parents 76d7e8b + 2d9a808 commit 8e91a45
Show file tree
Hide file tree
Showing 34 changed files with 286 additions and 355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public extension ModulePaths {
enum Domain: String, MicroTargetPathConvertable {
case BaseDomain
case AppDomain
case ArtistDomain
case AuthDomain
case ChartDomain
case FaqDomain
case LikeDomain
case NoticeDomain
case PlayListDomain
case SongsDomain
case UserDomain
}
}

Expand Down
2 changes: 1 addition & 1 deletion Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let targets: [Target] = [
.Project.Features.RootFeature,
.Project.Module.ThirdPartyLib,
.Project.Service.Data,
TargetDependency.domain(target: .BaseDomain)
TargetDependency.domain(target: .AppDomain)
],
settings: .settings(
base: env.baseSetting,
Expand Down
16 changes: 6 additions & 10 deletions Projects/App/Sources/Application/AppComponent+App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,26 @@
import DomainModule
import DataModule
import NetworkModule
import AppDomain
import AppDomainInterface


//MARK: λ³€μˆ˜λͺ… 주의
// AppComponent λ‚΄ λ³€μˆ˜ == Dependency λ‚΄ λ³€μˆ˜ 이름 같아야함

// MARK: λ³€μˆ˜λͺ… 주의
// AppComponent λ‚΄ λ³€μˆ˜ == Dependency λ‚΄ λ³€μˆ˜ 이름 같아야함

public extension AppComponent {

var remoteAppDataSource: any RemoteAppDataSource {
shared {
RemoteAppDataSourceImpl(keychain: keychain)
}
}

var appRepository: any AppRepository {
shared {
AppRepositoryImpl(remoteAppDataSource: remoteAppDataSource)
}
}


var fetchCheckAppUseCase: any FetchCheckAppUseCase{
var fetchAppCheckUseCase: any FetchAppCheckUseCase {
shared {
FetchCheckAppUseCaseImpl(appRepository: appRepository)
FetchAppCheckUseCaseImpl(appRepository: appRepository)
}
}
}
10 changes: 6 additions & 4 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@


import AppDomain
import AppDomainInterface
import ArtistFeature
import BaseFeature
import ChartFeature
Expand Down Expand Up @@ -493,8 +495,8 @@ private class RootDependency3944cc797a4a88956fb5Provider: RootDependency {
var fetchUserInfoUseCase: any FetchUserInfoUseCase {
return appComponent.fetchUserInfoUseCase
}
var fetchCheckAppUseCase: any FetchCheckAppUseCase {
return appComponent.fetchCheckAppUseCase
var fetchAppCheckUseCase: any FetchAppCheckUseCase {
return appComponent.fetchAppCheckUseCase
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
Expand Down Expand Up @@ -876,7 +878,7 @@ extension AppComponent: Registration {
localTable["fetchFaqUseCase-any FetchFaqUseCase"] = { self.fetchFaqUseCase as Any }
localTable["remoteAppDataSource-any RemoteAppDataSource"] = { self.remoteAppDataSource as Any }
localTable["appRepository-any AppRepository"] = { self.appRepository as Any }
localTable["fetchCheckAppUseCase-any FetchCheckAppUseCase"] = { self.fetchCheckAppUseCase as Any }
localTable["fetchAppCheckUseCase-any FetchAppCheckUseCase"] = { self.fetchAppCheckUseCase as Any }
localTable["chartComponent-ChartComponent"] = { self.chartComponent as Any }
localTable["chartContentComponent-ChartContentComponent"] = { self.chartContentComponent as Any }
localTable["remoteChartDataSource-any RemoteChartDataSource"] = { self.remoteChartDataSource as Any }
Expand Down Expand Up @@ -1060,7 +1062,7 @@ extension RootComponent: Registration {
keyPathToName[\RootDependency.mainContainerComponent] = "mainContainerComponent-MainContainerComponent"
keyPathToName[\RootDependency.permissionComponent] = "permissionComponent-PermissionComponent"
keyPathToName[\RootDependency.fetchUserInfoUseCase] = "fetchUserInfoUseCase-any FetchUserInfoUseCase"
keyPathToName[\RootDependency.fetchCheckAppUseCase] = "fetchCheckAppUseCase-any FetchCheckAppUseCase"
keyPathToName[\RootDependency.fetchAppCheckUseCase] = "fetchAppCheckUseCase-any FetchAppCheckUseCase"
}
}
extension PermissionComponent: Registration {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// RemoteAppDataSource.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import RxSwift

public protocol RemoteAppDataSource {
func fetchAppCheck() -> Single<AppCheckEntity>
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
//
// VersionCheckEntity.swift
// DomainModuleTests
// AppCheckEntity.swift
// AppDomain
//
// Created by yongbeomkwak on 2023/05/23.
// Copyright Β© 2023 yongbeomkwak. All rights reserved.
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import DataMappingModule

public struct AppInfoEntity: Equatable {
public struct AppCheckEntity: Equatable {
public init(
flag: AppInfoFlagType,
flag: AppCheckFlagType,
title: String,
description: String,
version: String,
specialLogo: Bool
)
{
) {
self.flag = flag
self.title = title
self.description = description
self.version = version
self.specialLogo = specialLogo
}
public let flag: AppInfoFlagType

public let flag: AppCheckFlagType
public let title, description, version: String
public let specialLogo: Bool
}
17 changes: 17 additions & 0 deletions Projects/Domains/AppDomain/Interface/Enum/AppCheckFlagType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// AppCheckFlagType.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation

public enum AppCheckFlagType: Int, Decodable {
case normal = 1
case event
case update
case forceUpdate
case offline
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// AppRepository.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import RxSwift

public protocol AppRepository {
func fetchAppCheck() -> Single<AppCheckEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// FetchAppCheckUseCase.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import RxSwift

public protocol FetchAppCheckUseCase {
func execute() -> Single<AppCheckEntity>
}
22 changes: 22 additions & 0 deletions Projects/Domains/AppDomain/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.module(
name: ModulePaths.Domain.AppDomain.rawValue,
targets: [
.implements(
module: .domain(.AppDomain),
product: .staticFramework,
dependencies: [
TargetDependency.domain(target: .BaseDomain),
TargetDependency.domain(target: .AppDomain, type: .interface)
]
),
.interface(module: .domain(.AppDomain)),
.tests(
module: .domain(.AppDomain),
dependencies: [.domain(target: .AppDomain)]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
//
// AppAPI.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import Moya
import DataMappingModule
import BaseDomain
import ErrorModule
import Foundation

public enum AppAPI {
case checkVersion
case fetchAppCheck
}

extension AppAPI: WMAPI {
public var domain: WMDomain {
.app
return WMDomain.app
}

public var urlPath: String {
switch self {
case .checkVersion:
case .fetchAppCheck:
return "/check"
}
}

public var method: Moya.Method {
return .get
}

public var task: Moya.Task {
switch self {

case .checkVersion:
return .requestParameters(parameters: [
"os": "ios",
"version": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? ""
], encoding: URLEncoding.queryString)

case .fetchAppCheck:
return .requestParameters(
parameters: [
"os": "ios",
"version": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? ""
],
encoding: URLEncoding.queryString
)
}
}

public var jwtTokenType: JwtTokenType {
return .none
}

public var errorMap: [Int: WMError] {
switch self {
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// RemoteAppDataSourceImpl.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import BaseDomain
import AppDomainInterface
import RxSwift

public final class RemoteAppDataSourceImpl: BaseRemoteDataSource<AppAPI>, RemoteAppDataSource {
public func fetchAppCheck() -> Single<AppCheckEntity> {
request(.fetchAppCheck)
.map(FetchAppCheckResponseDTO.self)
.map { $0.toDomain() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// AppRepositoryImpl.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import AppDomainInterface
import RxSwift

public final class AppRepositoryImpl: AppRepository {
private let remoteAppDataSource: any RemoteAppDataSource

public init(
remoteAppDataSource: RemoteAppDataSource
) {
self.remoteAppDataSource = remoteAppDataSource
}

public func fetchAppCheck() -> Single<AppCheckEntity> {
remoteAppDataSource.fetchAppCheck()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// AppCheckResponseDTO.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import AppDomainInterface

public struct FetchAppCheckResponseDTO: Decodable {
public let flag: AppCheckFlagType
public let title, description, version: String?
public let specialLogo: Bool?
}

public extension FetchAppCheckResponseDTO {
func toDomain() -> AppCheckEntity {
return AppCheckEntity(
flag: flag,
title: title ?? "",
description: description ?? "",
version: version ?? "",
specialLogo: specialLogo ?? false
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// FetchCheckAppUseCaseImpl.swift
// AppDomain
//
// Created by KTH on 2024/03/04.
// Copyright Β© 2024 yongbeomkwak. All rights reserved.
//

import Foundation
import RxSwift
import AppDomainInterface

public struct FetchAppCheckUseCaseImpl: FetchAppCheckUseCase {
private let appRepository: any AppRepository

public init(
appRepository: AppRepository
) {
self.appRepository = appRepository
}

public func execute() -> Single<AppCheckEntity> {
appRepository.fetchAppCheck()
}
}
1 change: 1 addition & 0 deletions Projects/Domains/AppDomain/Tests/Test.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading

0 comments on commit 8e91a45

Please sign in to comment.