generated from GSM-MSG/MSG-Repository-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from School-of-Company/368-company-domain-set…
…ting 🔀 :: [#368] Company 도메인 세팅
- Loading branch information
Showing
21 changed files
with
402 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
excluded: | ||
- fastlane | ||
- Dependencies | ||
- Carthage | ||
|
||
disabled_rules: | ||
- void_function_in_ternary | ||
|
||
identifier_name: | ||
min_length: 1 | ||
max_length: 60 | ||
allowed_symbols: [_] | ||
|
||
large_tuple: | ||
warning: 3 | ||
error: 4 | ||
|
||
line_length: | ||
warning: 120 | ||
error: 120 | ||
ignores_urls: true | ||
ignores_comments: true | ||
|
||
type_name: | ||
min_length: 2 | ||
max_length: 60 | ||
allowed_symbols: [_] | ||
|
28 changes: 28 additions & 0 deletions
28
App/Sources/Application/DI/Company/AppComponent+Company.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import NeedleFoundation | ||
import Service | ||
|
||
public extension AppComponent { | ||
var remoteCompanyDataSource: any RemoteCompanyDataSource { | ||
shared { | ||
RemoteCompanyDataSourceImpl(keychain: keychain) | ||
} | ||
} | ||
|
||
var companyRepository: any CompanyRepository { | ||
shared { | ||
CompanyRepositoryImpl(remoteCompanyDataSource: remoteCompanyDataSource) | ||
} | ||
} | ||
|
||
var fetchCompanyListUseCase: any FetchCompanyListUseCase { | ||
FetchCompanyListUseCaseImpl(companyRepository: companyRepository) | ||
} | ||
|
||
var createdCompanyUseCase: any CreatedCompanyUseCase { | ||
CreatedCompanyUseCaseImpl(companyRepository: companyRepository) | ||
} | ||
|
||
var deleteCompanyUseCase: any DeleteCompanyUseCase { | ||
DeleteCompanyUseCaseImpl(companyRepository: companyRepository) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
--exclude fastlane,Dependencies,Carthage | ||
--swiftversion 5.8 | ||
|
||
# options | ||
--maxwidth 120 | ||
--indent 4 # indent | ||
--ifdef no-indent # indent | ||
--trimwhitespace always # trailingSpace | ||
--lineaftermarks false # fileHeader | ||
--wraparguments before-first # wrapArguments | ||
--wrapparameters before-first # wrapArguments | ||
--wrapcollections before-first # wrapArguments | ||
--someAny disabled # opaqueGenericParameters | ||
|
||
# rules | ||
--rules anyObjectProtocol | ||
--rules blankLineAfterImports | ||
--rules blankLinesAroundMark | ||
--rules blankLinesAtEndOfScope | ||
--rules blankLinesAtStartOfScope | ||
--rules blankLinesBetweenImports | ||
--rules blankLinesBetweenScopes | ||
--rules braces | ||
--rules consecutiveBlankLines | ||
--rules consecutiveSpaces | ||
--rules docComments | ||
--rules duplicateImports | ||
--rules elseOnSameLine | ||
--rules emptyBraces | ||
--rules enumNamespaces | ||
--rules extensionAccessControl | ||
--rules fileHeader | ||
--rules hoistAwait | ||
--rules hoistPatternLet | ||
--rules hoistTry | ||
--rules initCoderUnavailable | ||
--rules indent | ||
--rules isEmpty | ||
--rules leadingDelimiters | ||
--rules linebreakAtEndOfFile | ||
--rules modifierOrder | ||
--rules numberFormatting | ||
--rules opaqueGenericParameters | ||
--rules preferKeyPath | ||
--rules redundantExtensionACL | ||
--rules redundantOptionalBinding | ||
--rules redundantParens | ||
--rules redundantVoidReturnType | ||
--rules semicolons | ||
--rules sortedImports | ||
--rules spaceAroundBraces | ||
--rules spaceAroundBrackets | ||
--rules spaceAroundComments | ||
--rules spaceAroundGenerics | ||
--rules spaceInsideBraces | ||
--rules spaceInsideBrackets | ||
--rules spaceInsideComments | ||
--rules spaceInsideGenerics | ||
--rules spaceInsideParens | ||
--rules todos | ||
--rules trailingClosures | ||
--rules trailingSpace | ||
--rules typeSugar | ||
--rules void | ||
--rules wrap | ||
--rules wrapArguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
excluded: | ||
- fastlane | ||
- Dependencies | ||
|
||
disabled_rules: | ||
- void_function_in_ternary | ||
|
||
identifier_name: | ||
min_length: 1 | ||
max_length: 60 | ||
allowed_symbols: [_] | ||
|
||
large_tuple: | ||
warning: 3 | ||
error: 4 | ||
|
||
line_length: | ||
warning: 120 | ||
error: 120 | ||
ignores_urls: true | ||
ignores_comments: true | ||
|
||
type_name: | ||
min_length: 2 | ||
max_length: 60 | ||
allowed_symbols: [_] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Service/Sources/Data/DataSource/Company/RemoteCompanyDataSourceImpl.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Foundation | ||
|
||
public final class RemoteCompanyDataSourceImpl: BaseRemoteDataSource<CompanyAPI>, RemoteCompanyDataSource { | ||
public func fetchCompanyList() async throws -> [CompanyInfoEntity] { | ||
try await request(.fetchCompanyList, dto: CompanyListResponseDTO.self).toDomain() | ||
} | ||
|
||
public func createdCompany(req: CreatedCompanyRequestDTO) async throws { | ||
try await request(.createdCompany(req: req)) | ||
} | ||
|
||
public func deleteCompany(companyID: String) async throws { | ||
try await request(.deleteCompany(companyID: companyID)) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Service/Sources/Data/Repository/Company/CompanyRepositoryImpl.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Foundation | ||
|
||
public struct CompanyRepositoryImpl: CompanyRepository { | ||
private let remoteCompanyDataSource: any RemoteCompanyDataSource | ||
|
||
public init(remoteCompanyDataSource: any RemoteCompanyDataSource) { | ||
self.remoteCompanyDataSource = remoteCompanyDataSource | ||
} | ||
|
||
public func fetchCompanyList() async throws -> [CompanyInfoEntity] { | ||
try await remoteCompanyDataSource.fetchCompanyList() | ||
} | ||
|
||
public func createdCompany(req: CreatedCompanyRequestDTO) async throws { | ||
try await remoteCompanyDataSource.createdCompany(req: req) | ||
} | ||
|
||
public func deleteCompany(companyID: String) async throws { | ||
try await remoteCompanyDataSource.deleteCompany(companyID: companyID) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Service/Sources/Data/UseCase/Company/CreatedCompanyUseCaseImpl.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
public struct CreatedCompanyUseCaseImpl: CreatedCompanyUseCase { | ||
private let companyRepository: any CompanyRepository | ||
|
||
public init(companyRepository: any CompanyRepository) { | ||
self.companyRepository = companyRepository | ||
} | ||
|
||
public func callAsFunction(req: CreatedCompanyRequestDTO) async throws { | ||
try await companyRepository.createdCompany(req: req) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Service/Sources/Data/UseCase/Company/DeleteCompanyUseCaseImpl.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
public struct DeleteCompanyUseCaseImpl: DeleteCompanyUseCase { | ||
private let companyRepository: any CompanyRepository | ||
|
||
public init(companyRepository: any CompanyRepository) { | ||
self.companyRepository = companyRepository | ||
} | ||
|
||
public func callAsFunction(companyID: String) async throws { | ||
try await companyRepository.deleteCompany(companyID: companyID) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Service/Sources/Data/UseCase/Company/FetchCompanyListUseCaseImpl.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
public struct FetchCompanyListUseCaseImpl: FetchCompanyListUseCase { | ||
private let companyRepository: any CompanyRepository | ||
|
||
public init(companyRepository: any CompanyRepository) { | ||
self.companyRepository = companyRepository | ||
} | ||
|
||
public func callAsFunction() async throws -> [CompanyInfoEntity] { | ||
try await companyRepository.fetchCompanyList() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import Foundation | ||
import Moya | ||
|
||
public enum CompanyAPI { | ||
case fetchCompanyList | ||
case createdCompany(req: CreatedCompanyRequestDTO) | ||
case deleteCompany(companyID: String) | ||
} | ||
|
||
extension CompanyAPI: BitgouelAPI { | ||
public typealias ErrorType = CompanyDomainError | ||
|
||
public var domain: BitgouelDomain { | ||
.company | ||
} | ||
|
||
public var urlPath: String { | ||
switch self { | ||
case .fetchCompanyList, | ||
.createdCompany: | ||
return "" | ||
|
||
case let .deleteCompany(companyID): | ||
return "/\(companyID)" | ||
} | ||
} | ||
|
||
public var method: Moya.Method { | ||
switch self { | ||
case .fetchCompanyList: | ||
return .get | ||
|
||
case .createdCompany: | ||
return .post | ||
|
||
case .deleteCompany: | ||
return .delete | ||
} | ||
} | ||
|
||
public var task: Moya.Task { | ||
switch self { | ||
case .fetchCompanyList, | ||
.deleteCompany: | ||
return .requestPlain | ||
|
||
case let .createdCompany(req): | ||
return .requestJSONEncodable(req) | ||
} | ||
} | ||
|
||
public var jwtTokenType: JwtTokenType { | ||
switch self { | ||
case .fetchCompanyList: | ||
return .none | ||
|
||
case .createdCompany, | ||
.deleteCompany: | ||
return .accessToken | ||
} | ||
} | ||
|
||
public var errorMap: [Int: CompanyDomainError] { | ||
switch self { | ||
case .fetchCompanyList, | ||
.createdCompany, | ||
.deleteCompany: | ||
return [ | ||
404: .notFound, | ||
409: .conflict | ||
] | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Service/Sources/Domain/CompanyDomain/DTO/Request/CreatedCompanyRequestDTO.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
|
||
public struct CreatedCompanyRequestDTO: Encodable { | ||
public let companyName: String | ||
public let field: FieldType | ||
} |
33 changes: 33 additions & 0 deletions
33
Service/Sources/Domain/CompanyDomain/DTO/Response/CompanyListResponseDTO.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Foundation | ||
|
||
public struct CompanyListResponseDTO: Decodable { | ||
public let companies: [CompanyInfoResponseDTO] | ||
} | ||
|
||
public struct CompanyInfoResponseDTO: Decodable { | ||
public let companyID: String | ||
public let companyName: String | ||
public let field: FieldType | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case companyID = "id" | ||
case companyName | ||
case field | ||
} | ||
} | ||
|
||
extension CompanyListResponseDTO { | ||
func toDomain() -> [CompanyInfoEntity] { | ||
companies.map { $0.toDomain() } | ||
} | ||
} | ||
|
||
extension CompanyInfoResponseDTO { | ||
func toDomain() -> CompanyInfoEntity { | ||
CompanyInfoEntity( | ||
companyID: companyID, | ||
companyName: companyName, | ||
field: field | ||
) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Service/Sources/Domain/CompanyDomain/DataSource/RemoteCompanyDataSource.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Foundation | ||
|
||
public protocol RemoteCompanyDataSource: BaseRemoteDataSource<CompanyAPI> { | ||
func fetchCompanyList() async throws -> [CompanyInfoEntity] | ||
func createdCompany(req: CreatedCompanyRequestDTO) async throws | ||
func deleteCompany(companyID: String) async throws | ||
} |
7 changes: 7 additions & 0 deletions
7
Service/Sources/Domain/CompanyDomain/Entity/CompanyInfoEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Foundation | ||
|
||
public struct CompanyInfoEntity: Equatable { | ||
public let companyID: String | ||
public let companyName: String | ||
public let field: FieldType | ||
} |
Oops, something went wrong.