snap_wish/lib/domain/entities/image_folder.dart
2025-10-09 17:10:38 +08:00

73 lines
2.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
);
}
/// 文件夹图片数量 - 计算属性,动态获取文件夹中包含的图片数量
/// 注意这是一个占位符属性实际实现需要通过Repository查询
int get imageCount => 0;
}