사용하지 않는 파일 정리 전 백업 (Phase 10 완료 후 상태)
This commit is contained in:
96
lib/data/models/equipment_history_dto.dart
Normal file
96
lib/data/models/equipment_history_dto.dart
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:superport/data/models/equipment/equipment_dto.dart';
|
||||
import 'package:superport/data/models/warehouse/warehouse_dto.dart';
|
||||
|
||||
part 'equipment_history_dto.freezed.dart';
|
||||
part 'equipment_history_dto.g.dart';
|
||||
|
||||
@freezed
|
||||
class EquipmentHistoryDto with _$EquipmentHistoryDto {
|
||||
const EquipmentHistoryDto._(); // Private constructor for getters
|
||||
|
||||
const factory EquipmentHistoryDto({
|
||||
@JsonKey(name: 'Id') int? id,
|
||||
@JsonKey(name: 'equipments_Id') required int equipmentsId,
|
||||
@JsonKey(name: 'warehouses_Id') required int warehousesId,
|
||||
@JsonKey(name: 'transaction_type') required String transactionType,
|
||||
required int quantity,
|
||||
@JsonKey(name: 'transacted_at') required DateTime transactedAt,
|
||||
String? remark,
|
||||
@JsonKey(name: 'is_deleted') @Default(false) bool isDeleted,
|
||||
@JsonKey(name: 'created_at') required DateTime createdAt,
|
||||
@JsonKey(name: 'updated_at') DateTime? updatedAt,
|
||||
|
||||
// Related entities (optional, populated in GET requests)
|
||||
EquipmentDto? equipment,
|
||||
WarehouseDto? warehouse,
|
||||
}) = _EquipmentHistoryDto;
|
||||
|
||||
// isActive 계산 속성 (is_deleted의 반대)
|
||||
bool get isActive => !isDeleted;
|
||||
|
||||
factory EquipmentHistoryDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$EquipmentHistoryDtoFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class EquipmentHistoryRequestDto with _$EquipmentHistoryRequestDto {
|
||||
const factory EquipmentHistoryRequestDto({
|
||||
@JsonKey(name: 'equipments_Id') required int equipmentsId,
|
||||
@JsonKey(name: 'warehouses_Id') required int warehousesId,
|
||||
@JsonKey(name: 'transaction_type') required String transactionType,
|
||||
required int quantity,
|
||||
@JsonKey(name: 'transacted_at') DateTime? transactedAt,
|
||||
String? remark,
|
||||
}) = _EquipmentHistoryRequestDto;
|
||||
|
||||
factory EquipmentHistoryRequestDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$EquipmentHistoryRequestDtoFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class EquipmentHistoryUpdateRequestDto with _$EquipmentHistoryUpdateRequestDto {
|
||||
const factory EquipmentHistoryUpdateRequestDto({
|
||||
@JsonKey(name: 'warehouses_Id') int? warehousesId,
|
||||
@JsonKey(name: 'transaction_type') String? transactionType,
|
||||
int? quantity,
|
||||
@JsonKey(name: 'transacted_at') DateTime? transactedAt,
|
||||
String? remark,
|
||||
}) = _EquipmentHistoryUpdateRequestDto;
|
||||
|
||||
factory EquipmentHistoryUpdateRequestDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$EquipmentHistoryUpdateRequestDtoFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class EquipmentHistoryListResponse with _$EquipmentHistoryListResponse {
|
||||
const factory EquipmentHistoryListResponse({
|
||||
@JsonKey(name: 'data') required List<EquipmentHistoryDto> items,
|
||||
@JsonKey(name: 'total') required int totalCount,
|
||||
@JsonKey(name: 'page') required int currentPage,
|
||||
@JsonKey(name: 'total_pages') required int totalPages,
|
||||
@JsonKey(name: 'page_size') int? pageSize,
|
||||
}) = _EquipmentHistoryListResponse;
|
||||
|
||||
factory EquipmentHistoryListResponse.fromJson(Map<String, dynamic> json) =>
|
||||
_$EquipmentHistoryListResponseFromJson(json);
|
||||
}
|
||||
|
||||
// Transaction Type 헬퍼
|
||||
class TransactionType {
|
||||
static const String input = 'I';
|
||||
static const String output = 'O';
|
||||
|
||||
static String getDisplayName(String type) {
|
||||
switch (type) {
|
||||
case input:
|
||||
return '입고';
|
||||
case output:
|
||||
return '출고';
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
static List<String> get allTypes => [input, output];
|
||||
}
|
||||
Reference in New Issue
Block a user