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

80 lines
2.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:hive/hive.dart';
part 'display_data.g.dart';
@HiveType(typeId: 11)
class DisplayData extends HiveObject {
@HiveField(0)
final String name;
@HiveField(1)
final String brewery;
@HiveField(2)
final String prefecture;
@HiveField(3)
final String? catchCopy;
@HiveField(4)
final List<String> imagePaths;
@HiveField(5)
final double? rating;
// ✅ さけのわデータ(統一名称用)- 表示時にこちらを優先
@HiveField(6)
final String? sakenowaName;
@HiveField(7)
final String? sakenowaBrewery;
@HiveField(8)
final String? sakenowaPrefecture;
DisplayData({
required this.name,
required this.brewery,
required this.prefecture,
this.catchCopy,
required this.imagePaths,
this.rating,
// さけのわデータ(オプショナル)
this.sakenowaName,
this.sakenowaBrewery,
this.sakenowaPrefecture,
});
// ✅ 表示用ゲッターさけのわデータ優先、なければGeminiデータ
String get displayName => sakenowaName ?? name;
String get displayBrewery => sakenowaBrewery ?? brewery;
String get displayPrefecture => sakenowaPrefecture ?? prefecture;
// ✅ さけのわデータが設定されているか
bool get hasSakenowaData => sakenowaName != null;
DisplayData copyWith({
String? name,
String? brewery,
String? prefecture,
String? catchCopy,
List<String>? imagePaths,
double? rating,
String? sakenowaName,
String? sakenowaBrewery,
String? sakenowaPrefecture,
}) {
return DisplayData(
name: name ?? this.name,
brewery: brewery ?? this.brewery,
prefecture: prefecture ?? this.prefecture,
catchCopy: catchCopy ?? this.catchCopy,
imagePaths: imagePaths ?? this.imagePaths,
rating: rating ?? this.rating,
sakenowaName: sakenowaName ?? this.sakenowaName,
sakenowaBrewery: sakenowaBrewery ?? this.sakenowaBrewery,
sakenowaPrefecture: sakenowaPrefecture ?? this.sakenowaPrefecture,
);
}
}