import 'package:hive/hive.dart'; part 'inspiration_image.g.dart'; /// 灵感图片实体类 - 核心业务实体 /// 用于表示用户保存的灵感图片,包含图片的所有元数据和属性 @HiveType(typeId: 0) class InspirationImage { /// 图片唯一标识符 - UUID格式 @HiveField(0) final String id; /// 原图文件路径 - 本地存储的完整路径 @HiveField(1) final String filePath; /// 缩略图文件路径 - 经过压缩处理的小图路径 @HiveField(2) final String thumbnailPath; /// 所属文件夹ID - 可为空的关联文件夹标识 @HiveField(3) final String? folderId; /// 标签ID列表 - 图片关联的标签集合 @HiveField(4) final List tags; /// 用户备注 - 对图片的文字描述或备注信息 @HiveField(5) final String? note; /// 创建时间 - 图片保存到应用的时间 @HiveField(6) final DateTime createdAt; /// 更新时间 - 图片信息最后修改时间 @HiveField(7) final DateTime updatedAt; /// 原始文件名 - 从分享接收时的原始文件名 @HiveField(8) final String? originalName; /// 文件大小 - 以字节为单位的文件大小 @HiveField(9) final int fileSize; /// MIME类型 - 图片的媒体类型 (如 image/jpeg) @HiveField(10) final String mimeType; /// 图片宽度 - 像素单位的图片宽度 @HiveField(11) final int? width; /// 图片高度 - 像素单位的图片高度 @HiveField(12) final int? height; /// 是否收藏 - 用户标记的收藏状态 @HiveField(13) final bool isFavorite; /// 构造函数 - 创建灵感图片实例 /// 所有必需参数都需要在创建时提供 InspirationImage({ required this.id, required this.filePath, required this.thumbnailPath, this.folderId, required this.tags, this.note, required this.createdAt, required this.updatedAt, this.originalName, required this.fileSize, required this.mimeType, this.width, this.height, this.isFavorite = false, }); /// 复制对象方法 - 创建当前对象的副本,可选择性更新字段 /// 用于需要修改对象属性时保持不可变性 InspirationImage copyWith({ String? id, String? filePath, String? thumbnailPath, String? folderId, List? tags, String? note, DateTime? createdAt, DateTime? updatedAt, String? originalName, int? fileSize, String? mimeType, int? width, int? height, bool? isFavorite, }) { return InspirationImage( id: id ?? this.id, filePath: filePath ?? this.filePath, thumbnailPath: thumbnailPath ?? this.thumbnailPath, folderId: folderId ?? this.folderId, tags: tags ?? this.tags, note: note ?? this.note, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, originalName: originalName ?? this.originalName, fileSize: fileSize ?? this.fileSize, mimeType: mimeType ?? this.mimeType, width: width ?? this.width, height: height ?? this.height, isFavorite: isFavorite ?? this.isFavorite, ); } }