ponshu-room-lite/lib/models/schema/hidden_specs.dart

104 lines
2.5 KiB
Dart

import 'package:hive/hive.dart';
import 'sake_taste_stats.dart';
part 'hidden_specs.g.dart';
@HiveType(typeId: 12)
class HiddenSpecs extends HiveObject {
@HiveField(0)
final String? description;
@HiveField(1)
final Map<String, int> tasteStats;
@HiveField(2)
final List<String> flavorTags;
@HiveField(3)
final double? sweetnessScore;
@HiveField(4)
final double? bodyScore;
// Future specs
@HiveField(5)
final String? type; // 特定名称
@HiveField(6)
final double? alcoholContent;
@HiveField(7)
final int? polishingRatio;
@HiveField(8)
final double? sakeMeterValue; // 日本酒度
@HiveField(9)
final String? riceVariety;
@HiveField(10)
final String? yeast;
@HiveField(11)
final String? manufacturingYearMonth;
@HiveField(12)
final String? qrCodeUrl;
// Helper getter to convert generic Map to typed SakeTasteStats
SakeTasteStats get sakeTasteStats {
if (tasteStats.isEmpty) {
return SakeTasteStats(aroma: 0, richness: 0, sweetness: 0, alcoholFeeling: 0, fruitiness: 0);
}
return SakeTasteStats.fromMap(tasteStats);
}
HiddenSpecs({
this.description,
this.tasteStats = const {},
this.flavorTags = const [],
this.sweetnessScore,
this.bodyScore,
this.type,
this.alcoholContent,
this.polishingRatio,
this.sakeMeterValue,
this.riceVariety,
this.yeast,
this.manufacturingYearMonth,
this.qrCodeUrl,
});
HiddenSpecs copyWith({
String? description,
Map<String, int>? tasteStats,
List<String>? flavorTags,
double? sweetnessScore,
double? bodyScore,
String? type,
double? alcoholContent,
int? polishingRatio,
double? sakeMeterValue,
String? riceVariety,
String? yeast,
String? manufacturingYearMonth,
String? qrCodeUrl,
}) {
return HiddenSpecs(
description: description ?? this.description,
tasteStats: tasteStats ?? this.tasteStats,
flavorTags: flavorTags ?? this.flavorTags,
sweetnessScore: sweetnessScore ?? this.sweetnessScore,
bodyScore: bodyScore ?? this.bodyScore,
type: type ?? this.type,
alcoholContent: alcoholContent ?? this.alcoholContent,
polishingRatio: polishingRatio ?? this.polishingRatio,
sakeMeterValue: sakeMeterValue ?? this.sakeMeterValue,
riceVariety: riceVariety ?? this.riceVariety,
yeast: yeast ?? this.yeast,
manufacturingYearMonth: manufacturingYearMonth ?? this.manufacturingYearMonth,
qrCodeUrl: qrCodeUrl ?? this.qrCodeUrl,
);
}
}