Skip to content
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
16 changes: 16 additions & 0 deletions FLINT/Data/Sources/DTO/Auth/LogoutRequestDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// LogoutRequestDTO.swift
// Data
//
// Created by 소은 on 6/19/26.
//

import Foundation

public struct LogoutRequestDTO: Encodable {
public let refreshToken: String

public init(refreshToken: String) {
self.refreshToken = refreshToken
}
}
14 changes: 14 additions & 0 deletions FLINT/Data/Sources/DTO/Auth/WithdrawRequestDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// WithdrawRequestDTO.swift
// Data
//

import Foundation

public struct WithdrawRequestDTO: Encodable {
public let agreedTermsIds: [String]

public init(agreedTermsIds: [String]) {
self.agreedTermsIds = agreedTermsIds
}
}
14 changes: 10 additions & 4 deletions FLINT/Data/Sources/Networking/API/AuthAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ import Moya
import DTO

public enum AuthAPI {
case logout
case logout(refreshToken: String)
case logoutAll
case refresh
case signup(userInfo: SignupRequestDTO)
case socialVerify(socialAuthCredential: SocialVerifyRequestDTO)
case withdraw
case withdraw(agreedTermsIds: [String])
}

extension AuthAPI: TargetType {
public var path: String {
switch self {
case .signup:
return "/api/v1/auth/signup"
case .logout, .logoutAll, .refresh:
case .logout:
return "/api/v1/auth/logout"
case .logoutAll, .refresh:
#warning("TODO: - 나중에 구현할 것")
return "TODO"
case .socialVerify:
Expand All @@ -50,8 +52,12 @@ extension AuthAPI: TargetType {
return .requestJSONEncodable(userInfo)
case let .socialVerify(socialAuthCredential):
return .requestJSONEncodable(socialAuthCredential)
case .logout, .logoutAll, .refresh, .withdraw:
case let .logout(refreshToken):
return .requestJSONEncodable(LogoutRequestDTO(refreshToken: refreshToken))
case .logoutAll, .refresh:
return .requestPlain
case let .withdraw(agreedTermsIds):
return .requestJSONEncodable(WithdrawRequestDTO(agreedTermsIds: agreedTermsIds))
}
}
}
25 changes: 20 additions & 5 deletions FLINT/Data/Sources/Networking/Service/AuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import DTO
public protocol AuthService {
func signup(userInfo: SignupInfoEntity) -> AnyPublisher<SignupDTO, Error>
func socialVerify(socialAuthCredential: SocialVerifyRequestDTO) -> AnyPublisher<SocialVerifyResponseDTO, Error>
func withDraw() -> AnyPublisher<Void, Error>
func logout() -> AnyPublisher<Void, Error>
func withDraw(agreedTermsIds: [String]) -> AnyPublisher<Void, Error>
}

public final class DefaultAuthService: AuthService {
Expand Down Expand Up @@ -67,10 +68,24 @@ public final class DefaultAuthService: AuthService {
.eraseToAnyPublisher()
}

public func withDraw() -> AnyPublisher<Void, Error> {
authAPIProvider.requestPublisher(.withdraw)
.mapBaseResponseData(BlankData.self)
.map({ _ in })
public func logout() -> AnyPublisher<Void, Error> {
guard let refreshToken = tokenStorage.load(type: .refreshToken) else {
return Fail(error: TokenError.noToken).eraseToAnyPublisher()
}
return authAPIProvider.requestPublisher(.logout(refreshToken: refreshToken))
.logged()
.tryMap { [weak self] response in
guard (200..<300).contains(response.statusCode) else {
throw MoyaError.statusCode(response)
}
self?.tokenStorage.clearAll()
}
.eraseToAnyPublisher()
}

public func withDraw(agreedTermsIds: [String]) -> AnyPublisher<Void, Error> {
return authAPIProvider.requestPublisher(.withdraw(agreedTermsIds: agreedTermsIds))
.logged()
.mapBaseResponseEmpty()
}
}
8 changes: 6 additions & 2 deletions FLINT/Data/Sources/RepositoryImpl/AuthRepositoryImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public final class DefaultAuthRepository: AuthRepository {
.eraseToAnyPublisher()
}

public func withDraw() -> AnyPublisher<Void, Error> {
return authService.withDraw()
public func logout() -> AnyPublisher<Void, Error> {
return authService.logout()
}

public func withDraw(agreedTermsIds: [String]) -> AnyPublisher<Void, Error> {
return authService.withDraw(agreedTermsIds: agreedTermsIds)
}
}
3 changes: 2 additions & 1 deletion FLINT/Domain/Sources/Repository/AuthRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ import Entity
public protocol AuthRepository {
func signup(userInfo: SignupInfoEntity) -> AnyPublisher<String, Error>
func socialVerify(socialAuthCredential: SocialVerifyEntity) -> AnyPublisher<SocialVerifyResultEntity, Error>
func withDraw() -> AnyPublisher<Void, Error>
func logout() -> AnyPublisher<Void, Error>
func withDraw(agreedTermsIds: [String]) -> AnyPublisher<Void, Error>
}
28 changes: 28 additions & 0 deletions FLINT/Domain/Sources/UseCase/Auth/LogoutUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// LogoutUseCase.swift
// Domain
//
// Created by 소은 on 6/19/26.
//

import Combine
import Foundation

import Repository

public protocol LogoutUseCase {
func callAsFunction() -> AnyPublisher<Void, Error>
}

public final class DefaultLogoutUseCase: LogoutUseCase {

private let authRepository: AuthRepository

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

public func callAsFunction() -> AnyPublisher<Void, Error> {
return authRepository.logout()
}
}
6 changes: 3 additions & 3 deletions FLINT/Domain/Sources/UseCase/Auth/WithDrawUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Entity
import Repository

public protocol WithDrawUseCase {
func callAsFunction() -> AnyPublisher<Void, Error>
func callAsFunction(agreedTermsIds: [String]) -> AnyPublisher<Void, Error>
}

public final class DefaultWithDrawUseCase: WithDrawUseCase {
Expand All @@ -23,7 +23,7 @@ public final class DefaultWithDrawUseCase: WithDrawUseCase {
self.authRepository = authRepository
}

public func callAsFunction() -> AnyPublisher<Void, Error> {
return authRepository.withDraw()
public func callAsFunction(agreedTermsIds: [String]) -> AnyPublisher<Void, Error> {
return authRepository.withDraw(agreedTermsIds: agreedTermsIds)
}
}
5 changes: 3 additions & 2 deletions FLINT/FLINT/Dependency/DIContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ typealias DependencyFactory = ViewControllerFactory &
FetchOTTPlatformsForContentUseCaseFactory &
ExploreViewModelFactory &
ProfileViewModelFactory &

ReportViewModelFactory &

SettingViewModelFactory &
WithdrawViewModelFactory &

CreateCollectionViewModelFactory &
AddContentSelectViewModelFactory &
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// LogoutUseCaseFactory..swift
// FLINT
//
// Created by 소은 on 6/19/26.
//

import Foundation

import Domain

protocol LogoutUseCaseFactory: AuthRepositoryFactory {
func makeLogoutUseCase() -> LogoutUseCase
}

extension LogoutUseCaseFactory {
func makeLogoutUseCase() -> LogoutUseCase {
return DefaultLogoutUseCase(authRepository: makeAuthRepository())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// SettingViewControllerFactory+.swift
// FLINT
//
// Created by 소은 on 6/19/26.
//

import Foundation

import Presentation

extension SettingViewControllerFactory where Self: SettingViewModelFactory & ViewControllerFactory {
func makeSettingViewController() -> SettingViewController {
return SettingViewController(
settingViewModel: makeSettingViewModel(),
viewControllerFactory: self
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// WithdrawalViewControllerFactory+.swift
// FLINT
//
// Created by 소은 on 6/19/26.
//

import Foundation

import Presentation

extension WithdrawalViewControllerFactory where Self: WithdrawViewModelFactory & ViewControllerFactory {
func makeWithdrawalViewController() -> WithdrawalViewController {
return WithdrawalViewController(
viewModel: makeWithdrawViewModel(),
viewControllerFactory: self
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// SettingViewModelFactory.swift
// FLINT
//
// Created by 소은 on 6/19/26.
//

import Foundation

import Presentation

protocol SettingViewModelFactory: LogoutUseCaseFactory {
func makeSettingViewModel() -> any SettingViewModel
}

extension SettingViewModelFactory {
func makeSettingViewModel() -> any SettingViewModel {
return DefaultSettingViewModel(logoutUseCase: makeLogoutUseCase())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// WithdrawViewModelFactory.swift
// FLINT
//
// Created by 소은 on 6/19/26.
//

import Foundation
import Presentation

protocol WithdrawViewModelFactory: WithDrawUseCaseFactory {
func makeWithdrawViewModel() -> WithdrawViewModel
}

extension WithdrawViewModelFactory {
func makeWithdrawViewModel() -> WithdrawViewModel {
return WithdrawViewModel(withDrawUseCase: makeWithDrawUseCase())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ public final class SelectedContentReasonTableViewCell: BaseTableViewCell {
}

private func makePhotoWrapper(image: UIImage, realIndex: Int) -> UIView {
let wrapper = UIView().then { $0.clipsToBounds = true }

let wrapper = UIView().then {
$0.clipsToBounds = true
$0.backgroundColor = .flintGray800
}
let imageView = UIImageView().then {
$0.contentMode = .scaleAspectFill
$0.contentMode = .scaleAspectFit
$0.clipsToBounds = true
$0.image = image
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ public typealias ViewControllerFactory =
SavedCollectionListViewControllerFactory &
AddContentSelectViewControllerFactory &
CreateCollectionViewControllerFactory &
ReportViewControllerFactory
SettingViewControllerFactory &
WithdrawalViewControllerFactory
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public final class HomeViewController: BaseViewController<HomeView> {
) {
self.viewModel = viewModel
self.fetchOTTPlatformsForContentUseCase = fetchOTTPlatformsForContentUseCase
super.init(viewControllerFactory: viewControllerFactory)
super.init(viewControllerFactory: viewControllerFactory)

self.viewControllerFactory = viewControllerFactory
}

Expand Down Expand Up @@ -109,7 +110,7 @@ public final class HomeViewController: BaseViewController<HomeView> {
title: "이 작품을 볼 수 있는 OTT",
content: .ott(platforms: platforms)
)
present(vc, animated: false)
present(vc, animated: true)
}

private func fetchAndPresentOTT(contentId: Int64) {
Expand Down Expand Up @@ -246,9 +247,10 @@ extension HomeViewController: UITableViewDataSource {

cell.onTapItem = { [weak self] content in
guard let self else { return }
guard let contentId = Int64(content.id) else { return }

self.fetchAndPresentOTT(contentId: contentId)
let platforms: [OTTPlatform] = content.ottList.compactMap { ott in
OTTPlatform.fromServerName(ott.ottName)
}
self.presentOTTBottomSheet(platforms: platforms)
}

return cell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ public final class ProfileViewController: BaseViewController<ProfileView> {
}

private func didTapSetting() {
// TODO: SettingViewController push (DI에 SettingViewControllerFactory 등록 후 연결)
print("setting tapped")
guard let factory = viewControllerFactory else { return }
let settingVC = factory.makeSettingViewController()
navigationController?.pushViewController(settingVC, animated: true)
}

private func setupTableView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ private extension SettingViewController {
}

func showWithdrawalAlert() {
print("Navigate to Withdrawal Page")
guard let vc = viewControllerFactory?.makeWithdrawalViewController() else { return }
navigationController?.pushViewController(vc, animated: true)
}

func handleLogoutSuccess() {
Expand Down
Loading