69 lines
1.8 KiB
Dart
69 lines
1.8 KiB
Dart
import 'package:hive/hive.dart';
|
|
|
|
part 'image_folder.g.dart';
|
|
|
|
/// 图片文件夹实体类 - 用于组织和管理图片
|
|
/// 用户可以创建多个文件夹来分类存储灵感图片
|
|
@HiveType(typeId: 1)
|
|
class ImageFolder {
|
|
/// 文件夹唯一标识符 - UUID格式
|
|
@HiveField(0)
|
|
final String id;
|
|
|
|
/// 文件夹名称 - 用户自定义的文件夹名称
|
|
@HiveField(1)
|
|
final String name;
|
|
|
|
/// 封面图片ID - 用于展示文件夹预览的封面图片
|
|
@HiveField(2)
|
|
final String? coverImageId;
|
|
|
|
/// 文件夹图标 - Material Design图标名称
|
|
@HiveField(3)
|
|
final String icon;
|
|
|
|
/// 创建时间 - 文件夹创建时间戳
|
|
@HiveField(4)
|
|
final DateTime createdAt;
|
|
|
|
/// 更新时间 - 文件夹信息最后修改时间
|
|
@HiveField(5)
|
|
final DateTime updatedAt;
|
|
|
|
/// 最近使用时间 - 用于文件夹排序和推荐
|
|
@HiveField(6)
|
|
final DateTime lastUsedAt;
|
|
|
|
/// 构造函数 - 创建图片文件夹实例
|
|
ImageFolder({
|
|
required this.id,
|
|
required this.name,
|
|
this.coverImageId,
|
|
required this.icon,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.lastUsedAt,
|
|
});
|
|
|
|
/// 复制对象方法 - 创建当前对象的副本,可选择性更新字段
|
|
/// 用于需要修改文件夹属性时保持不可变性
|
|
ImageFolder copyWith({
|
|
String? id,
|
|
String? name,
|
|
String? coverImageId,
|
|
String? icon,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
DateTime? lastUsedAt,
|
|
}) {
|
|
return ImageFolder(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
coverImageId: coverImageId ?? this.coverImageId,
|
|
icon: icon ?? this.icon,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
lastUsedAt: lastUsedAt ?? this.lastUsedAt,
|
|
);
|
|
}
|
|
} |