chore: core 多模块骨架
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
/// 打卡习惯的持久化实体(对应 Android Room 的 @Entity)。
|
||||
@Model
|
||||
public final class HabitEntity {
|
||||
public var id: String
|
||||
public var title: String
|
||||
public var detail: String
|
||||
public var streakDays: Int
|
||||
public var createdAt: Date
|
||||
|
||||
public init(id: String, title: String, detail: String, streakDays: Int, createdAt: Date) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
self.detail = detail
|
||||
self.streakDays = streakDays
|
||||
self.createdAt = createdAt
|
||||
}
|
||||
}
|
||||
|
||||
/// SwiftData 容器工厂(对应 Android RoomDatabase)。
|
||||
public enum PersistenceController {
|
||||
public static func makeModelContainer(inMemory: Bool = false) throws -> ModelContainer {
|
||||
let configuration = ModelConfiguration(isStoredInMemoryOnly: inMemory)
|
||||
return try ModelContainer(for: HabitEntity.self, configurations: configuration)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user