import 'package:hive/hive.dart';

part 'restaurant.g.dart';

@HiveType(typeId: 0)
class Restaurant extends HiveObject {
  @HiveField(0)
  final String id;

  @HiveField(1)
  final String name;

  @HiveField(2)
  final String category;

  @HiveField(3)
  final String subCategory;

  @HiveField(4)
  final String? description;

  @HiveField(5)
  final String? phoneNumber;

  @HiveField(6)
  final String roadAddress;

  @HiveField(7)
  final String jibunAddress;

  @HiveField(8)
  final double latitude;

  @HiveField(9)
  final double longitude;

  @HiveField(10)
  final DateTime? lastVisitDate;

  @HiveField(11)
  final DataSource source;

  @HiveField(12)
  final DateTime createdAt;

  @HiveField(13)
  final DateTime updatedAt;

  @HiveField(14)
  final String? naverPlaceId;

  @HiveField(15)
  final String? naverUrl;

  @HiveField(16)
  final String? businessHours;

  @HiveField(17)
  final DateTime? lastVisited;

  @HiveField(18)
  final int visitCount;

  @HiveField(19)
  final bool needsAddressVerification;

  Restaurant({
    required this.id,
    required this.name,
    required this.category,
    required this.subCategory,
    this.description,
    this.phoneNumber,
    required this.roadAddress,
    required this.jibunAddress,
    required this.latitude,
    required this.longitude,
    this.lastVisitDate,
    required this.source,
    required this.createdAt,
    required this.updatedAt,
    this.naverPlaceId,
    this.naverUrl,
    this.businessHours,
    this.lastVisited,
    this.visitCount = 0,
    this.needsAddressVerification = false,
  });

  Restaurant copyWith({
    String? id,
    String? name,
    String? category,
    String? subCategory,
    String? description,
    String? phoneNumber,
    String? roadAddress,
    String? jibunAddress,
    double? latitude,
    double? longitude,
    DateTime? lastVisitDate,
    DataSource? source,
    DateTime? createdAt,
    DateTime? updatedAt,
    String? naverPlaceId,
    String? naverUrl,
    String? businessHours,
    DateTime? lastVisited,
    int? visitCount,
    bool? needsAddressVerification,
  }) {
    return Restaurant(
      id: id ?? this.id,
      name: name ?? this.name,
      category: category ?? this.category,
      subCategory: subCategory ?? this.subCategory,
      description: description ?? this.description,
      phoneNumber: phoneNumber ?? this.phoneNumber,
      roadAddress: roadAddress ?? this.roadAddress,
      jibunAddress: jibunAddress ?? this.jibunAddress,
      latitude: latitude ?? this.latitude,
      longitude: longitude ?? this.longitude,
      lastVisitDate: lastVisitDate ?? this.lastVisitDate,
      source: source ?? this.source,
      createdAt: createdAt ?? this.createdAt,
      updatedAt: updatedAt ?? this.updatedAt,
      naverPlaceId: naverPlaceId ?? this.naverPlaceId,
      naverUrl: naverUrl ?? this.naverUrl,
      businessHours: businessHours ?? this.businessHours,
      lastVisited: lastVisited ?? this.lastVisited,
      visitCount: visitCount ?? this.visitCount,
      needsAddressVerification:
          needsAddressVerification ?? this.needsAddressVerification,
    );
  }
}

@HiveType(typeId: 1)
enum DataSource {
  @HiveField(0)
  NAVER,

  @HiveField(1)
  USER_INPUT,

  @HiveField(2)
  PRESET,
}
