This commit is contained in:
2025-10-10 22:49:05 +07:00
parent 02941e2234
commit 38c16bf0b9
49 changed files with 2702 additions and 740 deletions

View File

@@ -27,6 +27,9 @@ class CategoryModel extends HiveObject {
@HiveField(6)
final DateTime createdAt;
@HiveField(7)
final DateTime updatedAt;
CategoryModel({
required this.id,
required this.name,
@@ -35,6 +38,7 @@ class CategoryModel extends HiveObject {
this.color,
required this.productCount,
required this.createdAt,
required this.updatedAt,
});
/// Convert to domain entity
@@ -47,6 +51,7 @@ class CategoryModel extends HiveObject {
color: color,
productCount: productCount,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
@@ -60,6 +65,7 @@ class CategoryModel extends HiveObject {
color: category.color,
productCount: category.productCount,
createdAt: category.createdAt,
updatedAt: category.updatedAt,
);
}
@@ -71,8 +77,9 @@ class CategoryModel extends HiveObject {
description: json['description'] as String?,
iconPath: json['iconPath'] as String?,
color: json['color'] as String?,
productCount: json['productCount'] as int,
productCount: json['productCount'] as int? ?? 0,
createdAt: DateTime.parse(json['createdAt'] as String),
updatedAt: DateTime.parse(json['updatedAt'] as String),
);
}
@@ -86,6 +93,7 @@ class CategoryModel extends HiveObject {
'color': color,
'productCount': productCount,
'createdAt': createdAt.toIso8601String(),
'updatedAt': updatedAt.toIso8601String(),
};
}
@@ -98,6 +106,7 @@ class CategoryModel extends HiveObject {
String? color,
int? productCount,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return CategoryModel(
id: id ?? this.id,
@@ -107,6 +116,7 @@ class CategoryModel extends HiveObject {
color: color ?? this.color,
productCount: productCount ?? this.productCount,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
);
}
}

View File

@@ -24,13 +24,14 @@ class CategoryModelAdapter extends TypeAdapter<CategoryModel> {
color: fields[4] as String?,
productCount: (fields[5] as num).toInt(),
createdAt: fields[6] as DateTime,
updatedAt: fields[7] as DateTime,
);
}
@override
void write(BinaryWriter writer, CategoryModel obj) {
writer
..writeByte(7)
..writeByte(8)
..writeByte(0)
..write(obj.id)
..writeByte(1)
@@ -44,7 +45,9 @@ class CategoryModelAdapter extends TypeAdapter<CategoryModel> {
..writeByte(5)
..write(obj.productCount)
..writeByte(6)
..write(obj.createdAt);
..write(obj.createdAt)
..writeByte(7)
..write(obj.updatedAt);
}
@override