import 'package:freezed_annotation/freezed_annotation.dart';

part 'stock_status_dto.freezed.dart';
part 'stock_status_dto.g.dart';

/// 재고 현황 DTO (백엔드 stock-status API 응답)
@freezed
class StockStatusDto with _$StockStatusDto {
  const factory StockStatusDto({
    // 백엔드 StockStatusResponse와 정확히 매핑
    @JsonKey(name: 'equipment_id') required int equipmentId,
    @JsonKey(name: 'warehouse_id') required int warehouseId,
    @JsonKey(name: 'equipment_serial') required String equipmentSerial,
    @JsonKey(name: 'model_name') String? modelName,
    @JsonKey(name: 'warehouse_name') required String warehouseName,
    @JsonKey(name: 'current_quantity') required int currentQuantity,
    @JsonKey(name: 'last_transaction_date') DateTime? lastTransactionDate,
  }) = _StockStatusDto;

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

/// 재고 현황 목록 응답 DTO
@freezed
class StockStatusListResponse with _$StockStatusListResponse {
  const factory StockStatusListResponse({
    required List<StockStatusDto> items,
  }) = _StockStatusListResponse;

  factory StockStatusListResponse.fromJson(List<dynamic> json) =>
      StockStatusListResponse(
        items: json.map((item) => StockStatusDto.fromJson(item)).toList(),
      );
}