This commit is contained in:
Phuoc Nguyen
2025-10-24 16:20:48 +07:00
parent eaaa9921f5
commit b27c5d7742
17 changed files with 3245 additions and 5 deletions

View File

@@ -0,0 +1,72 @@
/// Domain Entity: Favorite
///
/// Pure business entity representing a user's favorite product.
/// This entity is framework-independent and contains only business logic.
library;
/// Favorite Entity
///
/// Represents a product that a user has marked as favorite.
/// Used across all layers but originates in the domain layer.
class Favorite {
/// Unique identifier for the favorite entry
final String favoriteId;
/// Reference to the product that was favorited
final String productId;
/// Reference to the user who favorited the product
final String userId;
/// Timestamp when the product was favorited
final DateTime createdAt;
const Favorite({
required this.favoriteId,
required this.productId,
required this.userId,
required this.createdAt,
});
/// Copy with method for creating modified copies
Favorite copyWith({
String? favoriteId,
String? productId,
String? userId,
DateTime? createdAt,
}) {
return Favorite(
favoriteId: favoriteId ?? this.favoriteId,
productId: productId ?? this.productId,
userId: userId ?? this.userId,
createdAt: createdAt ?? this.createdAt,
);
}
@override
String toString() {
return 'Favorite(favoriteId: $favoriteId, productId: $productId, '
'userId: $userId, createdAt: $createdAt)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is Favorite &&
other.favoriteId == favoriteId &&
other.productId == productId &&
other.userId == userId &&
other.createdAt == createdAt;
}
@override
int get hashCode {
return Object.hash(
favoriteId,
productId,
userId,
createdAt,
);
}
}