import 'package:freezed_annotation/freezed_annotation.dart';

part 'model_dto.freezed.dart';
part 'model_dto.g.dart';

@freezed
class ModelDto with _$ModelDto {
  const factory ModelDto({
    required int id,
    @JsonKey(name: 'vendors_id') required int vendorsId,
    @JsonKey(name: 'vendor_name') String? vendorName, // JOIN 필드
    required String name,
    @JsonKey(name: 'is_deleted') required bool isDeleted,
    @JsonKey(name: 'registered_at') required DateTime registeredAt,
    @JsonKey(name: 'updated_at') DateTime? updatedAt,
  }) = _ModelDto;

  factory ModelDto.fromJson(Map<String, dynamic> json) => _$ModelDtoFromJson(json);
}

@freezed
class ModelListDto with _$ModelListDto {
  const factory ModelListDto({
    @JsonKey(name: 'data') required List<ModelDto> items,
    required int total,
    required int page,
    @JsonKey(name: 'page_size') required int perPage,
    @JsonKey(name: 'total_pages') required int totalPages,
  }) = _ModelListDto;

  factory ModelListDto.fromJson(Map<String, dynamic> json) => _$ModelListDtoFromJson(json);
}

@freezed
class CreateModelRequest with _$CreateModelRequest {
  const factory CreateModelRequest({
    @JsonKey(name: 'vendors_id') required int vendorsId,
    required String name,
  }) = _CreateModelRequest;

  factory CreateModelRequest.fromJson(Map<String, dynamic> json) => _$CreateModelRequestFromJson(json);
}

@freezed
class UpdateModelRequest with _$UpdateModelRequest {
  const factory UpdateModelRequest({
    @JsonKey(name: 'vendors_id') int? vendorsId,
    String? name,
  }) = _UpdateModelRequest;

  factory UpdateModelRequest.fromJson(Map<String, dynamic> json) => _$UpdateModelRequestFromJson(json);
}