update database

This commit is contained in:
Phuoc Nguyen
2025-10-24 11:31:48 +07:00
parent f95fa9d0a6
commit c4272f9a21
126 changed files with 23528 additions and 2234 deletions

View File

@@ -0,0 +1,92 @@
/// Domain Entity: Cart
///
/// Represents a shopping cart for a user.
library;
/// Cart Entity
///
/// Contains cart-level information:
/// - User ID
/// - Total amount
/// - Sync status
/// - Timestamps
class Cart {
/// Unique cart identifier
final String cartId;
/// User ID who owns this cart
final String userId;
/// Total cart amount
final double totalAmount;
/// Whether cart is synced with backend
final bool isSynced;
/// Last modification timestamp
final DateTime lastModified;
/// Cart creation timestamp
final DateTime createdAt;
const Cart({
required this.cartId,
required this.userId,
required this.totalAmount,
required this.isSynced,
required this.lastModified,
required this.createdAt,
});
/// Check if cart is empty
bool get isEmpty => totalAmount == 0;
/// Check if cart needs sync
bool get needsSync => !isSynced;
/// Copy with method for immutability
Cart copyWith({
String? cartId,
String? userId,
double? totalAmount,
bool? isSynced,
DateTime? lastModified,
DateTime? createdAt,
}) {
return Cart(
cartId: cartId ?? this.cartId,
userId: userId ?? this.userId,
totalAmount: totalAmount ?? this.totalAmount,
isSynced: isSynced ?? this.isSynced,
lastModified: lastModified ?? this.lastModified,
createdAt: createdAt ?? this.createdAt,
);
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is Cart &&
other.cartId == cartId &&
other.userId == userId &&
other.totalAmount == totalAmount &&
other.isSynced == isSynced;
}
@override
int get hashCode {
return Object.hash(
cartId,
userId,
totalAmount,
isSynced,
);
}
@override
String toString() {
return 'Cart(cartId: $cartId, userId: $userId, totalAmount: $totalAmount, '
'isSynced: $isSynced, lastModified: $lastModified)';
}
}