Skip to content

Commit

Permalink
Merge branch 'develop' into 603-connect-search-feature-and-domain
Browse files Browse the repository at this point in the history
  • Loading branch information
yongbeomkwak authored Jun 16, 2024
2 parents 252733b + 7ecd4bf commit 9e08622
Show file tree
Hide file tree
Showing 55 changed files with 519 additions and 497 deletions.
4 changes: 2 additions & 2 deletions Projects/App/Sources/Application/AppComponent+Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public extension AppComponent {
}
}

var fetchNaverUserInfoUseCase: any FetchNaverUserInfoUseCase {
var regenerateAccessTokenUseCase: any ReGenerateAccessTokenUseCase {
shared {
FetchNaverUserInfoUseCaseImpl(authRepository: authRepository)
ReGenerateAccessTokenUseCaseImpl(authRepository: authRepository)
}
}

Expand Down
6 changes: 6 additions & 0 deletions Projects/App/Sources/Application/AppComponent+Songs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public extension AppComponent {
}
}

var fetchSongUseCase: any FetchSongUseCase {
shared {
FetchSongUseCaseImpl(songsRepository: songsRepository)
}
}

var fetchLyricsUseCase: any FetchLyricsUseCase {
shared {
FetchLyricsUseCaseImpl(songsRepository: songsRepository)
Expand Down
4 changes: 0 additions & 4 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,6 @@ private class SignInDependency5dda0dd015447272446cProvider: SignInDependency {
var fetchTokenUseCase: any FetchTokenUseCase {
return appComponent.fetchTokenUseCase
}
var fetchNaverUserInfoUseCase: any FetchNaverUserInfoUseCase {
return appComponent.fetchNaverUserInfoUseCase
}
var fetchUserInfoUseCase: any FetchUserInfoUseCase {
return appComponent.fetchUserInfoUseCase
}
Expand Down Expand Up @@ -1222,7 +1219,6 @@ extension PermissionComponent: Registration {
extension SignInComponent: Registration {
public func registerItems() {
keyPathToName[\SignInDependency.fetchTokenUseCase] = "fetchTokenUseCase-any FetchTokenUseCase"
keyPathToName[\SignInDependency.fetchNaverUserInfoUseCase] = "fetchNaverUserInfoUseCase-any FetchNaverUserInfoUseCase"
keyPathToName[\SignInDependency.fetchUserInfoUseCase] = "fetchUserInfoUseCase-any FetchUserInfoUseCase"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import Foundation
import RxSwift

public protocol RemoteAuthDataSource {
func fetchToken(token: String, type: ProviderType) -> Single<AuthLoginEntity>
func fetchNaverUserInfo(tokenType: String, accessToken: String) -> Single<NaverUserInfoEntity>
func fetchToken(providerType: ProviderType, token: String) -> Single<AuthLoginEntity>
func reGenerateAccessToken() -> Single<AuthLoginEntity>
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// RecommendPlayListEntity.swift
// DomainModuleTests
//
// Created by yongbeomkwak on 2023/02/10.
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import Foundation

public struct AuthLoginEntity: Equatable {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Foundation
import RxSwift

public protocol AuthRepository {
func fetchToken(token: String, type: ProviderType) -> Single<AuthLoginEntity>
func fetchNaverUserInfo(tokenType: String, accessToken: String) -> Single<NaverUserInfoEntity>
func fetchToken(providerType: ProviderType, token: String) -> Single<AuthLoginEntity>
func reGenerateAccessToken() -> Single<AuthLoginEntity>
func logout() -> Completable
func checkIsExistAccessToken() -> Single<Bool>
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import Foundation
import RxSwift

public protocol FetchTokenUseCase {
func execute(token: String, type: ProviderType) -> Single<AuthLoginEntity>
func execute(providerType: ProviderType, token: String) -> Single<AuthLoginEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation
import RxSwift

public protocol ReGenerateAccessTokenUseCase {
func execute() -> Single<AuthLoginEntity>
}
55 changes: 21 additions & 34 deletions Projects/Domains/AuthDomain/Sources/API/AuthAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,62 @@ import Foundation
import Moya

public enum AuthAPI {
case fetchToken(token: String, type: ProviderType)
case fetchNaverUserInfo(tokenType: String, accessToken: String)
case fetchToken(providerType: ProviderType, token: String)
case reGenerateAccessToken
}

public struct AuthRequset: Encodable {
var token: String
private struct FetchTokenRequestParameters: Encodable {
var provider: String
var token: String
}

extension AuthAPI: WMAPI {
public var baseURL: URL {
switch self {
case .fetchToken:
return URL(string: BASE_URL())!
case .fetchNaverUserInfo:
return URL(string: "https://openapi.naver.com")!
}
return URL(string: BASE_URL())!
}

public var domain: WMDomain {
switch self {
case .fetchToken:
return .auth
case .fetchNaverUserInfo:
return .naver
}
return .auth
}

public var urlPath: String {
switch self {
case .fetchToken:
return "/login/mobile"
case .fetchNaverUserInfo:
return ""
return "/app"
case .reGenerateAccessToken:
return "/token"
}
}

public var method: Moya.Method {
switch self {
case .fetchToken:
return .post
case .fetchNaverUserInfo:
return .get
case .reGenerateAccessToken:
return .post
}
}

public var headers: [String: String]? {
switch self {
case let .fetchNaverUserInfo(tokenType, accessToken):
return ["Authorization": "\(tokenType) \(accessToken)"]
default:
return ["Content-Type": "application/json"]
}
return ["Content-Type": "application/json"]
}

public var task: Moya.Task {
switch self {
case let .fetchToken(token: id, type: type):
return .requestJSONEncodable(AuthRequset(token: id, provider: type.rawValue))
case .fetchNaverUserInfo:
case let .fetchToken(providerType: providerType, token: id):
return .requestJSONEncodable(
FetchTokenRequestParameters(
provider: providerType.rawValue,
token: id
)
)
case .reGenerateAccessToken:
return .requestPlain
}
}

public var jwtTokenType: JwtTokenType {
switch self {
default:
return .none
}
return .none
}

public var errorMap: [Int: WMError] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import Foundation
import RxSwift

public final class RemoteAuthDataSourceImpl: BaseRemoteDataSource<AuthAPI>, RemoteAuthDataSource {
public func fetchToken(token: String, type: ProviderType) -> Single<AuthLoginEntity> {
request(.fetchToken(token: token, type: type))
public func fetchToken(providerType: ProviderType, token: String) -> Single<AuthLoginEntity> {
request(.fetchToken(providerType: providerType, token: token))
.map(AuthLoginResponseDTO.self)
.map { $0.toDomain() }
}

public func fetchNaverUserInfo(tokenType: String, accessToken: String) -> Single<NaverUserInfoEntity> {
request(.fetchNaverUserInfo(tokenType: tokenType, accessToken: accessToken))
.map(NaverUserInfoResponseDTO.self)
public func reGenerateAccessToken() -> Single<AuthLoginEntity> {
request(.reGenerateAccessToken)
.map(AuthLoginResponseDTO.self)
.map { $0.toDomain() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public final class AuthRepositoryImpl: AuthRepository {
self.remoteAuthDataSource = remoteAuthDataSource
}

public func fetchToken(token: String, type: ProviderType) -> Single<AuthLoginEntity> {
remoteAuthDataSource.fetchToken(token: token, type: type)
public func fetchToken(providerType: ProviderType, token: String) -> Single<AuthLoginEntity> {
remoteAuthDataSource.fetchToken(providerType: providerType, token: token)
}

public func fetchNaverUserInfo(tokenType: String, accessToken: String) -> Single<NaverUserInfoEntity> {
remoteAuthDataSource.fetchNaverUserInfo(tokenType: tokenType, accessToken: accessToken)
public func reGenerateAccessToken() -> Single<AuthLoginEntity> {
remoteAuthDataSource.reGenerateAccessToken()
}

public func logout() -> Completable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
//
// ArtistListResponseDTO.swift
// DataMappingModule
//
// Created by KTH on 2023/02/01.
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AuthDomainInterface
import Foundation

public struct AuthLoginResponseDTO: Decodable, Equatable {
public let token: String
public let accessToken: String
public let expiresIn: TimeInterval
public let refreshToken: String?

public static func == (lhs: Self, rhs: Self) -> Bool {
return lhs.token == rhs.token
lhs.accessToken == rhs.accessToken
&& lhs.expiresIn == rhs.expiresIn
&& lhs.refreshToken == rhs.refreshToken
}
}

public extension AuthLoginResponseDTO {
func toDomain() -> AuthLoginEntity {
AuthLoginEntity(
token: token
token: accessToken
)
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// FetchArtistListUseCaseImpl.swift
// DataModule
//
// Created by KTH on 2023/02/08.
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AuthDomainInterface
import Foundation
import RxSwift
Expand All @@ -17,7 +9,7 @@ public struct FetchTokenUseCaseImpl: FetchTokenUseCase {
self.authRepository = authRepository
}

public func execute(token: String, type: ProviderType) -> Single<AuthLoginEntity> {
authRepository.fetchToken(token: token, type: type)
public func execute(providerType: ProviderType, token: String) -> Single<AuthLoginEntity> {
authRepository.fetchToken(providerType: providerType, token: token)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import AuthDomainInterface
import Foundation
import RxSwift

public struct ReGenerateAccessTokenUseCaseImpl: ReGenerateAccessTokenUseCase {
private let authRepository: any AuthRepository

public init(authRepository: any AuthRepository) {
self.authRepository = authRepository
}

public func execute() -> Single<AuthLoginEntity> {
authRepository.reGenerateAccessToken()
}
}

This file was deleted.

Loading

0 comments on commit 9e08622

Please sign in to comment.