Skip to content

Commit

Permalink
Merge pull request #136 from Team-Ampersand/130-home-edit-personnel-f…
Browse files Browse the repository at this point in the history
…eature-impl

🔀 :: [#130] 자습, 안마의자 인원 수정 로직 추가
  • Loading branch information
baekteun authored Jul 30, 2023
2 parents c4e23f7 + 9cafe89 commit 68e1d2a
Show file tree
Hide file tree
Showing 57 changed files with 709 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public extension ModulePaths {
public extension ModulePaths {
enum Feature: String, MicroTargetPathConvertable {
case ProposeMusicFeature
case InputDialogFeature
case DetailNoticeFeature
case MyViolationListFeature
case SplashFeature
Expand Down
1 change: 1 addition & 0 deletions Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ let targets: [Target] = [
.feature(target: .SignupFeature),
.feature(target: .RenewalPasswordFeature),
.feature(target: .ConfirmationDialogFeature),
.feature(target: .InputDialogFeature),
.domain(target: .AuthDomain),
.domain(target: .UserDomain),
.domain(target: .SelfStudyDomain),
Expand Down
2 changes: 2 additions & 0 deletions Projects/App/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Database
import DetailNoticeFeature
import HomeFeature
import IQKeyboardManagerSwift
import InputDialogFeature
import JwtStore
import KeyValueStore
import MainTabFeature
Expand Down Expand Up @@ -47,6 +48,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
DatabaseAssembly(),
SplashAssembly(),
HomeAssembly(),
InputDialogAssembly(),
MyViolationListAssembly(),
NoticeAssembly(),
DetailNoticeAssembly(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ public protocol RemoteMassageDataSource {
func applyMassage() async throws
func cancelMassage() async throws
func fetchMassageRankList() async throws -> [MassageRankEntity]
func modifyMassagePersonnel(limit: Int) async throws
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ public protocol MassageRepository {
func applyMassage() async throws
func cancelMassage() async throws
func fetchMassageRankList() async throws -> [MassageRankEntity]
func modifyMassagePersonnel(limit: Int) async throws
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public protocol ModifyMassagePersonnelUseCase {
func callAsFunction(limit: Int) async throws
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ public final class MassageDomainAssembly: Assembly {
container.register(FetchMassageRankListUseCase.self) { resolver in
FetchMassageRankListUseCaseImpl(massageRepository: resolver.resolve(MassageRepository.self)!)
}

container.register(ModifyMassagePersonnelUseCase.self) { resolver in
ModifyMassagePersonnelUseCaseImpl(massageRepository: resolver.resolve(MassageRepository.self)!)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum MassageEndpoint {
case applyMassage
case cancelMassage
case fetchMassageRankList
case modifyMassagePersonnel(limit: Int)
}

extension MassageEndpoint: DotoriEndpoint {
Expand All @@ -28,11 +29,19 @@ extension MassageEndpoint: DotoriEndpoint {

case .fetchMassageRankList:
return .get("/rank")

case .modifyMassagePersonnel:
return .patch("/limit")
}
}

public var task: HTTPTask {
switch self {
case let .modifyMassagePersonnel(limit):
return .requestParameters(body: [
"limit": limit
])

default:
return .requestPlain
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ final class RemoteMassageDataSourceImpl: RemoteMassageDataSource {
)
.toDomain()
}

func modifyMassagePersonnel(limit: Int) async throws {
try await networking.request(MassageEndpoint.modifyMassagePersonnel(limit: limit))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ final class MassageRepositoryImpl: MassageRepository {
func fetchMassageRankList() async throws -> [MassageRankEntity] {
try await remoteMassageDataSource.fetchMassageRankList()
}

func modifyMassagePersonnel(limit: Int) async throws {
try await remoteMassageDataSource.modifyMassagePersonnel(limit: limit)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import MassageDomainInterface

struct ModifyMassagePersonnelUseCaseImpl: ModifyMassagePersonnelUseCase {
private let massageRepository: any MassageRepository

init(massageRepository: any MassageRepository) {
self.massageRepository = massageRepository
}

func callAsFunction(limit: Int) async throws {
try await massageRepository.modifyMassagePersonnel(limit: limit)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ final class RemoteMassageDataSourceSpy: RemoteMassageDataSource {
fetchMassageRankListCallCount += 1
return try await fetchMassageRankListHandler()
}

var modifyMassagePersonnelCallCount = 0
func modifyMassagePersonnel(limit: Int) async throws {
modifyMassagePersonnelCallCount += 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ final class MassageRepositorySpy: MassageRepository {
fetchMassageRankListCallCount += 1
return try await fetchMassageRankListHandler()
}

var modifyMassagePersonnelCallCount = 0
func modifyMassagePersonnel(limit: Int) async throws {
modifyMassagePersonnelCallCount += 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import MassageDomainInterface

final class ModifyMassagePersonnelUseCaseSpy: ModifyMassagePersonnelUseCase {
var modifyMassagePersonnelCallCount = 0
func callAsFunction(limit: Int) async throws {
modifyMassagePersonnelCallCount += 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public protocol RemoteSelfStudyDataSource {
func fetchSelfStudyRankList() async throws -> [SelfStudyRankEntity]
func fetchSelfStudyRankSearch(req: FetchSelfStudyRankSearchRequestDTO) async throws -> [SelfStudyRankEntity]
func checkSelfStudyMember(memberID: Int, isChecked: Bool) async throws
func modifySelfStudyPersonnel(limit: Int) async throws
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public protocol SelfStudyRepository {
func fetchSelfStudyRankList() async throws -> [SelfStudyRankEntity]
func fetchSelfStudyRankSearch(req: FetchSelfStudyRankSearchRequestDTO) async throws -> [SelfStudyRankEntity]
func checkSelfStudyMember(memberID: Int, isChecked: Bool) async throws
func modifySelfStudyPersonnel(limit: Int) async throws
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public protocol ModifySelfStudyPersonnelUseCase {
func callAsFunction(limit: Int) async throws
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ public final class SelfStudyDomainAssembly: Assembly {
container.register(CheckSelfStudyMemberUseCase.self) { resolver in
CheckSelfStudyMemberUseCaseImpl(selfStudyRepository: resolver.resolve(SelfStudyRepository.self)!)
}

container.register(ModifySelfStudyPersonnelUseCase.self) { resolver in
ModifySelfStudyPersonnelUseCaseImpl(selfStudyRepository: resolver.resolve(SelfStudyRepository.self)!)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ final class RemoteSelfStudyDataSourceImpl: RemoteSelfStudyDataSource {
SelfStudyEndpoint.checkSelfStudyMember(memberID: memberID, isChecked: isChecked)
)
}

func modifySelfStudyPersonnel(limit: Int) async throws {
try await networking.request(SelfStudyEndpoint.modifySelfStudyPersonnel(limit: limit))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum SelfStudyEndpoint {
case fetchSelfStudyRank
case fetchSelfStudySearch(FetchSelfStudyRankSearchRequestDTO)
case checkSelfStudyMember(memberID: Int, isChecked: Bool)
case modifySelfStudyPersonnel(limit: Int)
}

extension SelfStudyEndpoint: DotoriEndpoint {
Expand All @@ -35,6 +36,9 @@ extension SelfStudyEndpoint: DotoriEndpoint {

case let .checkSelfStudyMember(memberID, _):
return .patch("/check/\(memberID)")

case .modifySelfStudyPersonnel:
return .patch("/limit")
}
}

Expand All @@ -48,6 +52,11 @@ extension SelfStudyEndpoint: DotoriEndpoint {
"selfStudyCheck": isChecked
])

case let .modifySelfStudyPersonnel(limit):
return .requestParameters(body: [
"limit": limit
])

default:
return .requestPlain
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ final class SelfStudyRepositoryImpl: SelfStudyRepository {
func checkSelfStudyMember(memberID: Int, isChecked: Bool) async throws {
try await remoteSelfStudyDataSource.checkSelfStudyMember(memberID: memberID, isChecked: isChecked)
}

func modifySelfStudyPersonnel(limit: Int) async throws {
try await remoteSelfStudyDataSource.modifySelfStudyPersonnel(limit: limit)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import SelfStudyDomainInterface

struct ModifySelfStudyPersonnelUseCaseImpl: ModifySelfStudyPersonnelUseCase {
private let selfStudyRepository: any SelfStudyRepository

init(selfStudyRepository: any SelfStudyRepository) {
self.selfStudyRepository = selfStudyRepository
}

func callAsFunction(limit: Int) async throws {
try await selfStudyRepository.modifySelfStudyPersonnel(limit: limit)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ final class RemoteSelfStudyDataSourceSpy: RemoteSelfStudyDataSource {
func checkSelfStudyMember(memberID: Int, isChecked: Bool) async throws {
checkSelfStudyMemberCallCount += 1
}

var modifySelfStudyPersonnelCallCount = 0
func modifySelfStudyPersonnel(limit: Int) async throws {
modifySelfStudyPersonnelCallCount += 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ final class SelfStudyRepositorySpy: SelfStudyRepository {
func checkSelfStudyMember(memberID: Int, isChecked: Bool) async throws {
checkSelfStudyMemberCallCount += 1
}

var modifySelfStudyPersonnelCallCount = 0
func modifySelfStudyPersonnel(limit: Int) async throws {
modifySelfStudyPersonnelCallCount += 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import SelfStudyDomainInterface

final class ModifySelfStudyPersonnelUseCaseSpy: ModifySelfStudyPersonnelUseCase {
var modifySelfStudyPersonnelCallCount = 0
func callAsFunction(limit: Int) async throws {
modifySelfStudyPersonnelCallCount += 1
}
}
9 changes: 9 additions & 0 deletions Projects/Feature/BaseFeature/Interface/DialogInputType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

/**
InputDialogFeature에서 사용하기 위한 enum
*/
public enum DialogInputType {
case number
case text
}
5 changes: 5 additions & 0 deletions Projects/Feature/BaseFeature/Interface/HasRouter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Moordinator

public protocol HasRouter {
var router: any Router { get }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public protocol RoutedViewControllable: ViewControllable, HasRouter {}
5 changes: 4 additions & 1 deletion Projects/Feature/BaseFeature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import DependencyPlugin
let project = Project.module(
name: ModulePaths.Feature.BaseFeature.rawValue,
targets: [
.interface(module: .feature(.BaseFeature), dependencies: [
.SPM.Moordinator
]),
.implements(module: .feature(.BaseFeature), product: .framework, dependencies: [
.SPM.Moordinator,
.SPM.Store,
.SPM.IQKeyboardManagerSwift,
.SPM.Nuke,
.feature(target: .BaseFeature, type: .interface),
.userInterface(target: .DesignSystem),
.userInterface(target: .Localization),
.shared(target: .GlobalThirdPartyLibrary),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Anim
import BaseFeatureInterface
import Combine
import Configure
import DesignSystem
Expand All @@ -9,6 +10,7 @@ import UIKit
*/
open class BaseStoredModalViewController<Store: BaseStore>:
BaseModalViewController,
RoutedViewControllable,
StoredViewControllable,
StoreBindable {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import BaseFeatureInterface
import Moordinator
import UIKit

open class BaseStoredViewController<Store: BaseStore>:
BaseViewController,
RoutedViewControllable,
StoredViewControllable,
StoreBindable {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import BaseFeatureInterface
import Combine
import DesignSystem
import UIKit

open class BaseViewController:
UIViewController,
ViewControllable,
HasCancellableBag,
AddViewable,
SetLayoutable,
Expand Down
7 changes: 7 additions & 0 deletions Projects/Feature/BaseFeature/Sources/DotoriRoutePath.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BaseFeatureInterface
import Moordinator
import UIKit

Expand All @@ -14,6 +15,12 @@ public enum DotoriRoutePath: RoutePath {
description: String = "",
confirmAction: () async -> Void
)
case inputDialog(
title: String,
placeholder: String,
inputType: DialogInputType,
confirmAction: (String) async -> Void
)
case dismiss
case pop

Expand Down
10 changes: 9 additions & 1 deletion Projects/Feature/BaseFeature/Sources/Protocol/HasStore.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import BaseFeatureInterface
import Foundation
import Moordinator

public protocol HasStore {
public protocol HasStore: HasRouter {
associatedtype Store: BaseStore
var store: Store { get }
}

extension HasStore {
public var router: any Router {
store
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BaseFeatureInterface
import UIKit

public protocol StoredViewControllable: ViewControllable, HasStore {}
4 changes: 4 additions & 0 deletions Projects/Feature/HomeFeature/Demo/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
let loadCurrentUserRoleUseCase: LoadCurrentUserRoleUseCaseSpy = .init()
let applySelfStudyUseCase: ApplySelfStudyUseCaseSpy = .init()
let cancelSelfStudyUseCase = CancelSelfStudyUseCaseSpy()
let modifySelfStudyPersonnelUseCase = ModifySelfStudyPersonnelUseCaseSpy()
let applyMassageUseCase: ApplyMassageUseCaseSpy = .init()
let cancelMassageUseCase = CancelMassageUseCaseSpy()
let modifyMassagePersonnelUseCase = ModifyMassagePersonnelUseCaseSpy()
let logoutUseCase = LogoutUseCaseSpy()
let store = HomeStore(
repeatableTimer: repeatableTimerStub,
Expand All @@ -40,8 +42,10 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
loadCurrentUserRoleUseCase: loadCurrentUserRoleUseCase,
applySelfStudyUseCase: applySelfStudyUseCase,
cancelSelfStudyUseCase: cancelSelfStudyUseCase,
modifySelfStudyPersonnelUseCase: modifySelfStudyPersonnelUseCase,
applyMassageUseCase: applyMassageUseCase,
cancelMassageUseCase: cancelMassageUseCase,
modifyMassagePersonnelUseCase: modifyMassagePersonnelUseCase,
logoutUseCase: logoutUseCase
)
let viewController = Inject.ViewControllerHost(
Expand Down
Loading

0 comments on commit 68e1d2a

Please sign in to comment.