import 'package:freezed_annotation/freezed_annotation.dart';

part 'equipment_list_dto.freezed.dart';
part 'equipment_list_dto.g.dart';

@freezed
class EquipmentListDto with _$EquipmentListDto {
  const factory EquipmentListDto({
    required int id,
    @JsonKey(name: 'equipment_number') required String equipmentNumber,
    required String manufacturer,
    @JsonKey(name: 'model_name') String? modelName,
    @JsonKey(name: 'serial_number') String? serialNumber,
    required String status,
    @JsonKey(name: 'company_id') int? companyId,
    @JsonKey(name: 'warehouse_location_id') int? warehouseLocationId,
    @JsonKey(name: 'created_at') required DateTime createdAt,
    // 추가 필드 (조인된 데이터)
    @JsonKey(name: 'company_name') String? companyName,
    @JsonKey(name: 'warehouse_name') String? warehouseName,
  }) = _EquipmentListDto;

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

/// 장비 목록 응답 DTO
@freezed
class EquipmentListResponseDto with _$EquipmentListResponseDto {
  const factory EquipmentListResponseDto({
    required List<EquipmentListDto> items,
    required int total,
    required int page,
    @JsonKey(name: 'per_page') required int perPage,
    @JsonKey(name: 'total_pages') required int totalPages,
  }) = _EquipmentListResponseDto;

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