import 'package:freezed_annotation/freezed_annotation.dart';

part 'equipment_history_dto.freezed.dart';
part 'equipment_history_dto.g.dart';

@freezed
class EquipmentHistoryDto with _$EquipmentHistoryDto {
  const factory EquipmentHistoryDto({
    required int id,
    @JsonKey(name: 'equipment_id') required int equipmentId,
    @JsonKey(name: 'transaction_type') required String transactionType,
    required int quantity,
    @JsonKey(name: 'transaction_date') required DateTime transactionDate,
    String? remarks,
    @JsonKey(name: 'created_by') int? createdBy,
    @JsonKey(name: 'user_id') int? userId,
    @JsonKey(name: 'created_at') required DateTime createdAt,
    // 추가 정보
    @JsonKey(name: 'user_name') String? userName,
    @JsonKey(name: 'performed_by') String? performedBy,
  }) = _EquipmentHistoryDto;

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

@freezed
class CreateHistoryRequest with _$CreateHistoryRequest {
  const factory CreateHistoryRequest({
    @JsonKey(name: 'transaction_type') required String transactionType,
    required int quantity,
    @JsonKey(name: 'transaction_date') DateTime? transactionDate,
    String? remarks,
    @JsonKey(name: 'user_id') int? userId,
  }) = _CreateHistoryRequest;

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

// 트랜잭션 타입 상수
class TransactionType {
  static const String checkIn = 'I';  // 입고
  static const String checkOut = 'O'; // 출고
  static const String maintenance = 'maintenance';
  static const String repair = 'repair';
  static const String inspection = 'inspection';
  static const String transfer = 'transfer';
}