사용하지 않는 파일 정리 전 백업 (Phase 10 완료 후 상태)
This commit is contained in:
@@ -22,14 +22,12 @@ class CompanyItem {
|
||||
);
|
||||
|
||||
/// 본사 생성자
|
||||
CompanyItem.headquarters(Company company)
|
||||
: company = company,
|
||||
parentCompanyName = null;
|
||||
CompanyItem.headquarters(this.company)
|
||||
: parentCompanyName = null;
|
||||
|
||||
/// 지점 생성자
|
||||
CompanyItem.branch(Company branchCompany, String parentCompanyName)
|
||||
: company = branchCompany,
|
||||
parentCompanyName = parentCompanyName;
|
||||
CompanyItem.branch(Company branchCompany, this.parentCompanyName)
|
||||
: company = branchCompany;
|
||||
|
||||
/// 표시용 이름 (계층적 구조)
|
||||
String get displayName {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import 'package:superport/data/models/model_dto.dart';
|
||||
import 'package:superport/utils/constants.dart';
|
||||
|
||||
// 장비 정보 모델 - 백엔드 API 완전 호환
|
||||
// 장비 정보 모델 - Sprint 3: Vendor/Model 체계로 전환
|
||||
class Equipment {
|
||||
final int? id;
|
||||
final String manufacturer;
|
||||
|
||||
// Sprint 3: 새로운 FK 관계 필드들
|
||||
final int? modelsId; // models 테이블 FK
|
||||
final ModelDto? model; // Model 정보 (Vendor 포함)
|
||||
|
||||
// 메인 필드들 - 백엔드 API 호환
|
||||
final String equipmentNumber; // 장비 번호 (메인)
|
||||
final String modelName; // 모델명 (메인)
|
||||
final String category1; // 대분류 (메인)
|
||||
final String category2; // 중분류 (메인)
|
||||
final String category3; // 소분류 (메인)
|
||||
final String? serialNumber;
|
||||
final String? barcode;
|
||||
final int quantity;
|
||||
@@ -31,7 +31,17 @@ class Equipment {
|
||||
final String? equipmentStatus; // 장비 상태
|
||||
final int? companyId; // 구매처 회사 ID
|
||||
|
||||
// 레거시 호환성 필드들 (Deprecated - 하위 호환성 위해 유지)
|
||||
// Sprint 3: 레거시 호환성 getters (임시 유지 - 점진적 마이그레이션용)
|
||||
String get manufacturer => model?.vendor?.name ?? 'N/A';
|
||||
String get modelName => model?.name ?? 'N/A';
|
||||
String get category1 => 'N/A'; // 더 이상 사용하지 않음
|
||||
String get category2 => 'N/A'; // 더 이상 사용하지 않음
|
||||
String get category3 => 'N/A'; // 더 이상 사용하지 않음
|
||||
|
||||
// 추가 호환성 getters
|
||||
ModelDto? get modelDto => model; // stock_in_form 등에서 사용
|
||||
|
||||
// 기존 레거시 호환성 필드들 (Deprecated - 하위 호환성 위해 유지)
|
||||
@Deprecated('Use equipmentNumber instead')
|
||||
String get name => equipmentNumber;
|
||||
@Deprecated('Use category1 instead')
|
||||
@@ -43,12 +53,9 @@ class Equipment {
|
||||
|
||||
Equipment({
|
||||
this.id,
|
||||
required this.manufacturer,
|
||||
this.modelsId, // Sprint 3: 새로운 FK
|
||||
this.model, // Sprint 3: Model 관계
|
||||
required this.equipmentNumber, // 메인 필드
|
||||
required this.modelName, // 메인 필드
|
||||
required this.category1, // 메인 필드
|
||||
required this.category2, // 메인 필드
|
||||
required this.category3, // 메인 필드
|
||||
this.serialNumber,
|
||||
this.barcode,
|
||||
required this.quantity,
|
||||
@@ -68,17 +75,69 @@ class Equipment {
|
||||
this.equipmentStatus,
|
||||
this.companyId,
|
||||
});
|
||||
|
||||
// Sprint 3: Legacy 데이터 변환용 팩토리 (임시 - 마이그레이션 기간 동안만 사용)
|
||||
factory Equipment.fromLegacy({
|
||||
int? id,
|
||||
required String manufacturer,
|
||||
required String equipmentNumber,
|
||||
required String modelName,
|
||||
required String category1,
|
||||
required String category2,
|
||||
required String category3,
|
||||
String? serialNumber,
|
||||
String? barcode,
|
||||
required int quantity,
|
||||
DateTime? purchaseDate,
|
||||
double? purchasePrice,
|
||||
DateTime? inDate,
|
||||
String? remark,
|
||||
String? warrantyLicense,
|
||||
DateTime? warrantyStartDate,
|
||||
DateTime? warrantyEndDate,
|
||||
int? currentCompanyId,
|
||||
int? warehouseLocationId,
|
||||
int? currentBranchId,
|
||||
DateTime? lastInspectionDate,
|
||||
DateTime? nextInspectionDate,
|
||||
String? equipmentStatus,
|
||||
int? companyId,
|
||||
}) {
|
||||
// Legacy 데이터를 새로운 구조로 변환
|
||||
// TODO: 실제 Vendor/Model 매핑 로직 추가 필요
|
||||
return Equipment(
|
||||
id: id,
|
||||
modelsId: null, // Legacy 데이터는 models_id 없음
|
||||
model: null, // Legacy 데이터는 model 관계 없음
|
||||
equipmentNumber: equipmentNumber,
|
||||
serialNumber: serialNumber,
|
||||
barcode: barcode,
|
||||
quantity: quantity,
|
||||
purchaseDate: purchaseDate,
|
||||
purchasePrice: purchasePrice,
|
||||
inDate: inDate,
|
||||
remark: remark,
|
||||
warrantyLicense: warrantyLicense,
|
||||
warrantyStartDate: warrantyStartDate,
|
||||
warrantyEndDate: warrantyEndDate,
|
||||
currentCompanyId: currentCompanyId,
|
||||
warehouseLocationId: warehouseLocationId,
|
||||
currentBranchId: currentBranchId,
|
||||
lastInspectionDate: lastInspectionDate,
|
||||
nextInspectionDate: nextInspectionDate,
|
||||
equipmentStatus: equipmentStatus,
|
||||
companyId: companyId,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'manufacturer': manufacturer,
|
||||
// Sprint 3: 새로운 FK 관계 필드들
|
||||
'models_id': modelsId,
|
||||
'model': model?.toJson(),
|
||||
// 메인 필드들 (백엔드 API 호환)
|
||||
'equipmentNumber': equipmentNumber,
|
||||
'modelName': modelName,
|
||||
'category1': category1,
|
||||
'category2': category2,
|
||||
'category3': category3,
|
||||
'serialNumber': serialNumber,
|
||||
'barcode': barcode,
|
||||
'quantity': quantity,
|
||||
@@ -108,13 +167,10 @@ class Equipment {
|
||||
factory Equipment.fromJson(Map<String, dynamic> json) {
|
||||
return Equipment(
|
||||
id: json['id'],
|
||||
manufacturer: json['manufacturer'] ?? '',
|
||||
modelsId: json['models_id'] ?? json['modelsId'],
|
||||
model: json['model'] != null ? ModelDto.fromJson(json['model']) : null,
|
||||
// 메인 필드들 - 백엔드 우선, 레거시 fallback
|
||||
equipmentNumber: json['equipmentNumber'] ?? json['name'] ?? '',
|
||||
modelName: json['modelName'] ?? json['model'] ?? '',
|
||||
category1: json['category1'] ?? json['category'] ?? '',
|
||||
category2: json['category2'] ?? json['subCategory'] ?? '',
|
||||
category3: json['category3'] ?? json['subSubCategory'] ?? '',
|
||||
serialNumber: json['serialNumber'],
|
||||
barcode: json['barcode'],
|
||||
quantity: json['quantity'] ?? 0,
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
class License {
|
||||
final int? id;
|
||||
final String licenseKey;
|
||||
final String? productName;
|
||||
final String? vendor;
|
||||
final String? licenseType;
|
||||
final int? userCount;
|
||||
final DateTime? purchaseDate;
|
||||
final DateTime? expiryDate;
|
||||
final double? purchasePrice;
|
||||
final int? companyId;
|
||||
final int? branchId;
|
||||
final int? assignedUserId;
|
||||
final String? remark;
|
||||
final bool isActive;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
// 조인된 데이터 필드
|
||||
final String? companyName;
|
||||
final String? branchName;
|
||||
final String? assignedUserName;
|
||||
|
||||
// 계산 필드
|
||||
int? get daysUntilExpiry {
|
||||
if (expiryDate == null) return null;
|
||||
return expiryDate!.difference(DateTime.now()).inDays;
|
||||
}
|
||||
|
||||
bool get isExpired {
|
||||
if (expiryDate == null) return false;
|
||||
return expiryDate!.isBefore(DateTime.now());
|
||||
}
|
||||
|
||||
String get status {
|
||||
if (!isActive) return 'inactive';
|
||||
if (isExpired) return 'expired';
|
||||
if (daysUntilExpiry != null && daysUntilExpiry! <= 30) return 'expiring';
|
||||
return 'active';
|
||||
}
|
||||
|
||||
License({
|
||||
this.id,
|
||||
required this.licenseKey,
|
||||
this.productName,
|
||||
this.vendor,
|
||||
this.licenseType,
|
||||
this.userCount,
|
||||
this.purchaseDate,
|
||||
this.expiryDate,
|
||||
this.purchasePrice,
|
||||
this.companyId,
|
||||
this.branchId,
|
||||
this.assignedUserId,
|
||||
this.remark,
|
||||
this.isActive = true,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.companyName,
|
||||
this.branchName,
|
||||
this.assignedUserName,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'license_key': licenseKey,
|
||||
'product_name': productName,
|
||||
'vendor': vendor,
|
||||
'license_type': licenseType,
|
||||
'user_count': userCount,
|
||||
'purchase_date': purchaseDate?.toIso8601String(),
|
||||
'expiry_date': expiryDate?.toIso8601String(),
|
||||
'purchase_price': purchasePrice,
|
||||
'company_id': companyId,
|
||||
'branch_id': branchId,
|
||||
'assigned_user_id': assignedUserId,
|
||||
'remark': remark,
|
||||
'is_active': isActive,
|
||||
'created_at': createdAt?.toIso8601String(),
|
||||
'updated_at': updatedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
factory License.fromJson(Map<String, dynamic> json) {
|
||||
return License(
|
||||
id: json['id'] as int?,
|
||||
licenseKey: json['license_key'] as String,
|
||||
productName: json['product_name'] as String?,
|
||||
vendor: json['vendor'] as String?,
|
||||
licenseType: json['license_type'] as String?,
|
||||
userCount: json['user_count'] as int?,
|
||||
purchaseDate: json['purchase_date'] != null
|
||||
? DateTime.parse(json['purchase_date'] as String) : null,
|
||||
expiryDate: json['expiry_date'] != null
|
||||
? DateTime.parse(json['expiry_date'] as String) : null,
|
||||
purchasePrice: (json['purchase_price'] as num?)?.toDouble(),
|
||||
companyId: json['company_id'] as int?,
|
||||
branchId: json['branch_id'] as int?,
|
||||
assignedUserId: json['assigned_user_id'] as int?,
|
||||
remark: json['remark'] as String?,
|
||||
isActive: json['is_active'] ?? true,
|
||||
createdAt: json['created_at'] != null
|
||||
? DateTime.parse(json['created_at'] as String) : null,
|
||||
updatedAt: json['updated_at'] != null
|
||||
? DateTime.parse(json['updated_at'] as String) : null,
|
||||
companyName: json['company_name'] as String?,
|
||||
branchName: json['branch_name'] as String?,
|
||||
assignedUserName: json['assigned_user_name'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
License copyWith({
|
||||
int? id,
|
||||
String? licenseKey,
|
||||
String? productName,
|
||||
String? vendor,
|
||||
String? licenseType,
|
||||
int? userCount,
|
||||
DateTime? purchaseDate,
|
||||
DateTime? expiryDate,
|
||||
double? purchasePrice,
|
||||
int? companyId,
|
||||
int? branchId,
|
||||
int? assignedUserId,
|
||||
String? remark,
|
||||
bool? isActive,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
String? companyName,
|
||||
String? branchName,
|
||||
String? assignedUserName,
|
||||
}) {
|
||||
return License(
|
||||
id: id ?? this.id,
|
||||
licenseKey: licenseKey ?? this.licenseKey,
|
||||
productName: productName ?? this.productName,
|
||||
vendor: vendor ?? this.vendor,
|
||||
licenseType: licenseType ?? this.licenseType,
|
||||
userCount: userCount ?? this.userCount,
|
||||
purchaseDate: purchaseDate ?? this.purchaseDate,
|
||||
expiryDate: expiryDate ?? this.expiryDate,
|
||||
purchasePrice: purchasePrice ?? this.purchasePrice,
|
||||
companyId: companyId ?? this.companyId,
|
||||
branchId: branchId ?? this.branchId,
|
||||
assignedUserId: assignedUserId ?? this.assignedUserId,
|
||||
remark: remark ?? this.remark,
|
||||
isActive: isActive ?? this.isActive,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
companyName: companyName ?? this.companyName,
|
||||
branchName: branchName ?? this.branchName,
|
||||
assignedUserName: assignedUserName ?? this.assignedUserName,
|
||||
);
|
||||
}
|
||||
|
||||
// Mock 데이터 호환을 위한 추가 getter (기존 코드 호환)
|
||||
String get name => productName ?? licenseKey;
|
||||
int get durationMonths => 12; // 기본값
|
||||
String get visitCycle => '월'; // 기본값
|
||||
}
|
||||
Reference in New Issue
Block a user