backup: 사용하지 않는 파일 삭제 전 복구 지점
- 전체 371개 파일 중 82개 미사용 파일 식별 - Phase 1: 33개 파일 삭제 예정 (100% 안전) - Phase 2: 30개 파일 삭제 검토 예정 - Phase 3: 19개 파일 수동 검토 예정 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ abstract class EquipmentRemoteDataSource {
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
String? search,
|
||||
int? companyId,
|
||||
});
|
||||
|
||||
Future<EquipmentDto> createEquipment(EquipmentRequestDto request);
|
||||
@@ -19,22 +20,56 @@ abstract class EquipmentRemoteDataSource {
|
||||
Future<EquipmentDto> updateEquipment(int id, EquipmentUpdateRequestDto request);
|
||||
|
||||
Future<void> deleteEquipment(int id);
|
||||
|
||||
Future<EquipmentDto> restoreEquipment(int id);
|
||||
|
||||
Future<EquipmentDto> getEquipmentBySerial(String serial);
|
||||
|
||||
Future<EquipmentDto> getEquipmentByBarcode(String barcode);
|
||||
|
||||
Future<List<EquipmentDto>> getEquipmentsByCompany(int companyId);
|
||||
}
|
||||
|
||||
class EquipmentRemoteDataSourceImpl implements EquipmentRemoteDataSource {
|
||||
final ApiClient _apiClient = GetIt.instance<ApiClient>();
|
||||
|
||||
/// DioException을 ServerException으로 변환하는 헬퍼 메서드
|
||||
Never _handleDioException(DioException e) {
|
||||
String errorMessage = 'Network error occurred';
|
||||
|
||||
if (e.response?.data != null) {
|
||||
// 응답 데이터가 Map인 경우 (JSON 에러)
|
||||
if (e.response!.data is Map<String, dynamic>) {
|
||||
final errorData = e.response!.data as Map<String, dynamic>;
|
||||
errorMessage = errorData['error']?['message'] ??
|
||||
errorData['message'] ??
|
||||
'Server error occurred';
|
||||
}
|
||||
// 응답 데이터가 String인 경우 (Plain text 에러)
|
||||
else if (e.response!.data is String) {
|
||||
errorMessage = e.response!.data as String;
|
||||
}
|
||||
}
|
||||
|
||||
throw ServerException(
|
||||
message: errorMessage,
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<EquipmentListResponse> getEquipments({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
String? search,
|
||||
int? companyId,
|
||||
}) async {
|
||||
try {
|
||||
final queryParams = <String, dynamic>{
|
||||
'page': page,
|
||||
'page_size': perPage,
|
||||
if (search != null && search.isNotEmpty) 'search': search,
|
||||
if (companyId != null) 'company_id': companyId,
|
||||
};
|
||||
|
||||
final response = await _apiClient.get(
|
||||
@@ -48,10 +83,7 @@ class EquipmentRemoteDataSourceImpl implements EquipmentRemoteDataSource {
|
||||
final Map<String, dynamic> responseData = response.data;
|
||||
return EquipmentListResponse.fromJson(responseData);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
message: e.response?.data['message'] ?? 'Network error occurred',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
_handleDioException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,10 +106,7 @@ class EquipmentRemoteDataSourceImpl implements EquipmentRemoteDataSource {
|
||||
return EquipmentDto.fromJson(responseData);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
message: e.response?.data['message'] ?? 'Network error occurred',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
_handleDioException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,10 +126,7 @@ class EquipmentRemoteDataSourceImpl implements EquipmentRemoteDataSource {
|
||||
return EquipmentDto.fromJson(responseData);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
message: e.response?.data['message'] ?? 'Network error occurred',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
_handleDioException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,10 +159,7 @@ class EquipmentRemoteDataSourceImpl implements EquipmentRemoteDataSource {
|
||||
return EquipmentDto.fromJson(responseData);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
message: e.response?.data['message'] ?? 'Network error occurred',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
_handleDioException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,9 +167,74 @@ class EquipmentRemoteDataSourceImpl implements EquipmentRemoteDataSource {
|
||||
Future<void> deleteEquipment(int id) async {
|
||||
try {
|
||||
await _apiClient.delete('${ApiEndpoints.equipment}/$id');
|
||||
} on DioException catch (e) {
|
||||
_handleDioException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<EquipmentDto> restoreEquipment(int id) async {
|
||||
try {
|
||||
final response = await _apiClient.put('${ApiEndpoints.equipment}/$id/restore');
|
||||
|
||||
// 백엔드 응답 구조에 따라 data 필드에서 추출
|
||||
final responseData = response.data;
|
||||
return EquipmentDto.fromJson(responseData['data'] ?? responseData);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
message: e.response?.data['message'] ?? 'Network error occurred',
|
||||
message: e.response?.data['message'] ?? 'Failed to restore equipment',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<EquipmentDto> getEquipmentBySerial(String serial) async {
|
||||
try {
|
||||
final response = await _apiClient.get('${ApiEndpoints.equipment}/serial/$serial');
|
||||
|
||||
// 백엔드 응답 구조에 따라 data 필드에서 추출
|
||||
final responseData = response.data;
|
||||
return EquipmentDto.fromJson(responseData['data'] ?? responseData);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
message: e.response?.data['message'] ?? 'Equipment not found by serial',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<EquipmentDto> getEquipmentByBarcode(String barcode) async {
|
||||
try {
|
||||
final response = await _apiClient.get('${ApiEndpoints.equipment}/barcode/$barcode');
|
||||
|
||||
// 백엔드 응답 구조에 따라 data 필드에서 추출
|
||||
final responseData = response.data;
|
||||
return EquipmentDto.fromJson(responseData['data'] ?? responseData);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
message: e.response?.data['message'] ?? 'Equipment not found by barcode',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<EquipmentDto>> getEquipmentsByCompany(int companyId) async {
|
||||
try {
|
||||
final response = await _apiClient.get('${ApiEndpoints.equipment}/by-company/$companyId');
|
||||
|
||||
print('[Equipment API] Company Filter Response: ${response.data}');
|
||||
|
||||
// 백엔드 응답 구조에 따라 data 필드에서 추출
|
||||
final responseData = response.data;
|
||||
final List<dynamic> equipmentList = responseData['data'] ?? responseData;
|
||||
|
||||
return equipmentList.map((json) => EquipmentDto.fromJson(json)).toList();
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
message: e.response?.data['message'] ?? 'Failed to get equipments by company',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user