update review api.

This commit is contained in:
Phuoc Nguyen
2025-11-17 17:54:32 +07:00
parent 0798b28db5
commit 0841e3bf3d
23 changed files with 4856 additions and 209 deletions

View File

@@ -0,0 +1,49 @@
/// Domain Entity: Review Statistics
///
/// Aggregate statistics for product reviews.
library;
/// Review statistics entity
///
/// Contains aggregate data about reviews:
/// - Total number of feedbacks
/// - Average rating (0-5 scale)
class ReviewStatistics {
const ReviewStatistics({
required this.totalFeedback,
required this.averageRating,
});
/// Total number of reviews/feedbacks
final int totalFeedback;
/// Average rating (0-5 scale)
/// Note: This is already on 0-5 scale from API, no conversion needed
final double averageRating;
/// Check if there are any reviews
bool get hasReviews => totalFeedback > 0;
/// Get star rating rounded to nearest 0.5
/// Used for displaying star icons
double get displayRating {
return (averageRating * 2).round() / 2;
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ReviewStatistics &&
other.totalFeedback == totalFeedback &&
other.averageRating == averageRating;
}
@override
int get hashCode => Object.hash(totalFeedback, averageRating);
@override
String toString() {
return 'ReviewStatistics(totalFeedback: $totalFeedback, averageRating: $averageRating)';
}
}