- V/R 시스템 완전 전환: WARRANTY/CONTRACT/INSPECTION → V(방문)/R(원격) - 유지보수 대시보드 카드 → StandardDataTable 테이블 형태 전환 - "조회중..." 문제 해결: 백엔드 직접 필드 사용 (equipment_model, company_name) - MaintenanceDto 신규 필드 추가: company_id, company_name, equipment_serial, equipment_model - preloadEquipmentData 비활성화로 불필요한 equipment-history API 호출 제거 - CO-STAR 프레임워크 적용 및 CLAUDE.md v3.0 업데이트 - Flutter Analyze ERROR: 0 유지, 100% shadcn_ui 컴플라이언스 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
109 lines
4.0 KiB
Dart
109 lines
4.0 KiB
Dart
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,
|
|
|
|
// 백엔드 추가 필드들
|
|
@JsonKey(name: 'equipment_serial') String? equipmentSerial,
|
|
@JsonKey(name: 'warehouse_name') String? warehouseName,
|
|
@JsonKey(name: 'companies') @Default([]) List<Map<String, dynamic>> companies,
|
|
|
|
// 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') int? warehousesId, // 출고 시 null 가능 (다른 회사로 완전 이관)
|
|
@JsonKey(name: 'company_ids') List<int>? companyIds, // 백엔드 API 매칭
|
|
@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 const String rent = 'R'; // 대여
|
|
static const String dispose = 'D'; // 폐기
|
|
|
|
static String getDisplayName(String type) {
|
|
switch (type) {
|
|
case input:
|
|
return '입고';
|
|
case output:
|
|
return '출고';
|
|
case rent:
|
|
return '대여';
|
|
case dispose:
|
|
return '폐기';
|
|
default:
|
|
return type;
|
|
}
|
|
}
|
|
|
|
static List<String> get allTypes => [input, output, rent, dispose];
|
|
} |