From 231c8a0da4556b9d31bebf8ac02465f0c3ed4f66 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:43:29 +0900 Subject: [PATCH 01/11] :sparkles: :: [#372] GovernmentDomain / Entity --- .../DI/Government/AppComponent+Government.swift | 9 +++++++++ .../Government/RemoteGovernmentDataSourceImpl.swift | 8 ++++++++ .../Repository/Government/GovernmentRepositoryImpl.swift | 8 ++++++++ .../Government/CreatedGovernmentUseCaseImpl.swift | 8 ++++++++ .../UseCase/Government/DeleteGovernmentUseCaseImpl.swift | 8 ++++++++ .../UseCase/Government/FetchGovernmentUseCaseImpl.swift | 8 ++++++++ .../Domain/GovernmentDomain/API/GovernmentAPI.swift | 8 ++++++++ .../DTO/Request/CreatedGovernmentRequestDTO.swift | 8 ++++++++ .../DTO/Response/GovernmentListResponseDTO.swift | 8 ++++++++ .../DataSource/RemoteGovernmentDataSource.swift | 8 ++++++++ .../GovernmentDomain/Entity/GovernmentInfoEntity.swift | 7 +++++++ .../GovernmentDomain/Error/GovernmentDomainError.swift | 8 ++++++++ .../Repository/GovernmentRepository.swift | 8 ++++++++ .../UseCase/CreatedGovernmentUseCase.swift | 8 ++++++++ .../UseCase/DeleteGovernmentUseCase.swift | 8 ++++++++ .../UseCase/FetchGovernmentListUseCase.swift | 8 ++++++++ 16 files changed, 128 insertions(+) create mode 100644 App/Sources/Application/DI/Government/AppComponent+Government.swift create mode 100644 Service/Sources/Data/DataSource/Government/RemoteGovernmentDataSourceImpl.swift create mode 100644 Service/Sources/Data/Repository/Government/GovernmentRepositoryImpl.swift create mode 100644 Service/Sources/Data/UseCase/Government/CreatedGovernmentUseCaseImpl.swift create mode 100644 Service/Sources/Data/UseCase/Government/DeleteGovernmentUseCaseImpl.swift create mode 100644 Service/Sources/Data/UseCase/Government/FetchGovernmentUseCaseImpl.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/API/GovernmentAPI.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/DTO/Request/CreatedGovernmentRequestDTO.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/DTO/Response/GovernmentListResponseDTO.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/DataSource/RemoteGovernmentDataSource.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/Entity/GovernmentInfoEntity.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/Error/GovernmentDomainError.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/Repository/GovernmentRepository.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/UseCase/CreatedGovernmentUseCase.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/UseCase/DeleteGovernmentUseCase.swift create mode 100644 Service/Sources/Domain/GovernmentDomain/UseCase/FetchGovernmentListUseCase.swift diff --git a/App/Sources/Application/DI/Government/AppComponent+Government.swift b/App/Sources/Application/DI/Government/AppComponent+Government.swift new file mode 100644 index 00000000..0ced908a --- /dev/null +++ b/App/Sources/Application/DI/Government/AppComponent+Government.swift @@ -0,0 +1,9 @@ +// +// AppComponent+Government.swift +// Bitgouel +// +// Created by 정윤서 on 7/18/24. +// Copyright © 2024 team.msg. All rights reserved. +// + +import Foundation diff --git a/Service/Sources/Data/DataSource/Government/RemoteGovernmentDataSourceImpl.swift b/Service/Sources/Data/DataSource/Government/RemoteGovernmentDataSourceImpl.swift new file mode 100644 index 00000000..1b34a52b --- /dev/null +++ b/Service/Sources/Data/DataSource/Government/RemoteGovernmentDataSourceImpl.swift @@ -0,0 +1,8 @@ +// +// RemoteGovernmentDataSourceImpl.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Data/Repository/Government/GovernmentRepositoryImpl.swift b/Service/Sources/Data/Repository/Government/GovernmentRepositoryImpl.swift new file mode 100644 index 00000000..9324a538 --- /dev/null +++ b/Service/Sources/Data/Repository/Government/GovernmentRepositoryImpl.swift @@ -0,0 +1,8 @@ +// +// GovernmentRepositoryImpl.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Data/UseCase/Government/CreatedGovernmentUseCaseImpl.swift b/Service/Sources/Data/UseCase/Government/CreatedGovernmentUseCaseImpl.swift new file mode 100644 index 00000000..de0f84d3 --- /dev/null +++ b/Service/Sources/Data/UseCase/Government/CreatedGovernmentUseCaseImpl.swift @@ -0,0 +1,8 @@ +// +// CreatedGovernmentUseCaseImpl.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Data/UseCase/Government/DeleteGovernmentUseCaseImpl.swift b/Service/Sources/Data/UseCase/Government/DeleteGovernmentUseCaseImpl.swift new file mode 100644 index 00000000..156cd2ac --- /dev/null +++ b/Service/Sources/Data/UseCase/Government/DeleteGovernmentUseCaseImpl.swift @@ -0,0 +1,8 @@ +// +// DeleteGovernmentUseCaseImpl.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Data/UseCase/Government/FetchGovernmentUseCaseImpl.swift b/Service/Sources/Data/UseCase/Government/FetchGovernmentUseCaseImpl.swift new file mode 100644 index 00000000..a9fc1207 --- /dev/null +++ b/Service/Sources/Data/UseCase/Government/FetchGovernmentUseCaseImpl.swift @@ -0,0 +1,8 @@ +// +// FetchGovernmentUseCaseImpl.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/API/GovernmentAPI.swift b/Service/Sources/Domain/GovernmentDomain/API/GovernmentAPI.swift new file mode 100644 index 00000000..1f566194 --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/API/GovernmentAPI.swift @@ -0,0 +1,8 @@ +// +// GovernmentAPI.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/DTO/Request/CreatedGovernmentRequestDTO.swift b/Service/Sources/Domain/GovernmentDomain/DTO/Request/CreatedGovernmentRequestDTO.swift new file mode 100644 index 00000000..b05172d8 --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/DTO/Request/CreatedGovernmentRequestDTO.swift @@ -0,0 +1,8 @@ +// +// CreatedGovernmentRequestDTO.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/DTO/Response/GovernmentListResponseDTO.swift b/Service/Sources/Domain/GovernmentDomain/DTO/Response/GovernmentListResponseDTO.swift new file mode 100644 index 00000000..c7a20c6d --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/DTO/Response/GovernmentListResponseDTO.swift @@ -0,0 +1,8 @@ +// +// GovernmentListResponseDTO.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/DataSource/RemoteGovernmentDataSource.swift b/Service/Sources/Domain/GovernmentDomain/DataSource/RemoteGovernmentDataSource.swift new file mode 100644 index 00000000..a90dc559 --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/DataSource/RemoteGovernmentDataSource.swift @@ -0,0 +1,8 @@ +// +// RemoteGovernmentDataSource.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/Entity/GovernmentInfoEntity.swift b/Service/Sources/Domain/GovernmentDomain/Entity/GovernmentInfoEntity.swift new file mode 100644 index 00000000..9e09767d --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/Entity/GovernmentInfoEntity.swift @@ -0,0 +1,7 @@ +import Foundation + +public struct GovernmentInfoEntity: Equatable { + public let governmentID: Int + public let field: FieldType + public let governmentName: String +} diff --git a/Service/Sources/Domain/GovernmentDomain/Error/GovernmentDomainError.swift b/Service/Sources/Domain/GovernmentDomain/Error/GovernmentDomainError.swift new file mode 100644 index 00000000..8b37fa37 --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/Error/GovernmentDomainError.swift @@ -0,0 +1,8 @@ +// +// GovernmentDomainError.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/Repository/GovernmentRepository.swift b/Service/Sources/Domain/GovernmentDomain/Repository/GovernmentRepository.swift new file mode 100644 index 00000000..5a693706 --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/Repository/GovernmentRepository.swift @@ -0,0 +1,8 @@ +// +// GovernmentRepository.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/UseCase/CreatedGovernmentUseCase.swift b/Service/Sources/Domain/GovernmentDomain/UseCase/CreatedGovernmentUseCase.swift new file mode 100644 index 00000000..b1eb312d --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/UseCase/CreatedGovernmentUseCase.swift @@ -0,0 +1,8 @@ +// +// CreatedGovernmentUseCase.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/UseCase/DeleteGovernmentUseCase.swift b/Service/Sources/Domain/GovernmentDomain/UseCase/DeleteGovernmentUseCase.swift new file mode 100644 index 00000000..4bc9c335 --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/UseCase/DeleteGovernmentUseCase.swift @@ -0,0 +1,8 @@ +// +// DeleteGovernmentUseCase.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation diff --git a/Service/Sources/Domain/GovernmentDomain/UseCase/FetchGovernmentListUseCase.swift b/Service/Sources/Domain/GovernmentDomain/UseCase/FetchGovernmentListUseCase.swift new file mode 100644 index 00000000..b3d10d21 --- /dev/null +++ b/Service/Sources/Domain/GovernmentDomain/UseCase/FetchGovernmentListUseCase.swift @@ -0,0 +1,8 @@ +// +// FetchGovernmentListUseCase.swift +// Service +// +// Created by 정윤서 on 7/18/24. +// + +import Foundation From d3dc4794327a3e95389cc8598ee158dd814345c4 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:43:53 +0900 Subject: [PATCH 02/11] :sparkles: :: [#372] GovernmentDomain / DTO --- .../Request/CreatedGovernmentRequestDTO.swift | 20 +++++++---- .../Response/GovernmentListResponseDTO.swift | 33 +++++++++++++++---- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Service/Sources/Domain/GovernmentDomain/DTO/Request/CreatedGovernmentRequestDTO.swift b/Service/Sources/Domain/GovernmentDomain/DTO/Request/CreatedGovernmentRequestDTO.swift index b05172d8..468b3521 100644 --- a/Service/Sources/Domain/GovernmentDomain/DTO/Request/CreatedGovernmentRequestDTO.swift +++ b/Service/Sources/Domain/GovernmentDomain/DTO/Request/CreatedGovernmentRequestDTO.swift @@ -1,8 +1,14 @@ -// -// CreatedGovernmentRequestDTO.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public struct CreatedGovernmentRequestDTO: Encodable { + public let field: FieldType + public let governmentName: String + + public init( + field: FieldType, + governmentName: String + ) { + self.field = field + self.governmentName = governmentName + } +} diff --git a/Service/Sources/Domain/GovernmentDomain/DTO/Response/GovernmentListResponseDTO.swift b/Service/Sources/Domain/GovernmentDomain/DTO/Response/GovernmentListResponseDTO.swift index c7a20c6d..ac79b0a5 100644 --- a/Service/Sources/Domain/GovernmentDomain/DTO/Response/GovernmentListResponseDTO.swift +++ b/Service/Sources/Domain/GovernmentDomain/DTO/Response/GovernmentListResponseDTO.swift @@ -1,8 +1,27 @@ -// -// GovernmentListResponseDTO.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public struct GovernmentListResponseDTO: Decodable { + public let governments: [GovernmentInfoResponseDTO] +} + +public struct GovernmentInfoResponseDTO: Decodable { + public let governmentID: Int + public let field: FieldType + public let governmentName: String +} + +extension GovernmentListResponseDTO { + func toDomain() -> [GovernmentInfoEntity] { + governments.map { $0.toDomain() } + } +} + +extension GovernmentInfoResponseDTO { + func toDomain() -> GovernmentInfoEntity { + GovernmentInfoEntity( + governmentID: governmentID, + field: field, + governmentName: governmentName + ) + } +} From c6f5831369fdfdc6c5440b2e007a105027ffbcc3 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:44:31 +0900 Subject: [PATCH 03/11] :sparkles: :: [#372] GovernmentDomain / API --- Service/Sources/Base/BitgouelAPI.swift | 1 + .../GovernmentDomain/API/GovernmentAPI.swift | 80 +++++++++++++++++-- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/Service/Sources/Base/BitgouelAPI.swift b/Service/Sources/Base/BitgouelAPI.swift index f45f537a..178bb0b6 100644 --- a/Service/Sources/Base/BitgouelAPI.swift +++ b/Service/Sources/Base/BitgouelAPI.swift @@ -44,6 +44,7 @@ public enum BitgouelDomain: String { case school case company case university + case government } extension BitgouelDomain { diff --git a/Service/Sources/Domain/GovernmentDomain/API/GovernmentAPI.swift b/Service/Sources/Domain/GovernmentDomain/API/GovernmentAPI.swift index 1f566194..32506f06 100644 --- a/Service/Sources/Domain/GovernmentDomain/API/GovernmentAPI.swift +++ b/Service/Sources/Domain/GovernmentDomain/API/GovernmentAPI.swift @@ -1,8 +1,74 @@ -// -// GovernmentAPI.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation +import Moya + +public enum GovernmentAPI { + case fetchGovernmentList + case createdGovernment(req: CreatedGovernmentRequestDTO) + case deleteGovernment(governmentID: Int) +} + +extension GovernmentAPI: BitgouelAPI { + public typealias ErrorType = GovernmentDomainError + + public var domain: BitgouelDomain { + .government + } + + public var urlPath: String { + switch self { + case .fetchGovernmentList, + .createdGovernment: + return "" + + case let .deleteGovernment(governmentID): + return "/\(governmentID)" + } + } + + public var method: Moya.Method { + switch self { + case .fetchGovernmentList: + return .get + + case .createdGovernment: + return .post + + case .deleteGovernment: + return .delete + } + } + + public var task: Moya.Task { + switch self { + case .fetchGovernmentList, + .deleteGovernment: + return .requestPlain + + case let .createdGovernment(req): + return .requestJSONEncodable(req) + } + } + + public var jwtTokenType: JwtTokenType { + switch self { + case .fetchGovernmentList: + return .none + + case .createdGovernment, + .deleteGovernment: + return .accessToken + } + } + + public var errorMap: [Int: GovernmentDomainError] { + switch self { + case .fetchGovernmentList, + .createdGovernment, + .deleteGovernment: + return [ + 404: .notFound, + 409: .conflict + ] + } + } +} From ddb3493fb3c527e1cd90a504ff79d4c73a1ea465 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:45:22 +0900 Subject: [PATCH 04/11] :sparkles: :: [#372] GovernmentDomain / DataSource --- .../RemoteGovernmentDataSource.swift | 13 ++++++------ .../Error/GovernmentDomainError.swift | 21 ++++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Service/Sources/Domain/GovernmentDomain/DataSource/RemoteGovernmentDataSource.swift b/Service/Sources/Domain/GovernmentDomain/DataSource/RemoteGovernmentDataSource.swift index a90dc559..d9d5e38f 100644 --- a/Service/Sources/Domain/GovernmentDomain/DataSource/RemoteGovernmentDataSource.swift +++ b/Service/Sources/Domain/GovernmentDomain/DataSource/RemoteGovernmentDataSource.swift @@ -1,8 +1,7 @@ -// -// RemoteGovernmentDataSource.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public protocol RemoteGovernmentDataSource: BaseRemoteDataSource { + func fetchGovernmentList() async throws -> [GovernmentInfoEntity] + func createdGovernment(req: CreatedGovernmentRequestDTO) async throws + func deleteGovernment(governmentID: Int) async throws +} diff --git a/Service/Sources/Domain/GovernmentDomain/Error/GovernmentDomainError.swift b/Service/Sources/Domain/GovernmentDomain/Error/GovernmentDomainError.swift index 8b37fa37..3ceb88a5 100644 --- a/Service/Sources/Domain/GovernmentDomain/Error/GovernmentDomainError.swift +++ b/Service/Sources/Domain/GovernmentDomain/Error/GovernmentDomainError.swift @@ -1,8 +1,15 @@ -// -// GovernmentDomainError.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public enum GovernmentDomainError: Error { + case notFound + case conflict +} + +extension GovernmentDomainError: LocalizedError { + public var errorDescription: String? { + switch self { + case .notFound: return "존재하지 않는 유관기관입니다." + case .conflict: return "이미 존재하는 유관기관입니다." + } + } +} From 27086c8ff2d887c80b3e2948af279e937c1b7149 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:45:48 +0900 Subject: [PATCH 05/11] :sparkles: :: [#372] GovernmentDomain / Repository --- .../Repository/GovernmentRepository.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Service/Sources/Domain/GovernmentDomain/Repository/GovernmentRepository.swift b/Service/Sources/Domain/GovernmentDomain/Repository/GovernmentRepository.swift index 5a693706..c0557732 100644 --- a/Service/Sources/Domain/GovernmentDomain/Repository/GovernmentRepository.swift +++ b/Service/Sources/Domain/GovernmentDomain/Repository/GovernmentRepository.swift @@ -1,8 +1,7 @@ -// -// GovernmentRepository.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public protocol GovernmentRepository { + func fetchGovernmentList() async throws -> [GovernmentInfoEntity] + func createdGovernment(req: CreatedGovernmentRequestDTO) async throws + func deleteGovernment(governmentID: Int) async throws +} From 24b79f66a4d26950012a7e9f5dc28f983da9edd6 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:46:28 +0900 Subject: [PATCH 06/11] :sparkles: :: [#372] governmentDomain / UseCase --- .../UseCase/CreatedGovernmentUseCase.swift | 11 ++++------- .../UseCase/DeleteGovernmentUseCase.swift | 11 ++++------- .../UseCase/FetchGovernmentListUseCase.swift | 11 ++++------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Service/Sources/Domain/GovernmentDomain/UseCase/CreatedGovernmentUseCase.swift b/Service/Sources/Domain/GovernmentDomain/UseCase/CreatedGovernmentUseCase.swift index b1eb312d..dea75b92 100644 --- a/Service/Sources/Domain/GovernmentDomain/UseCase/CreatedGovernmentUseCase.swift +++ b/Service/Sources/Domain/GovernmentDomain/UseCase/CreatedGovernmentUseCase.swift @@ -1,8 +1,5 @@ -// -// CreatedGovernmentUseCase.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public protocol CreatedGovernmentUseCase { + func callAsFunction(req: CreatedGovernmentRequestDTO) async throws +} diff --git a/Service/Sources/Domain/GovernmentDomain/UseCase/DeleteGovernmentUseCase.swift b/Service/Sources/Domain/GovernmentDomain/UseCase/DeleteGovernmentUseCase.swift index 4bc9c335..a2c531cd 100644 --- a/Service/Sources/Domain/GovernmentDomain/UseCase/DeleteGovernmentUseCase.swift +++ b/Service/Sources/Domain/GovernmentDomain/UseCase/DeleteGovernmentUseCase.swift @@ -1,8 +1,5 @@ -// -// DeleteGovernmentUseCase.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public protocol DeleteGovernmentUseCase { + func callAsFunction(governmentID: Int) async throws +} diff --git a/Service/Sources/Domain/GovernmentDomain/UseCase/FetchGovernmentListUseCase.swift b/Service/Sources/Domain/GovernmentDomain/UseCase/FetchGovernmentListUseCase.swift index b3d10d21..f4a3dcd2 100644 --- a/Service/Sources/Domain/GovernmentDomain/UseCase/FetchGovernmentListUseCase.swift +++ b/Service/Sources/Domain/GovernmentDomain/UseCase/FetchGovernmentListUseCase.swift @@ -1,8 +1,5 @@ -// -// FetchGovernmentListUseCase.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public protocol FetchGovernmentListUseCase { + func callAsFunction() async throws -> [GovernmentInfoEntity] +} From 93d4fde2872bbfd8de341905bd94eed4eb7cb90c Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:46:53 +0900 Subject: [PATCH 07/11] :sparkles: :: [#372] governmentDomain / DataSourceImpl --- .../RemoteGovernmentDataSourceImpl.swift | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Service/Sources/Data/DataSource/Government/RemoteGovernmentDataSourceImpl.swift b/Service/Sources/Data/DataSource/Government/RemoteGovernmentDataSourceImpl.swift index 1b34a52b..6d0ebd32 100644 --- a/Service/Sources/Data/DataSource/Government/RemoteGovernmentDataSourceImpl.swift +++ b/Service/Sources/Data/DataSource/Government/RemoteGovernmentDataSourceImpl.swift @@ -1,8 +1,15 @@ -// -// RemoteGovernmentDataSourceImpl.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public final class RemoteGovernmentDataSourceImpl: BaseRemoteDataSource, RemoteGovernmentDataSource { + public func fetchGovernmentList() async throws -> [GovernmentInfoEntity] { + try await request(.fetchGovernmentList, dto: GovernmentListResponseDTO.self).toDomain() + } + + public func createdGovernment(req: CreatedGovernmentRequestDTO) async throws { + try await request(.createdGovernment(req: req)) + } + + public func deleteGovernment(governmentID: Int) async throws { + try await request(.deleteGovernment(governmentID: governmentID)) + } +} From f8532f28bafa335f9a5bb5daa04a912cf1c7fd20 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:47:20 +0900 Subject: [PATCH 08/11] :sparkles: :: [#372] governmentDomain / RepositoryImpl --- .../Government/GovernmentRepositoryImpl.swift | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Service/Sources/Data/Repository/Government/GovernmentRepositoryImpl.swift b/Service/Sources/Data/Repository/Government/GovernmentRepositoryImpl.swift index 9324a538..242a8d37 100644 --- a/Service/Sources/Data/Repository/Government/GovernmentRepositoryImpl.swift +++ b/Service/Sources/Data/Repository/Government/GovernmentRepositoryImpl.swift @@ -1,8 +1,21 @@ -// -// GovernmentRepositoryImpl.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public struct GovernmentRepositoryImpl: GovernmentRepository { + private let remoteGovernmentDataSource: any RemoteGovernmentDataSource + + public init(remoteGovernmentDataSource: any RemoteGovernmentDataSource) { + self.remoteGovernmentDataSource = remoteGovernmentDataSource + } + + public func fetchGovernmentList() async throws -> [GovernmentInfoEntity] { + try await remoteGovernmentDataSource.fetchGovernmentList() + } + + public func createdGovernment(req: CreatedGovernmentRequestDTO) async throws { + try await remoteGovernmentDataSource.createdGovernment(req: req) + } + + public func deleteGovernment(governmentID: Int) async throws { + try await remoteGovernmentDataSource.deleteGovernment(governmentID: governmentID) + } +} From 520483715eb69b0f9cc2e98145496a4c43b71ea9 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:47:44 +0900 Subject: [PATCH 09/11] :sparkles: :: [#372] governmentDomain / UseCaseImpl --- .../CreatedGovernmentUseCaseImpl.swift | 19 ++++++++++++------- .../DeleteGovernmentUseCaseImpl.swift | 19 ++++++++++++------- .../FetchGovernmentUseCaseImpl.swift | 19 ++++++++++++------- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Service/Sources/Data/UseCase/Government/CreatedGovernmentUseCaseImpl.swift b/Service/Sources/Data/UseCase/Government/CreatedGovernmentUseCaseImpl.swift index de0f84d3..e22b1058 100644 --- a/Service/Sources/Data/UseCase/Government/CreatedGovernmentUseCaseImpl.swift +++ b/Service/Sources/Data/UseCase/Government/CreatedGovernmentUseCaseImpl.swift @@ -1,8 +1,13 @@ -// -// CreatedGovernmentUseCaseImpl.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public struct CreatedGovernmentUseCaseImpl: CreatedGovernmentUseCase { + private let governmentRepository: any GovernmentRepository + + public init(governmentRepository: any GovernmentRepository) { + self.governmentRepository = governmentRepository + } + + public func callAsFunction(req: CreatedGovernmentRequestDTO) async throws { + try await governmentRepository.createdGovernment(req: req) + } +} diff --git a/Service/Sources/Data/UseCase/Government/DeleteGovernmentUseCaseImpl.swift b/Service/Sources/Data/UseCase/Government/DeleteGovernmentUseCaseImpl.swift index 156cd2ac..9a157548 100644 --- a/Service/Sources/Data/UseCase/Government/DeleteGovernmentUseCaseImpl.swift +++ b/Service/Sources/Data/UseCase/Government/DeleteGovernmentUseCaseImpl.swift @@ -1,8 +1,13 @@ -// -// DeleteGovernmentUseCaseImpl.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public struct DeleteGovernmentUseCaseImpl: DeleteGovernmentUseCase { + private let governmentRepository: any GovernmentRepository + + public init(governmentRepository: any GovernmentRepository) { + self.governmentRepository = governmentRepository + } + + public func callAsFunction(governmentID: Int) async throws { + try await governmentRepository.deleteGovernment(governmentID: governmentID) + } +} diff --git a/Service/Sources/Data/UseCase/Government/FetchGovernmentUseCaseImpl.swift b/Service/Sources/Data/UseCase/Government/FetchGovernmentUseCaseImpl.swift index a9fc1207..6f0a69fb 100644 --- a/Service/Sources/Data/UseCase/Government/FetchGovernmentUseCaseImpl.swift +++ b/Service/Sources/Data/UseCase/Government/FetchGovernmentUseCaseImpl.swift @@ -1,8 +1,13 @@ -// -// FetchGovernmentUseCaseImpl.swift -// Service -// -// Created by 정윤서 on 7/18/24. -// - import Foundation + +public struct FetchGovernmentUseCaseImpl: FetchGovernmentListUseCase { + private let governmentRepository: any GovernmentRepository + + public init(governmentRepository: any GovernmentRepository) { + self.governmentRepository = governmentRepository + } + + public func callAsFunction() async throws -> [GovernmentInfoEntity] { + try await governmentRepository.fetchGovernmentList() + } +} From 4b27fd095ce3497115f6f550f8bf61d358815000 Mon Sep 17 00:00:00 2001 From: uuuunseo Date: Fri, 19 Jul 2024 00:48:07 +0900 Subject: [PATCH 10/11] :sparkles: :: [#372] governmentDomain / AppComponent --- .../Government/AppComponent+Government.swift | 37 ++++++++++++++----- App/Sources/Application/NeedleGenerated.swift | 13 +++++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/App/Sources/Application/DI/Government/AppComponent+Government.swift b/App/Sources/Application/DI/Government/AppComponent+Government.swift index 0ced908a..094d288b 100644 --- a/App/Sources/Application/DI/Government/AppComponent+Government.swift +++ b/App/Sources/Application/DI/Government/AppComponent+Government.swift @@ -1,9 +1,28 @@ -// -// AppComponent+Government.swift -// Bitgouel -// -// Created by 정윤서 on 7/18/24. -// Copyright © 2024 team.msg. All rights reserved. -// - -import Foundation +import NeedleFoundation +import Service + +public extension AppComponent { + var remoteGovernmentDataSource: any RemoteGovernmentDataSource { + shared { + RemoteGovernmentDataSourceImpl(keychain: keychain) + } + } + + var governmentRepository: any GovernmentRepository { + shared { + GovernmentRepositoryImpl(remoteGovernmentDataSource: remoteGovernmentDataSource) + } + } + + var fetchGovernmentListUseCase: any FetchGovernmentListUseCase { + FetchGovernmentUseCaseImpl(governmentRepository: governmentRepository) + } + + var createdGovernmentUseCase: any CreatedGovernmentUseCase { + CreatedGovernmentUseCaseImpl(governmentRepository: governmentRepository) + } + + var deleteGovernmentUseCase: any DeleteGovernmentUseCase { + DeleteGovernmentUseCaseImpl(governmentRepository: governmentRepository) + } +} diff --git a/App/Sources/Application/NeedleGenerated.swift b/App/Sources/Application/NeedleGenerated.swift index a5a294f8..993a8c33 100644 --- a/App/Sources/Application/NeedleGenerated.swift +++ b/App/Sources/Application/NeedleGenerated.swift @@ -1269,6 +1269,11 @@ extension AppComponent: Registration { localTable["fetchClubDetailUseCase-any FetchClubDetailUseCase"] = { [unowned self] in self.fetchClubDetailUseCase as Any } localTable["fetchStudentListByClubUseCase-any FetchStudentListByClubUseCase"] = { [unowned self] in self.fetchStudentListByClubUseCase as Any } localTable["fetchStudentDetailByClubUseCase-any FetchStudentDetailByClubUseCase"] = { [unowned self] in self.fetchStudentDetailByClubUseCase as Any } + localTable["remoteGovernmentDataSource-any RemoteGovernmentDataSource"] = { [unowned self] in self.remoteGovernmentDataSource as Any } + localTable["governmentRepository-any GovernmentRepository"] = { [unowned self] in self.governmentRepository as Any } + localTable["fetchGovernmentListUseCase-any FetchGovernmentListUseCase"] = { [unowned self] in self.fetchGovernmentListUseCase as Any } + localTable["createdGovernmentUseCase-any CreatedGovernmentUseCase"] = { [unowned self] in self.createdGovernmentUseCase as Any } + localTable["deleteGovernmentUseCase-any DeleteGovernmentUseCase"] = { [unowned self] in self.deleteGovernmentUseCase as Any } localTable["remotePostDataSource-any RemotePostDataSource"] = { [unowned self] in self.remotePostDataSource as Any } localTable["postRepository-any PostRepository"] = { [unowned self] in self.postRepository as Any } localTable["writePostUseCase-any WritePostUseCase"] = { [unowned self] in self.writePostUseCase as Any } @@ -1322,6 +1327,14 @@ extension AppComponent: Registration { localTable["userRepository-any UserRepository"] = { [unowned self] in self.userRepository as Any } localTable["changePasswordUseCase-any ChangePasswordUseCase"] = { [unowned self] in self.changePasswordUseCase as Any } localTable["fetchMyInfoUseCase-any FetchMyInfoUseCase"] = { [unowned self] in self.fetchMyInfoUseCase as Any } + localTable["remoteUniversityDataSource-any RemoteUniversityDataSource"] = { [unowned self] in self.remoteUniversityDataSource as Any } + localTable["universityRepository-any UniversityRepository"] = { [unowned self] in self.universityRepository as Any } + localTable["fetchUniversityListUseCase-any FetchUniversityListUseCase"] = { [unowned self] in self.fetchUniversityListUseCase as Any } + localTable["createdUniversityUseCase-any CreatedUniversityUseCase"] = { [unowned self] in self.createdUniversityUseCase as Any } + localTable["modifyUniversityUseCase-any ModifyUniversityUseCase"] = { [unowned self] in self.modifyUniversityUseCase as Any } + localTable["deleteUniversityUseCase-any DeleteUniversityUseCase"] = { [unowned self] in self.deleteUniversityUseCase as Any } + localTable["createdDepartmentUseCase-any CreatedDepartmentUseCase"] = { [unowned self] in self.createdDepartmentUseCase as Any } + localTable["deleteDepartmentUseCase-any DeleteDepartmentUseCase"] = { [unowned self] in self.deleteDepartmentUseCase as Any } localTable["loginFactory-any LoginFactory"] = { [unowned self] in self.loginFactory as Any } localTable["activityListFactory-any ActivityListFactory"] = { [unowned self] in self.activityListFactory as Any } localTable["signupFactory-any SignUpFactory"] = { [unowned self] in self.signupFactory as Any } From d81d473daf803db07b21ab8a290b1e9be717a70b Mon Sep 17 00:00:00 2001 From: uuuunseo <105629604+uuuunseo@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:13:06 +0900 Subject: [PATCH 11/11] Update bitgouel-ios-ci.yml --- .github/workflows/bitgouel-ios-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bitgouel-ios-ci.yml b/.github/workflows/bitgouel-ios-ci.yml index ccb7edeb..2799f1ac 100644 --- a/.github/workflows/bitgouel-ios-ci.yml +++ b/.github/workflows/bitgouel-ios-ci.yml @@ -16,7 +16,7 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install tuist run: curl -Ls https://install.tuist.io | bash