Files
superport/lib/data/models/maintenance_dto.dart
JiWoong Sul 519e1883a3
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled
feat: V/R 유지보수 시스템 전환 및 대시보드 테이블 형태 완성
- 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>
2025-09-05 14:33:20 +09:00

120 lines
4.5 KiB
Dart

import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:superport/data/models/equipment_history_dto.dart';
part 'maintenance_dto.freezed.dart';
part 'maintenance_dto.g.dart';
@freezed
class MaintenanceDto with _$MaintenanceDto {
const MaintenanceDto._(); // Private constructor for getters
const factory MaintenanceDto({
@JsonKey(name: 'id') int? id,
@JsonKey(name: 'equipment_history_id') int? equipmentHistoryId, // Optional in backend
@JsonKey(name: 'started_at') required DateTime startedAt,
@JsonKey(name: 'ended_at') required DateTime endedAt,
@JsonKey(name: 'period_month') @Default(1) int periodMonth,
@JsonKey(name: 'maintenance_type') @Default('V') String maintenanceType, // V: 방문, R: 원격
@JsonKey(name: 'is_deleted') @Default(false) bool isDeleted,
@JsonKey(name: 'registered_at') required DateTime registeredAt,
@JsonKey(name: 'updated_at') DateTime? updatedAt,
// 백엔드 추가 필드들 (계산된 값)
@JsonKey(name: 'equipment_serial') String? equipmentSerial,
@JsonKey(name: 'equipment_model') String? equipmentModel,
@JsonKey(name: 'company_id') int? companyId,
@JsonKey(name: 'company_name') String? companyName,
@JsonKey(name: 'days_remaining') int? daysRemaining,
@JsonKey(name: 'is_expired') @Default(false) bool isExpired,
// Related entities (optional, populated in GET requests)
EquipmentHistoryDto? equipmentHistory,
}) = _MaintenanceDto;
// isActive 계산 속성 (is_deleted의 반대)
bool get isActive => !isDeleted;
factory MaintenanceDto.fromJson(Map<String, dynamic> json) =>
_$MaintenanceDtoFromJson(json);
}
@freezed
class MaintenanceRequestDto with _$MaintenanceRequestDto {
const factory MaintenanceRequestDto({
@JsonKey(name: 'equipment_history_id') int? equipmentHistoryId, // Optional in backend
@JsonKey(name: 'started_at') required DateTime startedAt,
@JsonKey(name: 'ended_at') required DateTime endedAt,
@JsonKey(name: 'period_month') @Default(1) int periodMonth,
@JsonKey(name: 'maintenance_type') @Default('V') String maintenanceType, // V: 방문, R: 원격
}) = _MaintenanceRequestDto;
factory MaintenanceRequestDto.fromJson(Map<String, dynamic> json) =>
_$MaintenanceRequestDtoFromJson(json);
}
@freezed
class MaintenanceUpdateRequestDto with _$MaintenanceUpdateRequestDto {
const factory MaintenanceUpdateRequestDto({
@JsonKey(name: 'started_at') DateTime? startedAt,
@JsonKey(name: 'ended_at') DateTime? endedAt,
@JsonKey(name: 'period_month') int? periodMonth,
@JsonKey(name: 'maintenance_type') String? maintenanceType,
}) = _MaintenanceUpdateRequestDto;
factory MaintenanceUpdateRequestDto.fromJson(Map<String, dynamic> json) =>
_$MaintenanceUpdateRequestDtoFromJson(json);
}
@freezed
class MaintenanceListResponse with _$MaintenanceListResponse {
const factory MaintenanceListResponse({
@JsonKey(name: 'data') required List<MaintenanceDto> 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,
}) = _MaintenanceListResponse;
factory MaintenanceListResponse.fromJson(Map<String, dynamic> json) =>
_$MaintenanceListResponseFromJson(json);
}
@freezed
class MaintenanceQueryDto with _$MaintenanceQueryDto {
const factory MaintenanceQueryDto({
@JsonKey(name: 'equipment_id') int? equipmentId,
@JsonKey(name: 'maintenance_type') String? maintenanceType,
@JsonKey(name: 'is_expired') bool? isExpired,
@JsonKey(name: 'expiring_days') int? expiringDays,
@JsonKey(name: 'page') @Default(1) int page,
@JsonKey(name: 'per_page') @Default(10) int perPage,
@JsonKey(name: 'include_deleted') @Default(false) bool includeDeleted,
}) = _MaintenanceQueryDto;
factory MaintenanceQueryDto.fromJson(Map<String, dynamic> json) =>
_$MaintenanceQueryDtoFromJson(json);
}
// Maintenance Type 헬퍼 (V/R 시스템)
class MaintenanceType {
static const String visit = 'V'; // 방문 유지보수
static const String remote = 'R'; // 원격 유지보수
static String getDisplayName(String type) {
switch (type) {
case visit:
return '방문';
case remote:
return '원격';
default:
return type;
}
}
static List<String> get allTypes => [visit, remote];
static List<Map<String, String>> get typeOptions => [
{'value': visit, 'label': '방문'},
{'value': remote, 'label': '원격'},
];
}