-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Book, Page 등 Entity, Storage, Repository, FileManager 생성 #82
Changes from 44 commits
324496a
2d77243
0095076
ec3fcc9
0da53c1
cad4f14
4404356
1c0745d
08781ec
26d3b48
d680ab2
464ffc4
fbc49b2
4b1329c
2ee6924
ead3b39
1204d36
41fa8dc
73e45c7
5c7b869
4f6bc8c
d4a6e59
291f971
0109995
10f59e4
768f42f
56e89d3
d9f5a6a
0518b74
e251e11
64c4887
c7a74bd
67e5b4f
7e6a62e
551dd18
ab06643
02d6543
731c81d
b8abbc9
c23d906
88e0341
5a4f073
42332f7
3ee147b
d466ea7
07ea62f
1ab46a8
3f198e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import MHFoundation | ||
|
||
public enum MHCoreError: Error, CustomStringConvertible, Equatable { | ||
case DIContainerResolveFailure(key: String) | ||
|
||
public var description: String { | ||
switch self { | ||
case .DIContainerResolveFailure(let key): | ||
"\(key)에 대한 dependency resolve 실패" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import MHFoundation | ||
|
||
public enum MHDataError: Error, CustomStringConvertible, Equatable { | ||
case noSuchEntity(key: String) | ||
case createEntityFailure | ||
case convertDTOFailure | ||
case fetchEntityFaliure | ||
case updateEntityFailure | ||
case deleteEntityFailure | ||
case findEntityFailure | ||
case saveContextFailure | ||
case directorySettingFailure | ||
case fileCreationFailure | ||
case fileReadingFailure | ||
case fileDeletionFailure | ||
case fileMovingFailure | ||
case fileNotExists | ||
|
||
public var description: String { | ||
switch self { | ||
case let .noSuchEntity(key): | ||
"\(key)에 대한 Entity가 존재하지 않습니다" | ||
case .createEntityFailure: | ||
"Entity 생성 실패" | ||
case .convertDTOFailure: | ||
"Entity에 대한 DTO 변환 실패" | ||
case .fetchEntityFaliure: | ||
"Entity 가져오기 실패" | ||
case .updateEntityFailure: | ||
"Entity 업데이트 실패" | ||
case .deleteEntityFailure: | ||
"Entity 삭제 실패" | ||
case .findEntityFailure: | ||
"Entity 찾기 실패" | ||
case .saveContextFailure: | ||
"Update된 Context 저장 실패" | ||
case .directorySettingFailure: | ||
"디렉토리 설정 실패" | ||
case .fileCreationFailure: | ||
"파일 생성 실패" | ||
case .fileReadingFailure: | ||
"파일 읽기 실패" | ||
case .fileDeletionFailure: | ||
"파일 삭제 실패" | ||
case .fileMovingFailure: | ||
"파일 이동 실패" | ||
case .fileNotExists: | ||
"파일이 존재하지 않습니다" | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import MHFoundation | ||
import MHDomain | ||
|
||
public struct BookDTO { | ||
let id: UUID | ||
let pages: [PageDTO] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. public init 없이 잘 동작하나요 ?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Internal하게 사용돼서 아직 오류가 안나온 것같습니다! 혹시 모르니 넣어 놓을께욤! |
||
public init(id: UUID, pages: [PageDTO]) { | ||
self.id = id | ||
self.pages = pages | ||
} | ||
|
||
func toBook() -> Book { | ||
return Book( | ||
id: self.id, | ||
pages: self.pages.map { $0.toPage() } | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import MHFoundation | ||
import MHDomain | ||
|
||
public struct MediaDescriptionDTO { | ||
let id: UUID | ||
let type: String | ||
let attributes: Data? | ||
|
||
public init(id: UUID, type: String, attributes: Data?) { | ||
self.id = id | ||
self.type = type | ||
self.attributes = attributes | ||
} | ||
|
||
func toMediaDescription() -> MediaDescription? { | ||
guard let type = MediaType(rawValue: self.type) else { return nil } | ||
let attributes = try? JSONSerialization.jsonObject(with: attributes ?? Data(), options: []) as? [String: any Sendable] | ||
Check warning on line 17 in MemorialHouse/MHData/MHData/DTO/MediaDescriptionDTO.swift
|
||
|
||
return MediaDescription( | ||
id: self.id, | ||
type: type, | ||
attributes: attributes | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import MHFoundation | ||
import MHDomain | ||
|
||
public struct PageDTO { | ||
let id: UUID | ||
let metadata: [Int: MediaDescriptionDTO] | ||
let text: String | ||
|
||
public init(id: UUID, metadata: [Int: MediaDescriptionDTO], text: String) { | ||
self.id = id | ||
self.metadata = metadata | ||
self.text = text | ||
} | ||
|
||
func toPage() -> Page { | ||
let metadata = self.metadata | ||
.compactMapValues { $0.toMediaDescription() } | ||
|
||
return Page( | ||
id: self.id, | ||
metadata: metadata, | ||
text: self.text | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import MHFoundation | ||
import MHCore | ||
|
||
public protocol BookStorage { | ||
func create(data: BookDTO) async -> Result<Void, MHDataError> | ||
func fetch(with id: UUID) async -> Result<BookDTO, MHDataError> | ||
func update(with id: UUID, data: BookDTO) async -> Result<Void, MHDataError> | ||
func delete(with id: UUID) async -> Result<Void, MHDataError> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: 해당 에러는 DataLayer에서만 사용되는 Error인 것 같은데, 그냥 DataLayer에 두고 사용하면 되지 않나요?? 혹시 Core 모듈에 두신 이유가 있으신가욤??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그게... 사실 DataLayer에 두고 싶었습니다...
그렇게 하니까 Domain이 DataLayer에 의존해야하더라구요...
그래서 어떻게 하지... 하다가 그냥 파일로만 나누자... 했습니다 ㅠㅠ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하...그런 문제가.... 맞네용.. 정현님의 판단이 1928478번 정확한 판단인 것 같습니다