// 日记条目 Isar Collection — 本地持久化存储 // // 与纯 Dart 模型 JournalEntry 分离,通过转换函数桥接。 // 业务 ID (String UUID) 作为索引字段,Isar 主键用 autoIncrement。 import 'package:isar/isar.dart'; part 'journal_entry_collection.g.dart'; @collection class JournalEntryCollection { /// Isar 自增主键 Id isarId = Isar.autoIncrement; /// 业务 UUID(索引,用于查找) @Index() String id = ''; /// 作者 ID(索引 + 组合索引 authorId+dateEpoch,覆盖按作者查询并按日期排序的场景) @Index(composite: [CompositeIndex('dateEpoch')]) String authorId = ''; /// 班级 ID(可选) String? classId; /// 日记标题 String title = ''; /// 日记日期(epoch milliseconds)— 单独索引支持日期范围查询 @Index() int dateEpoch = 0; /// 心情(enum → string) String mood = 'calm'; /// 天气(enum → string) String weather = 'sunny'; /// 标签列表(JSON String) String tagsJson = '[]'; /// 是否私密 bool isPrivate = true; /// 是否分享到班级 bool sharedToClass = false; /// 关联主题 ID(可选) String? assignedTopicId; /// 内容摘要(自动从文本元素提取) String? contentExcerpt; /// 版本号(乐观锁) int version = 1; /// 创建时间(epoch milliseconds) int createdAtEpoch = 0; /// 更新时间(epoch milliseconds) int updatedAtEpoch = 0; /// 软删除标记 bool isDeleted = false; }