-
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 #95 from Team-MindWay/94-notice-domain-setting
🔀 :: [#94] NoticeDomain Setting
- Loading branch information
Showing
16 changed files
with
170 additions
and
14 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
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
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
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,51 @@ | ||
import Foundation | ||
import Moya | ||
|
||
public enum NoticeAPI { | ||
case fetchNotice | ||
} | ||
|
||
extension NoticeAPI: MindWayAPI { | ||
public typealias ErrorType = NoticeDomainError | ||
|
||
public var domain: MindWayDomain { | ||
.notice | ||
} | ||
|
||
public var urlPath: String { | ||
switch self { | ||
case .fetchNotice: | ||
return "" | ||
} | ||
} | ||
|
||
public var method: Moya.Method { | ||
switch self { | ||
case .fetchNotice: | ||
return .get | ||
} | ||
} | ||
|
||
public var task: Moya.Task { | ||
switch self { | ||
case .fetchNotice: | ||
return .requestPlain | ||
} | ||
} | ||
|
||
public var jwtTokenType: JwtTokenType { | ||
switch self { | ||
case .fetchNotice: | ||
return .accessToken | ||
} | ||
} | ||
|
||
public var errorMap: [Int: ErrorType] { | ||
switch self { | ||
case .fetchNotice: | ||
return [ | ||
401: .unauthorized | ||
] | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Service/Sources/Domain/NoticeDomain/DTO/Response/FetchNoticeResponseDTO.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,23 @@ | ||
import Foundation | ||
|
||
public struct FetchNoticeResponseDTO: Decodable { | ||
public let title: String | ||
public let content: String | ||
|
||
init( | ||
title: String, | ||
content: String | ||
) { | ||
self.title = title | ||
self.content = content | ||
} | ||
} | ||
|
||
extension FetchNoticeResponseDTO { | ||
func toDomain() -> FetchNoticeEntity { | ||
FetchNoticeEntity( | ||
title: title, | ||
content: content | ||
) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
Service/Sources/Domain/NoticeDomain/DataSource/RemoteNoticeDataSourceImpl.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,8 @@ | ||
import Foundation | ||
|
||
public final class RemoteNoticeDataSourceImpl: BaseRemoteDataSource<NoticeAPI>, RemoteNoticeDataSource { | ||
public func fetchNotice() async throws -> FetchNoticeEntity { | ||
try await request(.fetchNotice, dto: FetchNoticeResponseDTO.self) | ||
.toDomain() | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Service/Sources/Domain/NoticeDomain/Entity/FetchNoticeEntity.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,14 @@ | ||
import Foundation | ||
|
||
public struct FetchNoticeEntity { | ||
private let title: String | ||
private let content: String | ||
|
||
init( | ||
title: String, | ||
content: String | ||
) { | ||
self.title = title | ||
self.content = content | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Service/Sources/Domain/NoticeDomain/Error/NoticeDomainError.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,14 @@ | ||
import Foundation | ||
|
||
public enum NoticeDomainError: Error { | ||
case unauthorized | ||
} | ||
|
||
extension NoticeDomainError: LocalizedError { | ||
public var errorDescription: String? { | ||
switch self { | ||
case .unauthorized: | ||
return "AccessToken이 블랙리스트에 있습니다." | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Service/Sources/Domain/NoticeDomain/Repository/NoticeRepositoryImpl.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 struct NoticeRepositoryImpl: NoticeRepository { | ||
private let remoteNoticeDataSource: any RemoteNoticeDataSource | ||
|
||
public init( | ||
remoteNoticeDataSource: any RemoteNoticeDataSource | ||
) { | ||
self.remoteNoticeDataSource = remoteNoticeDataSource | ||
} | ||
|
||
public func fetchNotice() async throws -> FetchNoticeEntity { | ||
try await remoteNoticeDataSource.fetchNotice() | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Service/Sources/Domain/NoticeDomain/UseCase/FetchNoticeUseCaseImpl.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 struct FetchNoticeUseCaseImpl: FetchNoticeUseCase { | ||
private let noticeRepository: any NoticeRepository | ||
|
||
public init( | ||
noticeRepository: any NoticeRepository | ||
) { | ||
self.noticeRepository = noticeRepository | ||
} | ||
|
||
public func execute() async throws -> FetchNoticeEntity { | ||
try await noticeRepository.fetchNotice() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Service/Sources/Interface/DataSource/Notice/RemoteNoticeDataSource.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,5 @@ | ||
import Foundation | ||
|
||
public protocol RemoteNoticeDataSource { | ||
func fetchNotice() async throws -> FetchNoticeEntity | ||
} |
5 changes: 5 additions & 0 deletions
5
Service/Sources/Interface/Repository/Notice/NoticeRepository.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,5 @@ | ||
import Foundation | ||
|
||
public protocol NoticeRepository { | ||
func fetchNotice() async throws -> FetchNoticeEntity | ||
} |
5 changes: 5 additions & 0 deletions
5
Service/Sources/Interface/UseCase/Notice/FetchNoticeUseCase.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,5 @@ | ||
import Foundation | ||
|
||
public protocol FetchNoticeUseCase { | ||
func execute() async throws -> FetchNoticeEntity | ||
} |