Skip to content

Commit

Permalink
fix: Trash 폴더 내부 Camera 관련 UseCase 제거
Browse files Browse the repository at this point in the history
- FetchDailyMissionContentUseCase 추가
- MissionContentEntity, MissionTodayContentResponseDTO 추가
- CameraViewReactor Mission관련 비즈니스 로직 수정
-  MissonDIContainer FetchMissionContentUseCase 의존성 추가
  • Loading branch information
Do-hyun-Kim committed Nov 26, 2024
1 parent 0cc5460 commit 93648aa
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ final class MissionDIContainer: BaseContainer {
return CheckMissionAlertShowUseCase(missionRepository: repository)
}

private func makeFetchMissionContentUseCase() -> FetchDailyMissonContentUseCaseProtocol {
return FetchDailyMissonContentUseCase(missionRepository: repository)
}

func registerDependencies() {
container.register(type: FetchMissionContentUseCaseProtocol.self) { _ in
self.makeMissionUseCase()
Expand All @@ -28,6 +32,10 @@ final class MissionDIContainer: BaseContainer {
container.register(type: CheckMissionAlertShowUseCaseProtocol.self) { _ in
self.makeCheckMissionAlertShowUseCase()
}

container.register(type: FetchDailyMissonContentUseCaseProtocol.self) { _ in
self.makeFetchMissionContentUseCase()
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -243,29 +243,29 @@ public final class CameraViewController: BaseViewController<CameraViewReactor> {
}.disposed(by: disposeBag)


// Observable
// .zip(
// reactor.state.compactMap { $0.feedImageData }.distinctUntilChanged(),
// reactor.state.compactMap { $0.missionEntity?.missionContent },
// reactor.state.map { $0.cameraType.asPostType }
// )
// .withUnretained(self)
// .bind {
// let cameraDisplayViewController = CameraDisplayViewControllerWrapper(displayData: $0.1.0, missionTitle: $0.1.1, cameraDisplayType: $0.1.2).viewController
// $0.0.navigationController?.pushViewController(cameraDisplayViewController, animated: true)
// }.disposed(by: disposeBag)
//
Observable
.zip(
reactor.state.compactMap { $0.imageData }.distinctUntilChanged(),
reactor.state.compactMap { $0.missionEntity?.missionContent },
reactor.state.map { $0.cameraType.asPostType }
)
.withUnretained(self)
.bind {
let cameraDisplayViewController = CameraDisplayViewControllerWrapper(displayData: $0.1.0, missionTitle: $0.1.1, cameraDisplayType: $0.1.2).viewController
$0.0.navigationController?.pushViewController(cameraDisplayViewController, animated: true)
}.disposed(by: disposeBag)

reactor.state
.map { $0.cameraType.isRealEmojiType }
.distinctUntilChanged()
.withUnretained(self)
.bind(onNext: {$0.0.setupRealEmojiLayoutContent(isShow: !$0.1)})
.disposed(by: disposeBag)

// reactor.pulse(\.$missionEntity)
// .map { $0?.missionContent }
// .bind(to: missionView.missionTitleView.rx.text)
// .disposed(by: disposeBag)
reactor.pulse(\.$missionEntity)
.map { $0?.missionContent }
.bind(to: missionView.missionTitleView.rx.text)
.disposed(by: disposeBag)


reactor.pulse(\.$cameraType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class CameraViewReactor: Reactor {


@Injected private var uploadImageUseCase: FetchCameraUploadImageUseCaseProtocol
// @Injected private var fetchMissionUseCase: FetchCameraTodayMissionUseCaseProtocol
@Injected private var fetchDailyMissionUseCase: FetchDailyMissonContentUseCaseProtocol
@Injected private var fetchRealEmojiUpdateUseCase: FetchCameraRealEmojiUpdateUseCaseProtocol
@Injected private var fetchRealEmojiCreateUseCase: FetchCameraRealEmojiUploadUseCaseProtocol
@Injected private var fetchRealEmojiListUseCase: FetchCameraRealEmojiListUseCaseProtocol
Expand Down Expand Up @@ -50,6 +50,7 @@ public final class CameraViewReactor: Reactor {
case setFlashMode(Bool)
case setPinchZoomScale(CGFloat)
case setZoomScale(CGFloat)
case setDailyMissionrResponse(MissonTodayContentEntity?)
case setProfilePresignedResponse(CreateMemberPresignedEntity?)
case setProfileMemberResponse(MembersProfileEntity?)
case setRealEmojiImageURLResponse(CameraRealEmojiPreSignedEntity?)
Expand All @@ -66,6 +67,7 @@ public final class CameraViewReactor: Reactor {
@Pulse var isLoading: Bool
@Pulse var isFlashMode: Bool
@Pulse var isSwitchPosition: Bool
@Pulse var missionEntity: MissonTodayContentEntity?
@Pulse var memberPresignedEntity: CreateMemberPresignedEntity?
@Pulse var realEmojiURLEntity: CameraRealEmojiPreSignedEntity?
@Pulse var realEmojiCreateEntity: CameraCreateRealEmojiEntity?
Expand Down Expand Up @@ -173,6 +175,8 @@ public final class CameraViewReactor: Reactor {
newState.imageData = feedImage
case let .setProfilePresignedResponse(memberPresignedEntity):
newState.memberPresignedEntity = memberPresignedEntity
case let .setDailyMissionrResponse(missionEntity):
newState.missionEntity = missionEntity
}

return newState
Expand Down Expand Up @@ -238,19 +242,14 @@ extension CameraViewReactor {
}
)
case .mission:
return .empty()
// return fetchMissionUseCase.execute()
// .asObservable()
// .withUnretained(self)
// .flatMap { owner, entity -> Observable<CameraViewReactor.Mutation> in
//
// return .concat(
// .just(.setLoading(false)),
// .just(.setLoading(true))
// )
// }
//

return fetchDailyMissionUseCase.execute()
.flatMap { entity -> Observable<Mutation> in
return .concat(
.just(.setLoading(false)),
.just(.setDailyMissionrResponse(entity)),
.just(.setLoading(true))
)
}
default:
return .empty()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// MissonTodayContentResponseDTO.swift
// Data
//
// Created by 김도현 on 11/25/24.
//

import Foundation

import Domain

struct MissonTodayContentResponseDTO: Decodable {
let date: String
let missionId: String
let missionContent: String


enum CodingKeys: String, CodingKey {
case date
case missionId = "id"
case missionContent = "content"
}
}


extension MissonTodayContentResponseDTO {
public func toDomain() -> MissonTodayContentEntity {
return .init(
missionId: missionId,
missionContent: missionContent,
date: date
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension MissionAPIWorker {
/// 미션 일일 정보를 조회하기 위한 API 입니다.
/// HTTP Method : GET
/// - Returns : CameraTodayMissionResponseDTO
func fetchDailyMisson() -> Observable<CameraTodayMissionResponseDTO?> {
func fetchDailyMisson() -> Observable<MissonTodayContentResponseDTO?> {
let spec = MissionAPIs.fetchDailyMisson.spec

return request(spec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension MissionRepository {
.map { $0?.toDomain() }
}

public func fetchDailyMissonItem() -> Observable<CameraTodayMssionEntity?> {
public func fetchDailyMissonItem() -> Observable<MissonTodayContentEntity?> {
return missionAPIWorker.fetchDailyMisson()
.map { $0?.toDomain() }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// MissonTodayContentEntity.swift
// Domain
//
// Created by 김도현 on 11/25/24.
//

import Foundation

public struct MissonTodayContentEntity {
public let missionId: String
public let missionContent: String
public let date: String

public init(
missionId: String,
missionContent: String,
date: String
) {
self.missionId = missionId
self.missionContent = missionContent
self.date = date
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public protocol MissionRepositoryProtocol {

/// FETCH
func fetchMissonContentItem(missonId: String) -> Observable<MissionContentEntity?>
func fetchDailyMissonItem() -> Observable<CameraTodayMssionEntity?>
func fetchDailyMissonItem() -> Observable<MissonTodayContentEntity?>

/// LOCAL DB
func isAlreadyShowMissionAlert() -> Observable<Bool>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// FetchDailyMissonContentUseCase.swift
// Domain
//
// Created by 김도현 on 11/25/24.
//

import Foundation

import RxSwift


public protocol FetchDailyMissonContentUseCaseProtocol {
func execute() -> Observable<MissonTodayContentEntity?>
}

public final class FetchDailyMissonContentUseCase: FetchDailyMissonContentUseCaseProtocol {

private let missionRepository: any MissionRepositoryProtocol

public init(missionRepository: any MissionRepositoryProtocol) {
self.missionRepository = missionRepository
}

public func execute() -> Observable<MissonTodayContentEntity?> {
return missionRepository.fetchDailyMissonItem()
}
}

0 comments on commit 93648aa

Please sign in to comment.