From 6752c097e4ea1ef5b3887f683eda097fb836fd47 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Tue, 7 Mar 2023 19:14:31 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat=20::=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=A7=81=ED=9B=84=20=ED=83=AD=EB=B0=94=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=8B=A0=EC=B2=AD=20=ED=83=AD=EC=9D=B4=20=EC=82=AC?= =?UTF-8?q?=EB=9D=BC=EC=A7=80=EB=8A=94=20=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignupTerms/SignupTermsViewModel.swift | 4 ++- .../Sources/Base/DmsFeaturesResponseDTO.swift | 6 ++++ .../Students/Response/SignupResponseDTO.swift | 27 ++++++++++++++++++ .../Stub/AuthRepositoryStub.swift | 24 ++++++++++++---- .../UseCases/Fake/SigninUseCaseFake.swift | 14 +++++++--- .../Impl/StudentsRepositoryImpl.swift | 2 +- .../Stub/StudentsRepositoryStub.swift | 13 +++++++-- .../UseCases/Fake/SignupUseCaseFake.swift | 28 +++++++++++++++++++ .../UseCases/Impl/SignupUseCaseImpl.swift | 2 +- .../Sources/Entities/DmsFeatures.swift | 12 ++++++++ .../Repository/StudentsRepository.swift | 2 +- .../Students/UseCases/SignupUseCase.swift | 2 +- .../Stub/RemoteAuthDataSourceStub.swift | 24 ++++++++++++---- .../DmsFeaturesDataTransfer.swift | 3 ++ .../Impl/RemoteStudentsDataSourceImpl.swift | 6 ++-- .../Remote/RemoteStudentsDataSource.swift | 2 +- .../Stub/RemoteStudentsDataSourceStub.swift | 13 +++++++-- 17 files changed, 154 insertions(+), 30 deletions(-) create mode 100644 Projects/Services/DataMappingModule/Sources/Students/Response/SignupResponseDTO.swift create mode 100644 Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift index 21522914..3c547639 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift @@ -6,6 +6,7 @@ final class SignupTermsViewModel: BaseViewModel { @Published var isAgreeTerms = false @Published var isShowingAlert = false @Published var alertMessage = "" + @Published var dmsFeatures: DmsFeatures? private let signupUseCase: any SignupUseCase let signupTermsParam: SignupTermsParam @@ -34,7 +35,8 @@ final class SignupTermsViewModel: BaseViewModel { profileImageUrl: signupTermsParam.profileImageURLString ) ) - ) { [weak self] _ in + ) { [weak self] feature in + self?.dmsFeatures = feature self?.isShowingAlert = true self?.alertMessage = "회원가입이 완료되었습니다!" } diff --git a/Projects/Services/DataMappingModule/Sources/Base/DmsFeaturesResponseDTO.swift b/Projects/Services/DataMappingModule/Sources/Base/DmsFeaturesResponseDTO.swift index 9ba5f522..94507795 100644 --- a/Projects/Services/DataMappingModule/Sources/Base/DmsFeaturesResponseDTO.swift +++ b/Projects/Services/DataMappingModule/Sources/Base/DmsFeaturesResponseDTO.swift @@ -5,10 +5,16 @@ public struct DmsFeaturesResponseDTO: Decodable { } public struct DmsFeaturesDTO: Decodable { + public let mealService: Bool + public let noticeService: Bool + public let pointService: Bool public let studyRoomService: Bool public let remainService: Bool enum CodingKeys: String, CodingKey { + case mealService = "meal_service" + case noticeService = "notice_service" + case pointService = "point_service" case studyRoomService = "study_room_service" case remainService = "remain_service" } diff --git a/Projects/Services/DataMappingModule/Sources/Students/Response/SignupResponseDTO.swift b/Projects/Services/DataMappingModule/Sources/Students/Response/SignupResponseDTO.swift new file mode 100644 index 00000000..48530053 --- /dev/null +++ b/Projects/Services/DataMappingModule/Sources/Students/Response/SignupResponseDTO.swift @@ -0,0 +1,27 @@ +import Foundation + +public struct SignupResponseDTO: Decodable { + public let isFeaturesOn: IsFeaturesOn + + public init( + isFeaturesOn: IsFeaturesOn + ) { + self.isFeaturesOn = isFeaturesOn + } +} + +public struct IsFeaturesOn: Decodable { + public let meal: Bool + public let notice: Bool + public let point: Bool + public let studyRoom: Bool + public let remain: Bool + + enum CodingKeys: String, CodingKey { + case meal = "meal_service" + case notice = "notice_service" + case point = "point_service" + case studyRoom = "study_room_service" + case remain = "remain_service" + } +} diff --git a/Projects/Services/DataModule/Sources/Auth/Repositories/Stub/AuthRepositoryStub.swift b/Projects/Services/DataModule/Sources/Auth/Repositories/Stub/AuthRepositoryStub.swift index 3b9d2acc..271d2976 100644 --- a/Projects/Services/DataModule/Sources/Auth/Repositories/Stub/AuthRepositoryStub.swift +++ b/Projects/Services/DataModule/Sources/Auth/Repositories/Stub/AuthRepositoryStub.swift @@ -9,9 +9,15 @@ public struct AuthRepositoryStub: AuthRepository { public func logout() {} public func signin(req: SigninRequestDTO) -> AnyPublisher { - Just(DmsFeatures(studyRoomService: false, remainService: false )) - .setFailureType(to: DmsError.self) - .eraseToAnyPublisher() + Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .eraseToAnyPublisher() } public func verifyAuthCode(req: VerifyAuthCodeRequestDTO) -> AnyPublisher { @@ -25,9 +31,15 @@ public struct AuthRepositoryStub: AuthRepository { } public func reissueToken() -> AnyPublisher { - Just(DmsFeatures(studyRoomService: false, remainService: false)) - .setFailureType(to: DmsError.self) - .eraseToAnyPublisher() + Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .eraseToAnyPublisher() } public func checkEmailExistByAccountID(req: EmailExistByAccountIDRequestDTO) -> AnyPublisher { diff --git a/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift b/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift index bf955639..34aaa94c 100644 --- a/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift +++ b/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift @@ -9,10 +9,16 @@ public struct SigninUseCaseFake: SigninUseCase { public func execute(req: SigninRequestDTO) -> AnyPublisher { if req.accountID == "baekteun" && req.password == "baekteun" { - return Just(DmsFeatures(studyRoomService: false, remainService: false)) - .setFailureType(to: DmsError.self) - .delay(for: 1, scheduler: DispatchQueue.main) - .eraseToAnyPublisher() + return Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .delay(for: 1, scheduler: DispatchQueue.main) + .eraseToAnyPublisher() } else { return Fail(error: DmsError.passwordMismatch) .delay(for: 1, scheduler: DispatchQueue.main) diff --git a/Projects/Services/DataModule/Sources/Students/Repositories/Impl/StudentsRepositoryImpl.swift b/Projects/Services/DataModule/Sources/Students/Repositories/Impl/StudentsRepositoryImpl.swift index a3f12365..91ed48ee 100644 --- a/Projects/Services/DataModule/Sources/Students/Repositories/Impl/StudentsRepositoryImpl.swift +++ b/Projects/Services/DataModule/Sources/Students/Repositories/Impl/StudentsRepositoryImpl.swift @@ -11,7 +11,7 @@ public struct StudentsRepositoryImpl: StudentsRepository { self.remoteStudentsDataSource = remoteStudentsDataSource } - public func signup(req: SignupRequestDTO) -> AnyPublisher { + public func signup(req: SignupRequestDTO) -> AnyPublisher { remoteStudentsDataSource.signup(req: req) } diff --git a/Projects/Services/DataModule/Sources/Students/Repositories/Stub/StudentsRepositoryStub.swift b/Projects/Services/DataModule/Sources/Students/Repositories/Stub/StudentsRepositoryStub.swift index bcc502a3..5ecc1051 100644 --- a/Projects/Services/DataModule/Sources/Students/Repositories/Stub/StudentsRepositoryStub.swift +++ b/Projects/Services/DataModule/Sources/Students/Repositories/Stub/StudentsRepositoryStub.swift @@ -8,9 +8,16 @@ import Foundation public struct StudentsRepositoryStub: StudentsRepository { public init() {} - public func signup(req: SignupRequestDTO) -> AnyPublisher { - Just(()).setFailureType(to: DmsError.self) - .eraseToAnyPublisher() + public func signup(req: SignupRequestDTO) -> AnyPublisher { + Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .eraseToAnyPublisher() } public func checkDuplicateAccountID(id: String) -> AnyPublisher { diff --git a/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift b/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift new file mode 100644 index 00000000..9153db49 --- /dev/null +++ b/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift @@ -0,0 +1,28 @@ +import Combine +import DataMappingModule +import DomainModule +import ErrorModule +import Foundation + +public struct SignupUseCaseFake: SignupUseCase { + public init () {} + + public func execute(req: SignupRequestDTO) -> AnyPublisher { + if req.accountID == "baekteun" && req.password == "baekteun" { + return Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .delay(for: 1, scheduler: DispatchQueue.main) + .eraseToAnyPublisher() + } else { + return Fail(error: DmsError.passwordMismatch) + .delay(for: 1, scheduler: DispatchQueue.main) + .eraseToAnyPublisher() + } + } +} diff --git a/Projects/Services/DataModule/Sources/Students/UseCases/Impl/SignupUseCaseImpl.swift b/Projects/Services/DataModule/Sources/Students/UseCases/Impl/SignupUseCaseImpl.swift index 9f299794..f2edbe67 100644 --- a/Projects/Services/DataModule/Sources/Students/UseCases/Impl/SignupUseCaseImpl.swift +++ b/Projects/Services/DataModule/Sources/Students/UseCases/Impl/SignupUseCaseImpl.swift @@ -10,7 +10,7 @@ public struct SignupUseCaseImpl: SignupUseCase { self.studentsRepository = studentsRepository } - public func execute(req: SignupRequestDTO) -> AnyPublisher { + public func execute(req: SignupRequestDTO) -> AnyPublisher { studentsRepository.signup(req: req) } } diff --git a/Projects/Services/DomainModule/Sources/Entities/DmsFeatures.swift b/Projects/Services/DomainModule/Sources/Entities/DmsFeatures.swift index 8f5913fe..ac603729 100644 --- a/Projects/Services/DomainModule/Sources/Entities/DmsFeatures.swift +++ b/Projects/Services/DomainModule/Sources/Entities/DmsFeatures.swift @@ -2,18 +2,30 @@ import Foundation public struct DmsFeatures: Equatable { public init( + mealService: Bool, + noticeService: Bool, + pointService: Bool, studyRoomService: Bool, remainService: Bool ) { + self.mealService = mealService + self.noticeService = noticeService + self.pointService = pointService self.studyRoomService = studyRoomService self.remainService = remainService } public init() { + self.mealService = false + self.noticeService = false + self.pointService = false self.studyRoomService = false self.remainService = false } + public let mealService: Bool + public let noticeService: Bool + public let pointService: Bool public let studyRoomService: Bool public let remainService: Bool } diff --git a/Projects/Services/DomainModule/Sources/Students/Repository/StudentsRepository.swift b/Projects/Services/DomainModule/Sources/Students/Repository/StudentsRepository.swift index f560fb9e..a66e66cd 100644 --- a/Projects/Services/DomainModule/Sources/Students/Repository/StudentsRepository.swift +++ b/Projects/Services/DomainModule/Sources/Students/Repository/StudentsRepository.swift @@ -3,7 +3,7 @@ import DataMappingModule import ErrorModule public protocol StudentsRepository { - func signup(req: SignupRequestDTO) -> AnyPublisher + func signup(req: SignupRequestDTO) -> AnyPublisher func checkDuplicateAccountID(id: String) -> AnyPublisher func checkDuplicateEmail(email: String) -> AnyPublisher func renewalPassword(req: RenewalPasswordRequestDTO) -> AnyPublisher diff --git a/Projects/Services/DomainModule/Sources/Students/UseCases/SignupUseCase.swift b/Projects/Services/DomainModule/Sources/Students/UseCases/SignupUseCase.swift index 451abbc3..ad6b2643 100644 --- a/Projects/Services/DomainModule/Sources/Students/UseCases/SignupUseCase.swift +++ b/Projects/Services/DomainModule/Sources/Students/UseCases/SignupUseCase.swift @@ -3,5 +3,5 @@ import DataMappingModule import ErrorModule public protocol SignupUseCase { - func execute(req: SignupRequestDTO) -> AnyPublisher + func execute(req: SignupRequestDTO) -> AnyPublisher } diff --git a/Projects/Services/NetworkModule/Sources/Auth/Remote/Stub/RemoteAuthDataSourceStub.swift b/Projects/Services/NetworkModule/Sources/Auth/Remote/Stub/RemoteAuthDataSourceStub.swift index e9538b7b..4ed50357 100644 --- a/Projects/Services/NetworkModule/Sources/Auth/Remote/Stub/RemoteAuthDataSourceStub.swift +++ b/Projects/Services/NetworkModule/Sources/Auth/Remote/Stub/RemoteAuthDataSourceStub.swift @@ -7,9 +7,15 @@ public struct RemoteAuthDataSourceStub: RemoteAuthDataSource { public init() {} public func signin(req: SigninRequestDTO) -> AnyPublisher { - Just(DmsFeatures(studyRoomService: false, remainService: false)) - .setFailureType(to: DmsError.self) - .eraseToAnyPublisher() + Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .eraseToAnyPublisher() } public func verifyAuthCode(req: VerifyAuthCodeRequestDTO) -> AnyPublisher { @@ -23,9 +29,15 @@ public struct RemoteAuthDataSourceStub: RemoteAuthDataSource { } public func reissueToken() -> AnyPublisher { - Just(DmsFeatures(studyRoomService: false, remainService: false)) - .setFailureType(to: DmsError.self) - .eraseToAnyPublisher() + Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .eraseToAnyPublisher() } public func checkEmailExistByAccountID(req: EmailExistByAccountIDRequestDTO) -> AnyPublisher { diff --git a/Projects/Services/NetworkModule/Sources/Base/DataTransfer/DmsFeaturesDataTransfer.swift b/Projects/Services/NetworkModule/Sources/Base/DataTransfer/DmsFeaturesDataTransfer.swift index 802d1a0c..ed599f78 100644 --- a/Projects/Services/NetworkModule/Sources/Base/DataTransfer/DmsFeaturesDataTransfer.swift +++ b/Projects/Services/NetworkModule/Sources/Base/DataTransfer/DmsFeaturesDataTransfer.swift @@ -4,6 +4,9 @@ import DomainModule public extension DmsFeaturesResponseDTO { func toDomain() -> DmsFeatures { DmsFeatures( + mealService: features.mealService, + noticeService: features.noticeService, + pointService: features.pointService, studyRoomService: features.studyRoomService, remainService: features.remainService ) diff --git a/Projects/Services/NetworkModule/Sources/Students/Remote/Impl/RemoteStudentsDataSourceImpl.swift b/Projects/Services/NetworkModule/Sources/Students/Remote/Impl/RemoteStudentsDataSourceImpl.swift index de89276b..8c13b0f0 100644 --- a/Projects/Services/NetworkModule/Sources/Students/Remote/Impl/RemoteStudentsDataSourceImpl.swift +++ b/Projects/Services/NetworkModule/Sources/Students/Remote/Impl/RemoteStudentsDataSourceImpl.swift @@ -5,8 +5,10 @@ import DomainModule import ErrorModule public final class RemoteStudentsDataSourceImpl: BaseRemoteDataSource, RemoteStudentsDataSource { - public func signup(req: SignupRequestDTO) -> AnyPublisher { - request(.signup(req)) + public func signup(req: SignupRequestDTO) -> AnyPublisher { + request(.signup(req), dto: DmsFeaturesResponseDTO.self) + .map { $0.toDomain() } + .eraseToAnyPublisher() } public func checkDuplicateAccountID(id: String) -> AnyPublisher { diff --git a/Projects/Services/NetworkModule/Sources/Students/Remote/RemoteStudentsDataSource.swift b/Projects/Services/NetworkModule/Sources/Students/Remote/RemoteStudentsDataSource.swift index 2a562c11..6da93c07 100644 --- a/Projects/Services/NetworkModule/Sources/Students/Remote/RemoteStudentsDataSource.swift +++ b/Projects/Services/NetworkModule/Sources/Students/Remote/RemoteStudentsDataSource.swift @@ -4,7 +4,7 @@ import DomainModule import ErrorModule public protocol RemoteStudentsDataSource { - func signup(req: SignupRequestDTO) -> AnyPublisher + func signup(req: SignupRequestDTO) -> AnyPublisher func checkDuplicateAccountID(id: String) -> AnyPublisher func checkDuplicateEmail(email: String) -> AnyPublisher func renewalPassword(req: RenewalPasswordRequestDTO) -> AnyPublisher diff --git a/Projects/Services/NetworkModule/Sources/Students/Remote/Stub/RemoteStudentsDataSourceStub.swift b/Projects/Services/NetworkModule/Sources/Students/Remote/Stub/RemoteStudentsDataSourceStub.swift index aacde1ea..27929e5d 100644 --- a/Projects/Services/NetworkModule/Sources/Students/Remote/Stub/RemoteStudentsDataSourceStub.swift +++ b/Projects/Services/NetworkModule/Sources/Students/Remote/Stub/RemoteStudentsDataSourceStub.swift @@ -7,9 +7,16 @@ import Foundation public struct RemoteStudentsDataSourceStub: RemoteStudentsDataSource { public init() {} - public func signup(req: SignupRequestDTO) -> AnyPublisher { - Just(()).setFailureType(to: DmsError.self) - .eraseToAnyPublisher() + public func signup(req: SignupRequestDTO) -> AnyPublisher { + Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .eraseToAnyPublisher() } public func checkDuplicateAccountID(id: String) -> AnyPublisher { From 714cdc07ce073b7141270daedcd4624e15b9a631 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Wed, 8 Mar 2023 12:30:24 +0900 Subject: [PATCH 02/11] =?UTF-8?q?feat=20::=20=EC=9D=BC=EB=8B=A8=20features?= =?UTF-8?q?=20=EC=98=AC=EB=A0=A4=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/SignupTerms/SignupTermsView.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift index f14bef92..1c21f774 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift @@ -8,6 +8,7 @@ struct SignupTermsView: View { @StateObject var viewModel: SignupTermsViewModel @Environment(\.dismiss) var dismiss @Environment(\.colorScheme) var colorScheme + @State var isNavigateHome = false init( viewModel: SignupTermsViewModel @@ -61,5 +62,11 @@ struct SignupTermsView: View { appState.sceneFlow = . main } } + .onChange(of: viewModel.dmsFeatures) { newValue in + if let newValue { + appState.features = newValue + } + } + .environment(\.rootPresentationMode, $isNavigateHome) } } From f971e1d67ecabab8345743f5d6f6769b4b08294c Mon Sep 17 00:00:00 2001 From: baegteun Date: Wed, 8 Mar 2023 14:09:08 +0900 Subject: [PATCH 03/11] test :: Authentication Test --- .../Services/APIKit/Sources/StudentsAPI.swift | 2 ++ .../Repository/AuthRepositoryImplSpec.swift | 25 +++++------------ .../Auth/UseCase/SigninUseCaseImplSpec.swift | 18 ------------- .../StudentsRepositoryImplSpec.swift | 6 ++--- .../UseCase/SignupUseCaseImplSpec.swift | 2 +- .../Remote/RemoteAuthDataSourceImplSpec.swift | 15 ----------- .../RemoteStudentsDataSourceImplSpec.swift | 27 +------------------ 7 files changed, 13 insertions(+), 82 deletions(-) diff --git a/Projects/Services/APIKit/Sources/StudentsAPI.swift b/Projects/Services/APIKit/Sources/StudentsAPI.swift index b3c02fe9..b01b07f9 100644 --- a/Projects/Services/APIKit/Sources/StudentsAPI.swift +++ b/Projects/Services/APIKit/Sources/StudentsAPI.swift @@ -206,6 +206,8 @@ extension StudentsAPI: DmsAPI { "school_name" : "광주소프트웨어마이스터고등학교", "name" : "변찬우", "gcn" : "2118", + "profile_image_url": "", + "sex": "MALE", "bonus_point" : 0, "minus_point" : 24, "phrase" : "안녕하세요 프론트하는 변찬우입니다" diff --git a/Projects/Services/DataModule/Tests/Auth/Repository/AuthRepositoryImplSpec.swift b/Projects/Services/DataModule/Tests/Auth/Repository/AuthRepositoryImplSpec.swift index cf6ea5a2..707d433e 100644 --- a/Projects/Services/DataModule/Tests/Auth/Repository/AuthRepositoryImplSpec.swift +++ b/Projects/Services/DataModule/Tests/Auth/Repository/AuthRepositoryImplSpec.swift @@ -4,6 +4,8 @@ import Combine import DomainModule import DataModule import NetworkModule +import DatabaseModule +@testable import KeychainModule // swiftlint: disable function_body_length final class AuthRepositoryImplSpec: QuickSpec { @@ -14,27 +16,12 @@ final class AuthRepositoryImplSpec: QuickSpec { beforeEach { remoteAuthDS = RemoteAuthDataSourceStub() - sut = AuthRepositoryImpl(remoteAuthDataSource: remoteAuthDS) + sut = AuthRepositoryImpl( + remoteAuthDataSource: remoteAuthDS, + localAuthDataSource: LocalAuthDataSourceImpl(keychain: KeychainFake()) + ) } describe("AuthRepositoryImpl에서") { - context("signin()를 실행하면") { - it("request를 성공적으로 실행한다.") { - var success: Void? - var res: DmsFeatures? - sut.signin(req: .init(accountID: "", password: "")) - .sink { _ in } receiveValue: { item in - success = () - res = item - } - .store(in: &bag) - expect { success }.toNotEventually(beNil()) - expect { success }.toEventually(beVoid()) - expect { res }.toNot(beNil()) - expect { res?.mealService }.to(beFalse()) - expect { res?.noticeService }.to(beFalse()) - expect { res?.pointService }.to(beFalse()) - } - } context("verifyAuthCode()를 실행하면") { it("request를 성공적으로 실행한다.") { var success: Void? diff --git a/Projects/Services/DataModule/Tests/Auth/UseCase/SigninUseCaseImplSpec.swift b/Projects/Services/DataModule/Tests/Auth/UseCase/SigninUseCaseImplSpec.swift index 62e816ac..15fcfc5b 100644 --- a/Projects/Services/DataModule/Tests/Auth/UseCase/SigninUseCaseImplSpec.swift +++ b/Projects/Services/DataModule/Tests/Auth/UseCase/SigninUseCaseImplSpec.swift @@ -15,24 +15,6 @@ final class SigninUseCaseImplSpec: QuickSpec { sut = SigninUseCaseImpl(authRepository: repo) } describe("SigninUseCaseImpl에서") { - context("execute()를 실행하면") { - it("request를 성공적으로 실행한다.") { - var success: Void? - var res: DmsFeatures? - sut.execute(req: .init(accountID: "", password: "")) - .sink { _ in } receiveValue: { item in - success = () - res = item - } - .store(in: &bag) - expect { success }.toNotEventually(beNil()) - expect { success }.toEventually(beVoid()) - expect { res }.toNot(beNil()) - expect { res?.mealService }.to(beFalse()) - expect { res?.noticeService }.to(beFalse()) - expect { res?.pointService }.to(beFalse()) - } - } } } } diff --git a/Projects/Services/DataModule/Tests/Students/Repository/StudentsRepositoryImplSpec.swift b/Projects/Services/DataModule/Tests/Students/Repository/StudentsRepositoryImplSpec.swift index 0aa83728..ffe467ad 100644 --- a/Projects/Services/DataModule/Tests/Students/Repository/StudentsRepositoryImplSpec.swift +++ b/Projects/Services/DataModule/Tests/Students/Repository/StudentsRepositoryImplSpec.swift @@ -19,7 +19,7 @@ final class StudentsRepositoryImplSpec: QuickSpec { describe("StudentsRepositoryImpl에서") { context("signup()을 실행하면") { it("request를 성공적으로 실행한다.") { - var success: Void? + var success: DmsFeatures? sut.signup( req: .init( schoolCode: "", @@ -91,7 +91,7 @@ final class StudentsRepositoryImplSpec: QuickSpec { expect { success }.toNotEventually(beNil()) expect { success }.toEventually(beVoid()) expect { res }.toNotEventually(beNil()) - expect { res }.toEventually(equal("abc*****@gmail.com")) + expect { res }.toEventually(equal("abcdef@gmail.com")) } } context("fetchMyProfile()을 실행하면") { @@ -112,7 +112,7 @@ final class StudentsRepositoryImplSpec: QuickSpec { expect { res!.gcn }.toEventually(equal("2118")) expect { res!.bonusPoint }.toEventually(equal(0)) expect { res!.minusPoint }.toEventually(equal(24)) - expect { res!.phrase }.toEventually(equal("안녕하세요")) + expect { res!.phrase }.toEventually(equal("벌점이 12점이예요. 더 바른 생활을 위해 노력해주세요!")) } } } diff --git a/Projects/Services/DataModule/Tests/Students/UseCase/SignupUseCaseImplSpec.swift b/Projects/Services/DataModule/Tests/Students/UseCase/SignupUseCaseImplSpec.swift index c94aaa69..20f0f773 100644 --- a/Projects/Services/DataModule/Tests/Students/UseCase/SignupUseCaseImplSpec.swift +++ b/Projects/Services/DataModule/Tests/Students/UseCase/SignupUseCaseImplSpec.swift @@ -17,7 +17,7 @@ final class SignupUseCaseImplSpec: QuickSpec { describe("SignupUseCaseImpl에서") { context("execute()를 실행하면") { it("request를 성공적으로 실행한다.") { - var success: Void? + var success: DmsFeatures? sut.execute( req: .init( schoolCode: "", diff --git a/Projects/Services/NetworkModule/Tests/Auth/Remote/RemoteAuthDataSourceImplSpec.swift b/Projects/Services/NetworkModule/Tests/Auth/Remote/RemoteAuthDataSourceImplSpec.swift index 34124f3b..aecee671 100644 --- a/Projects/Services/NetworkModule/Tests/Auth/Remote/RemoteAuthDataSourceImplSpec.swift +++ b/Projects/Services/NetworkModule/Tests/Auth/Remote/RemoteAuthDataSourceImplSpec.swift @@ -32,21 +32,6 @@ final class RemoteAuthDataSourceImplSpec: QuickSpec { provider: provider) } describe("RemoteAuthDataSourceImpl에서") { - context("signin()을 실행하면") { - it("request를 성공적으로 실행한다.") { - var success: Void? - var res: DmsFeatures? - sut.signin(req: .init(accountID: "", password: "")) - .sink { _ in } receiveValue: { item in - success = () - res = item - } - .store(in: &bag) - expect { success }.toNotEventually(beNil()) - expect { success }.toEventually(beVoid()) - expect { res }.toNot(beNil()) - } - } context("verifyAuthCode()를 실행하면") { it("request를 성공적으로 실행한다.") { var success: Void? diff --git a/Projects/Services/NetworkModule/Tests/Students/Remote/RemoteStudentsDataSourceImplSpec.swift b/Projects/Services/NetworkModule/Tests/Students/Remote/RemoteStudentsDataSourceImplSpec.swift index 7c0b73ef..7f4e0658 100644 --- a/Projects/Services/NetworkModule/Tests/Students/Remote/RemoteStudentsDataSourceImplSpec.swift +++ b/Projects/Services/NetworkModule/Tests/Students/Remote/RemoteStudentsDataSourceImplSpec.swift @@ -39,31 +39,6 @@ final class RemoteStudentsDataSourceImplSpec: QuickSpec { ) } describe("RemoteStudentsDataSourceImpl에서") { - context("Signup()을 실행하면 ") { - it("request를 성공적으로 실행한다.") { - var success: Void? - sut.signup( - req: SignupRequestDTO( - schoolCode: "", - schoolAnswer: "", - email: "", - authCode: "", - grade: 0, - classRoom: 0, - number: 0, - accountID: "", - password: "", - profileImageUrl: nil - ) - ) - .sink { _ in } receiveValue: { item in - success = item - } - .store(in: &bag) - expect { success }.toNotEventually(beNil()) - expect { success }.toEventually(beVoid()) - } - } context("checkDuplicateAccountID()을 실행하면 ") { it("request를 성공적으로 실행한다.") { var success: Void? @@ -142,7 +117,7 @@ final class RemoteStudentsDataSourceImplSpec: QuickSpec { keychain.save(type: .accessExpiredAt, value: Date().addingTimeInterval(500).toDMSDateString()) } afterEach { - keychain.delete(type: .expiredAt) + keychain.delete(type: .accessExpiredAt) } it("request를 성공적으로 실행하고, sampleData가 Response로 온다.") { var success: Void? From 62200a0d63c178c5d2ad26ec1153e087d950a9bb Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Wed, 8 Mar 2023 21:32:46 +0900 Subject: [PATCH 04/11] =?UTF-8?q?feat=20::=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=84=B1=EA=B3=B5=20=EC=8B=9C=20toast=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignupFeature/Sources/SignupTerms/SignupTermsView.swift | 5 ++--- .../Sources/SignupTerms/SignupTermsViewModel.swift | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift index 1c21f774..4e2fe4be 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift @@ -8,7 +8,6 @@ struct SignupTermsView: View { @StateObject var viewModel: SignupTermsViewModel @Environment(\.dismiss) var dismiss @Environment(\.colorScheme) var colorScheme - @State var isNavigateHome = false init( viewModel: SignupTermsViewModel @@ -54,7 +53,7 @@ struct SignupTermsView: View { ) } .dmsBackButton(dismiss: dismiss) - .dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) + .dmsToast(isShowing: $viewModel.isShowingAlert, message: viewModel.alertMessage, style: .success) .padding(.horizontal, 24) .dmsBackground() .alert(viewModel.alertMessage, isPresented: $viewModel.isShowingAlert) { @@ -67,6 +66,6 @@ struct SignupTermsView: View { appState.features = newValue } } - .environment(\.rootPresentationMode, $isNavigateHome) + .dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) } } diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift index 3c547639..ed1a0a2d 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift @@ -37,8 +37,8 @@ final class SignupTermsViewModel: BaseViewModel { ) ) { [weak self] feature in self?.dmsFeatures = feature - self?.isShowingAlert = true self?.alertMessage = "회원가입이 완료되었습니다!" + self?.isShowingAlert = true } } } From 4742a32f7909911a202e3e64a67ad60a4c1b3f9a Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Wed, 8 Mar 2023 22:38:54 +0900 Subject: [PATCH 05/11] =?UTF-8?q?refactor=20::=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignupFeature/Sources/SignupTerms/SignupTermsView.swift | 1 - .../Sources/SignupTerms/SignupTermsViewModel.swift | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift index 4e2fe4be..cde201ec 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift @@ -53,7 +53,6 @@ struct SignupTermsView: View { ) } .dmsBackButton(dismiss: dismiss) - .dmsToast(isShowing: $viewModel.isShowingAlert, message: viewModel.alertMessage, style: .success) .padding(.horizontal, 24) .dmsBackground() .alert(viewModel.alertMessage, isPresented: $viewModel.isShowingAlert) { diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift index ed1a0a2d..3c547639 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift @@ -37,8 +37,8 @@ final class SignupTermsViewModel: BaseViewModel { ) ) { [weak self] feature in self?.dmsFeatures = feature - self?.alertMessage = "회원가입이 완료되었습니다!" self?.isShowingAlert = true + self?.alertMessage = "회원가입이 완료되었습니다!" } } } From 687c16a5b2428ae5e27b9f070c485eb77c8ec214 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Wed, 8 Mar 2023 23:13:12 +0900 Subject: [PATCH 06/11] =?UTF-8?q?refactor=20::=20=ED=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Students/Response/SignupResponseDTO.swift | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 Projects/Services/DataMappingModule/Sources/Students/Response/SignupResponseDTO.swift diff --git a/Projects/Services/DataMappingModule/Sources/Students/Response/SignupResponseDTO.swift b/Projects/Services/DataMappingModule/Sources/Students/Response/SignupResponseDTO.swift deleted file mode 100644 index 48530053..00000000 --- a/Projects/Services/DataMappingModule/Sources/Students/Response/SignupResponseDTO.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Foundation - -public struct SignupResponseDTO: Decodable { - public let isFeaturesOn: IsFeaturesOn - - public init( - isFeaturesOn: IsFeaturesOn - ) { - self.isFeaturesOn = isFeaturesOn - } -} - -public struct IsFeaturesOn: Decodable { - public let meal: Bool - public let notice: Bool - public let point: Bool - public let studyRoom: Bool - public let remain: Bool - - enum CodingKeys: String, CodingKey { - case meal = "meal_service" - case notice = "notice_service" - case point = "point_service" - case studyRoom = "study_room_service" - case remain = "remain_service" - } -} From bee9d54dac750f730e2fa58cc47de0684f4c25a7 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Wed, 8 Mar 2023 23:39:28 +0900 Subject: [PATCH 07/11] =?UTF-8?q?fix=20::=20=EC=97=90=EB=9F=AC=20=ED=94=BD?= =?UTF-8?q?=EC=8A=A4=20=ED=95=98=EA=B3=A0=20=EC=8B=B6=EC=96=B4=EC=9A=94=20?= =?UTF-8?q?=EC=B0=A1=EC=B0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignupFeature/Sources/SignupTerms/SignupTermsView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift index cde201ec..1f8b421c 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsView.swift @@ -55,6 +55,7 @@ struct SignupTermsView: View { .dmsBackButton(dismiss: dismiss) .padding(.horizontal, 24) .dmsBackground() + .dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) .alert(viewModel.alertMessage, isPresented: $viewModel.isShowingAlert) { Button("확인", role: .cancel) { appState.sceneFlow = . main @@ -65,6 +66,5 @@ struct SignupTermsView: View { appState.features = newValue } } - .dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) } } From 4fea1b498037d468b0064dd576073d96c651965e Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 9 Mar 2023 12:36:32 +0900 Subject: [PATCH 08/11] =?UTF-8?q?refactor=20::=20=ED=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignupFeature/Sources/SignupTerms/SignupTermsParam.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsParam.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsParam.swift index 062fd87f..0eef778e 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsParam.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsParam.swift @@ -6,7 +6,6 @@ public struct SignupTermsParam: Equatable { profileImageURLString: String? ) { self.schoolCode = signupProfileImageParam.schoolCode - self.schoolID = signupProfileImageParam.schoolID self.schoolAnswer = signupProfileImageParam.schoolAnswer self.email = signupProfileImageParam.email self.authCode = signupProfileImageParam.authCode @@ -19,7 +18,6 @@ public struct SignupTermsParam: Equatable { } public let schoolCode: String - public let schoolID: String public let schoolAnswer: String public let email: String public let authCode: String From 16ba65718b68c7a7fba3da6b213178a497b940fc Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 9 Mar 2023 17:28:33 +0900 Subject: [PATCH 09/11] =?UTF-8?q?fix=20::=20=EC=95=84=EB=A7=88=20=EC=9D=B4?= =?UTF-8?q?=EA=B1=B4=20=EC=A7=84=EC=A7=9C=20=EC=93=B0=EC=9E=98=EB=8D=B0?= =?UTF-8?q?=EA=B8=B0=EA=B0=80=20=EC=97=86=EC=96=B4=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UseCases/Fake/SignupUseCaseFake.swift | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift diff --git a/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift b/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift deleted file mode 100644 index 9153db49..00000000 --- a/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift +++ /dev/null @@ -1,28 +0,0 @@ -import Combine -import DataMappingModule -import DomainModule -import ErrorModule -import Foundation - -public struct SignupUseCaseFake: SignupUseCase { - public init () {} - - public func execute(req: SignupRequestDTO) -> AnyPublisher { - if req.accountID == "baekteun" && req.password == "baekteun" { - return Just(DmsFeatures( - mealService: true, - noticeService: true, - pointService: true, - studyRoomService: false, - remainService: false - )) - .setFailureType(to: DmsError.self) - .delay(for: 1, scheduler: DispatchQueue.main) - .eraseToAnyPublisher() - } else { - return Fail(error: DmsError.passwordMismatch) - .delay(for: 1, scheduler: DispatchQueue.main) - .eraseToAnyPublisher() - } - } -} From 95ef14d1bee671c90da12bac2d5b8848f25ed97b Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 9 Mar 2023 20:47:40 +0900 Subject: [PATCH 10/11] =?UTF-8?q?refactor=20::=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EB=B0=8F=20=ED=94=84=EB=A6=B0?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignupTerms/SignupTermsViewModel.swift | 2 ++ .../ErrorModule/Sources/DmsError.swift | 5 +++- .../Services/APIKit/Sources/StudentsAPI.swift | 2 ++ .../UseCases/Fake/SigninUseCaseFake.swift | 6 ++-- .../UseCases/Fake/SignupUseCaseFake.swift | 28 +++++++++++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift index 3c547639..9d81832a 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift @@ -38,6 +38,8 @@ final class SignupTermsViewModel: BaseViewModel { ) { [weak self] feature in self?.dmsFeatures = feature self?.isShowingAlert = true + print("thisis") + print(self?.dmsFeatures?.remainService ?? "failed parsing") self?.alertMessage = "회원가입이 완료되었습니다!" } } diff --git a/Projects/Modules/ErrorModule/Sources/DmsError.swift b/Projects/Modules/ErrorModule/Sources/DmsError.swift index eb66a0ea..ada38cbc 100644 --- a/Projects/Modules/ErrorModule/Sources/DmsError.swift +++ b/Projects/Modules/ErrorModule/Sources/DmsError.swift @@ -24,6 +24,7 @@ public enum DmsError: Error { case notFoundAccountID // MARK: - Students + case unAuthorizedEmail case alreadyExistUserBySignup case alreadyExistIDByCheckID case alreadyExistEmailByCheckEmail @@ -86,7 +87,7 @@ extension DmsError: LocalizedError { return "인증 정보를 찾을 수 없습니다." case .diffrentEmailByAccountID: - return "아이디외 이메일과 일치하지 않습니다." + return "아이디와 이메일이 일치하지 않습니다." case .notFoundAccountID: return "존재하지 않는 아이디입니다." @@ -95,6 +96,8 @@ extension DmsError: LocalizedError { return "학생이 등록되지 않았습니다." // MARK: - Students + case .unAuthorizedEmail: + return "이메일이 인증되지 않았습니다." case .alreadyExistUserBySignup: return "이미 회원가입한 학생합니다!" diff --git a/Projects/Services/APIKit/Sources/StudentsAPI.swift b/Projects/Services/APIKit/Sources/StudentsAPI.swift index b01b07f9..0e4a106a 100644 --- a/Projects/Services/APIKit/Sources/StudentsAPI.swift +++ b/Projects/Services/APIKit/Sources/StudentsAPI.swift @@ -127,7 +127,9 @@ extension StudentsAPI: DmsAPI { case .signup: return [ 400: .badRequest, + 401: .unAuthorizedEmail, 409: .alreadyExistUserBySignup, + 429: .tooManyRequest, 500: .internalServerError ] diff --git a/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift b/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift index dfffa651..34aaa94c 100644 --- a/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift +++ b/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift @@ -10,9 +10,9 @@ public struct SigninUseCaseFake: SigninUseCase { public func execute(req: SigninRequestDTO) -> AnyPublisher { if req.accountID == "baekteun" && req.password == "baekteun" { return Just(DmsFeatures( - mealService: false, - noticeService: false, - pointService: false, + mealService: true, + noticeService: true, + pointService: true, studyRoomService: false, remainService: false )) diff --git a/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift b/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift new file mode 100644 index 00000000..9153db49 --- /dev/null +++ b/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift @@ -0,0 +1,28 @@ +import Combine +import DataMappingModule +import DomainModule +import ErrorModule +import Foundation + +public struct SignupUseCaseFake: SignupUseCase { + public init () {} + + public func execute(req: SignupRequestDTO) -> AnyPublisher { + if req.accountID == "baekteun" && req.password == "baekteun" { + return Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .delay(for: 1, scheduler: DispatchQueue.main) + .eraseToAnyPublisher() + } else { + return Fail(error: DmsError.passwordMismatch) + .delay(for: 1, scheduler: DispatchQueue.main) + .eraseToAnyPublisher() + } + } +} From 553d5729ead736ddf49f7120cf46e1c970925a8c Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 9 Mar 2023 20:47:40 +0900 Subject: [PATCH 11/11] =?UTF-8?q?feat=20::=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20alert=20=ED=86=B5=EA=B3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignupTerms/SignupTermsViewModel.swift | 2 ++ .../ErrorModule/Sources/DmsError.swift | 5 +++- .../Services/APIKit/Sources/StudentsAPI.swift | 2 ++ .../UseCases/Fake/SigninUseCaseFake.swift | 6 ++-- .../UseCases/Fake/SignupUseCaseFake.swift | 28 +++++++++++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift diff --git a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift index 3c547639..9d81832a 100644 --- a/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift +++ b/Projects/Features/SignupFeature/Sources/SignupTerms/SignupTermsViewModel.swift @@ -38,6 +38,8 @@ final class SignupTermsViewModel: BaseViewModel { ) { [weak self] feature in self?.dmsFeatures = feature self?.isShowingAlert = true + print("thisis") + print(self?.dmsFeatures?.remainService ?? "failed parsing") self?.alertMessage = "회원가입이 완료되었습니다!" } } diff --git a/Projects/Modules/ErrorModule/Sources/DmsError.swift b/Projects/Modules/ErrorModule/Sources/DmsError.swift index eb66a0ea..ada38cbc 100644 --- a/Projects/Modules/ErrorModule/Sources/DmsError.swift +++ b/Projects/Modules/ErrorModule/Sources/DmsError.swift @@ -24,6 +24,7 @@ public enum DmsError: Error { case notFoundAccountID // MARK: - Students + case unAuthorizedEmail case alreadyExistUserBySignup case alreadyExistIDByCheckID case alreadyExistEmailByCheckEmail @@ -86,7 +87,7 @@ extension DmsError: LocalizedError { return "인증 정보를 찾을 수 없습니다." case .diffrentEmailByAccountID: - return "아이디외 이메일과 일치하지 않습니다." + return "아이디와 이메일이 일치하지 않습니다." case .notFoundAccountID: return "존재하지 않는 아이디입니다." @@ -95,6 +96,8 @@ extension DmsError: LocalizedError { return "학생이 등록되지 않았습니다." // MARK: - Students + case .unAuthorizedEmail: + return "이메일이 인증되지 않았습니다." case .alreadyExistUserBySignup: return "이미 회원가입한 학생합니다!" diff --git a/Projects/Services/APIKit/Sources/StudentsAPI.swift b/Projects/Services/APIKit/Sources/StudentsAPI.swift index b01b07f9..0e4a106a 100644 --- a/Projects/Services/APIKit/Sources/StudentsAPI.swift +++ b/Projects/Services/APIKit/Sources/StudentsAPI.swift @@ -127,7 +127,9 @@ extension StudentsAPI: DmsAPI { case .signup: return [ 400: .badRequest, + 401: .unAuthorizedEmail, 409: .alreadyExistUserBySignup, + 429: .tooManyRequest, 500: .internalServerError ] diff --git a/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift b/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift index dfffa651..34aaa94c 100644 --- a/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift +++ b/Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.swift @@ -10,9 +10,9 @@ public struct SigninUseCaseFake: SigninUseCase { public func execute(req: SigninRequestDTO) -> AnyPublisher { if req.accountID == "baekteun" && req.password == "baekteun" { return Just(DmsFeatures( - mealService: false, - noticeService: false, - pointService: false, + mealService: true, + noticeService: true, + pointService: true, studyRoomService: false, remainService: false )) diff --git a/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift b/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift new file mode 100644 index 00000000..9153db49 --- /dev/null +++ b/Projects/Services/DataModule/Sources/Students/UseCases/Fake/SignupUseCaseFake.swift @@ -0,0 +1,28 @@ +import Combine +import DataMappingModule +import DomainModule +import ErrorModule +import Foundation + +public struct SignupUseCaseFake: SignupUseCase { + public init () {} + + public func execute(req: SignupRequestDTO) -> AnyPublisher { + if req.accountID == "baekteun" && req.password == "baekteun" { + return Just(DmsFeatures( + mealService: true, + noticeService: true, + pointService: true, + studyRoomService: false, + remainService: false + )) + .setFailureType(to: DmsError.self) + .delay(for: 1, scheduler: DispatchQueue.main) + .eraseToAnyPublisher() + } else { + return Fail(error: DmsError.passwordMismatch) + .delay(for: 1, scheduler: DispatchQueue.main) + .eraseToAnyPublisher() + } + } +}