-
Notifications
You must be signed in to change notification settings - Fork 0
Setting/#101 코어데이터를 통한 저장소 구현 #104
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
Open
dev-domo
wants to merge
26
commits into
dev
Choose a base branch
from
setting/#101-coredata
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
dc1a4db
refactor: #101 기존 레포지토리 임시 폴더링 수정
dev-domo 64faf0e
feat: #101 데이터베이스 스키마 설정
dev-domo 6e63073
refactor: #101 소셜 로그인, 로그아웃 기능 삭제
dev-domo 409bbdb
refactor: #101 프레임워크명 명시
dev-domo a0ed942
feat: #101 CoreData 사용 설정
dev-domo 2dbe90a
feat: #101 Member API를 CoreData로 대체
dev-domo edb4d34
test: #101 Member 관련 유스케이스 테스트 작성
dev-domo 62f6a1c
test: #101 TermsStorage 기능 테스트
dev-domo 9a551d4
refactor: #101 테스트 환경에서 앱과 동일한 모델 인스턴스를 재사용하도록 수정
dev-domo 152d4e9
feat: MemberStorage 구현 및 테스트
dev-domo 7110af7
refactor: #101 생성자 내 객체 생성 코드 수정
dev-domo 6a98f52
refactor: #101 구조체 네이밍 수정
dev-domo 19b5db2
chore: #101 테스트 메서드명 수정
dev-domo 07b6237
refactor: #101 NotificationsEntity 속성명 수정
dev-domo 8b0166d
refactor: #101 엔티티 id를 Int64형으로 수정
dev-domo b9fa9ef
refactor: #101 파라미터명 수정사항 반영
dev-domo d80de5b
test: #101 시나리오 엔티티 관련 테스트 작성
dev-domo e3f4566
test: #101 미션 관련 유스케이스 테스트 작성
dev-domo 16884eb
feat: #101 Mission 저장소 구현
dev-domo 8cb633a
feat: #101 Scenario 저장소 구현
dev-domo a984b66
feat: #101 Terms 저장소 구현
dev-domo 0ae9d36
chore: #101 불필요한 열거형 제거
dev-domo f5d3ab0
feat: #101 엔티티 id 배정 유틸리티 구현
dev-domo 737a360
refactor: #101 toRawvalues 메서드 구현
dev-domo bb4346f
refactor: #101 저장소 구현에 필요한 에러 케이스 정의
dev-domo 0e8ec30
refactor: #101 DefaultValue 재설정
dev-domo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,64 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
| <model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23605" systemVersion="24D60" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> | ||
| <entity name="Member" representedClassName="Member" syncable="YES" codeGenerationType="class"> | ||
| <attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <attribute name="id" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="nickname" attributeType="String"/> | ||
| <attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <relationship name="scenarios" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Scenario" inverseName="member" inverseEntity="Scenario"/> | ||
| <relationship name="term" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Terms" inverseName="member" inverseEntity="Terms"/> | ||
| </entity> | ||
| <entity name="Mission" representedClassName="Mission" syncable="YES" codeGenerationType="class"> | ||
| <attribute name="content" attributeType="String"/> | ||
| <attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <attribute name="id" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="isChecked" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/> | ||
| <attribute name="missionOrder" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="missionType" attributeType="String"/> | ||
| <attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <attribute name="useDate" optional="YES" attributeType="Date" usesScalarValueType="NO"/> | ||
| <relationship name="children" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Mission" inverseName="parent" inverseEntity="Mission"/> | ||
| <relationship name="parent" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Mission" inverseName="children" inverseEntity="Mission"/> | ||
| <relationship name="scenario" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Scenario" inverseName="missions" inverseEntity="Scenario"/> | ||
| </entity> | ||
| <entity name="Notification" representedClassName="Notification" syncable="YES" codeGenerationType="class"> | ||
| <attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <attribute name="daysOfWeek" optional="YES" attributeType="String"/> | ||
| <attribute name="id" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="isActive" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/> | ||
| <attribute name="notificationMethodType" optional="YES" attributeType="String"/> | ||
| <attribute name="notificationType" attributeType="String"/> | ||
| <attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <relationship name="scenario" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Scenario" inverseName="notification" inverseEntity="Scenario"/> | ||
| <relationship name="timeNotifications" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="TimeNotification" inverseName="notification" inverseEntity="TimeNotification"/> | ||
| </entity> | ||
| <entity name="Scenario" representedClassName="Scenario" syncable="YES" codeGenerationType="class"> | ||
| <attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <attribute name="id" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="memo" optional="YES" attributeType="String"/> | ||
| <attribute name="scenarioName" attributeType="String"/> | ||
| <attribute name="scenarioOrder" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <relationship name="member" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Member" inverseName="scenarios" inverseEntity="Member"/> | ||
| <relationship name="missions" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mission" inverseName="scenario" inverseEntity="Mission"/> | ||
| <relationship name="notification" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Notification" inverseName="scenario" inverseEntity="Notification"/> | ||
| </entity> | ||
| <entity name="Terms" representedClassName="Terms" syncable="YES" codeGenerationType="class"> | ||
| <attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <attribute name="eventPushAgreed" attributeType="Boolean" usesScalarValueType="YES"/> | ||
| <attribute name="id" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="isOverFourteen" attributeType="Boolean" usesScalarValueType="YES"/> | ||
| <attribute name="privacyPolicyAgreed" attributeType="Boolean" usesScalarValueType="YES"/> | ||
| <attribute name="termsOfServiceAgreed" attributeType="Boolean" usesScalarValueType="YES"/> | ||
| <attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <relationship name="member" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Member" inverseName="term" inverseEntity="Member"/> | ||
| </entity> | ||
| <entity name="TimeNotification" representedClassName="TimeNotification" syncable="YES" codeGenerationType="class"> | ||
| <attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <attribute name="id" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="startHour" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="startMinute" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> | ||
| <attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/> | ||
| <relationship name="notification" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Notification" inverseName="timeNotifications" inverseEntity="Notification"/> | ||
| </entity> | ||
| </model> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| // | ||
| // CoreDataStack.swift | ||
| // BeforeGoing | ||
| // | ||
| // Created by APPLE on 2/3/26. | ||
| // | ||
|
|
||
| import CoreData | ||
|
|
||
| final class CoreDataStack { | ||
|
|
||
| static let shared = CoreDataStack() | ||
| private init() {} | ||
|
|
||
| // 모델을 static으로 분리해서 외부에서 접근 가능하게 | ||
| static let managedObjectModel: NSManagedObjectModel = { | ||
| let modelName = "BeforeGoingModel" | ||
| let uniqueBundles: [Bundle] = Bundle.allBundles | ||
| .compactMap { bundle -> (Bundle, URL)? in | ||
| guard let url = bundle.url(forResource: modelName, withExtension: "mom") else { | ||
| return nil | ||
| } | ||
| return (bundle, url) | ||
| } | ||
| .reduce(into: [(Bundle, URL)]()) { result, pair in | ||
| if !result.contains(where: { $0.1.path == pair.1.path }) { | ||
| result.append(pair) | ||
| } | ||
| } | ||
| .map { $0.0 } | ||
|
|
||
| guard let model = NSManagedObjectModel.mergedModel(from: uniqueBundles) else { | ||
| fatalError("NSManagedObjectModel을 로드할 수 없습니다.") | ||
| } | ||
| return model | ||
| }() | ||
|
|
||
| // 기존 container도 동일한 모델 인스턴스 사용 | ||
| private let container: NSPersistentContainer = { | ||
| let container = NSPersistentContainer( | ||
| name: "BeforeGoingModel", | ||
| managedObjectModel: CoreDataStack.managedObjectModel | ||
| ) | ||
| container.loadPersistentStores { _, error in | ||
| if let error { fatalError("Failed to load store: \(error)") } | ||
| } | ||
| return container | ||
| }() | ||
|
|
||
| var context: NSManagedObjectContext { container.viewContext } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| // | ||
|
|
||
| enum UserDefaultsKey: String, CaseIterable { | ||
| case userID | ||
| case provider | ||
| case lastProvider | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
MemberStorage를 초기화할 때NSManagedObjectContext가 누락되었습니다.MemberStorage의init은context를 필요로 하므로, 이대로는 런타임에 크래시가 발생할 것입니다.CoreDataStack.shared.context를 주입해야 합니다.