## 주요 변경사항 - Company, Equipment, License, Warehouse Location 모든 화면에 소프트 딜리트 구현 - 관리자 권한으로 삭제된 데이터 조회 가능 (includeInactive 파라미터) - 데이터 무결성 보장을 위한 논리 삭제 시스템 완성 ## 기능 개선 - 각 리스트 컨트롤러에 toggleIncludeInactive() 메서드 추가 - UI에 "비활성 포함" 체크박스 추가 (관리자 전용) - API 데이터소스에 includeInactive 파라미터 지원 ## 문서 정리 - 불필요한 문서 파일 제거 및 재구성 - CLAUDE.md 프로젝트 상태 업데이트 (진행률 80%) - 테스트 결과 문서화 (test20250812v01.md) ## UI 컴포넌트 - Equipment 화면 위젯 모듈화 (custom_dropdown_field, equipment_basic_info_section) - 폼 유효성 검증 강화 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
229 lines
7.0 KiB
Dart
229 lines
7.0 KiB
Dart
import 'package:injectable/injectable.dart';
|
|
import 'package:superport/core/constants/api_endpoints.dart';
|
|
import 'package:superport/core/errors/exceptions.dart';
|
|
import 'package:superport/data/datasources/remote/api_client.dart';
|
|
import 'package:superport/data/models/warehouse/warehouse_dto.dart';
|
|
|
|
abstract class WarehouseRemoteDataSource {
|
|
Future<WarehouseLocationListDto> getWarehouseLocations({
|
|
int page = 1,
|
|
int perPage = 20,
|
|
bool? isActive,
|
|
String? search,
|
|
bool includeInactive = false,
|
|
});
|
|
|
|
Future<WarehouseLocationDto> getWarehouseLocationById(int id);
|
|
Future<WarehouseLocationDto> createWarehouseLocation(CreateWarehouseLocationRequest request);
|
|
Future<WarehouseLocationDto> updateWarehouseLocation(int id, UpdateWarehouseLocationRequest request);
|
|
Future<void> deleteWarehouseLocation(int id);
|
|
Future<WarehouseEquipmentListDto> getWarehouseEquipment(
|
|
int warehouseId, {
|
|
int page = 1,
|
|
int perPage = 20,
|
|
});
|
|
Future<WarehouseCapacityInfo> getWarehouseCapacity(int id);
|
|
Future<List<WarehouseLocationDto>> getInUseWarehouseLocations();
|
|
}
|
|
|
|
@LazySingleton(as: WarehouseRemoteDataSource)
|
|
class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
|
|
final ApiClient _apiClient;
|
|
|
|
WarehouseRemoteDataSourceImpl({
|
|
required ApiClient apiClient,
|
|
}) : _apiClient = apiClient;
|
|
|
|
@override
|
|
Future<WarehouseLocationListDto> getWarehouseLocations({
|
|
int page = 1,
|
|
int perPage = 20,
|
|
bool? isActive,
|
|
String? search,
|
|
bool includeInactive = false,
|
|
}) async {
|
|
try {
|
|
final queryParams = <String, dynamic>{
|
|
'page': page,
|
|
'per_page': perPage,
|
|
};
|
|
|
|
if (isActive != null) queryParams['is_active'] = isActive;
|
|
if (search != null && search.isNotEmpty) queryParams['search'] = search;
|
|
queryParams['include_inactive'] = includeInactive;
|
|
|
|
final response = await _apiClient.get(
|
|
ApiEndpoints.warehouseLocations,
|
|
queryParameters: queryParams,
|
|
);
|
|
|
|
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
|
// API 응답 구조를 DTO에 맞게 변환
|
|
final List<dynamic> dataList = response.data['data'];
|
|
final pagination = response.data['pagination'] ?? {};
|
|
|
|
final listData = {
|
|
'items': dataList,
|
|
'total': pagination['total'] ?? 0,
|
|
'page': pagination['page'] ?? 1,
|
|
'per_page': pagination['per_page'] ?? 20,
|
|
'total_pages': pagination['total_pages'] ?? 1,
|
|
};
|
|
|
|
return WarehouseLocationListDto.fromJson(listData);
|
|
} else {
|
|
throw ApiException(
|
|
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse locations',
|
|
);
|
|
}
|
|
} catch (e) {
|
|
throw _handleError(e);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<WarehouseLocationDto> getWarehouseLocationById(int id) async {
|
|
try {
|
|
final response = await _apiClient.get(
|
|
'${ApiEndpoints.warehouseLocations}/$id',
|
|
);
|
|
|
|
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
|
return WarehouseLocationDto.fromJson(response.data['data']);
|
|
} else {
|
|
throw ApiException(
|
|
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse location',
|
|
);
|
|
}
|
|
} catch (e) {
|
|
throw _handleError(e);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<WarehouseLocationDto> createWarehouseLocation(CreateWarehouseLocationRequest request) async {
|
|
try {
|
|
final response = await _apiClient.post(
|
|
ApiEndpoints.warehouseLocations,
|
|
data: request.toJson(),
|
|
);
|
|
|
|
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
|
return WarehouseLocationDto.fromJson(response.data['data']);
|
|
} else {
|
|
throw ApiException(
|
|
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse location',
|
|
);
|
|
}
|
|
} catch (e) {
|
|
throw _handleError(e);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<WarehouseLocationDto> updateWarehouseLocation(int id, UpdateWarehouseLocationRequest request) async {
|
|
try {
|
|
final response = await _apiClient.put(
|
|
'${ApiEndpoints.warehouseLocations}/$id',
|
|
data: request.toJson(),
|
|
);
|
|
|
|
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
|
return WarehouseLocationDto.fromJson(response.data['data']);
|
|
} else {
|
|
throw ApiException(
|
|
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse location',
|
|
);
|
|
}
|
|
} catch (e) {
|
|
throw _handleError(e);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<void> deleteWarehouseLocation(int id) async {
|
|
try {
|
|
await _apiClient.delete(
|
|
'${ApiEndpoints.warehouseLocations}/$id',
|
|
);
|
|
} catch (e) {
|
|
throw _handleError(e);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<WarehouseEquipmentListDto> getWarehouseEquipment(
|
|
int warehouseId, {
|
|
int page = 1,
|
|
int perPage = 20,
|
|
}) async {
|
|
try {
|
|
final queryParams = <String, dynamic>{
|
|
'page': page,
|
|
'per_page': perPage,
|
|
};
|
|
|
|
final response = await _apiClient.get(
|
|
'${ApiEndpoints.warehouseLocations}/$warehouseId/equipment',
|
|
queryParameters: queryParams,
|
|
);
|
|
|
|
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
|
return WarehouseEquipmentListDto.fromJson(response.data['data']);
|
|
} else {
|
|
throw ApiException(
|
|
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse equipment',
|
|
);
|
|
}
|
|
} catch (e) {
|
|
throw _handleError(e);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<WarehouseCapacityInfo> getWarehouseCapacity(int id) async {
|
|
try {
|
|
final response = await _apiClient.get(
|
|
'${ApiEndpoints.warehouseLocations}/$id/capacity',
|
|
);
|
|
|
|
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
|
return WarehouseCapacityInfo.fromJson(response.data['data']);
|
|
} else {
|
|
throw ApiException(
|
|
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse capacity',
|
|
);
|
|
}
|
|
} catch (e) {
|
|
throw _handleError(e);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<List<WarehouseLocationDto>> getInUseWarehouseLocations() async {
|
|
try {
|
|
final response = await _apiClient.get(
|
|
'${ApiEndpoints.warehouseLocations}/in-use',
|
|
);
|
|
|
|
if (response.data != null && response.data['success'] == true && response.data['data'] is List) {
|
|
return (response.data['data'] as List)
|
|
.map((item) => WarehouseLocationDto.fromJson(item))
|
|
.toList();
|
|
} else {
|
|
throw ApiException(message: 'Invalid response format');
|
|
}
|
|
} catch (e) {
|
|
throw _handleError(e);
|
|
}
|
|
}
|
|
|
|
Exception _handleError(dynamic error) {
|
|
if (error is ApiException) {
|
|
return error;
|
|
}
|
|
return ApiException(
|
|
message: error.toString(),
|
|
);
|
|
}
|
|
} |