feat: API 연동 개선 및 라이선스 모델 확장
- 라이선스 모델 전면 개편 (상세 필드 추가, 계산 필드 구현) - API 응답 처리 개선 (HTTP 상태 코드 기반) - 장비 출고 폼 컨트롤러 추가 - 회사 지점 정보 모델 추가 - 공통 데이터 모델 구조 추가 - 전체 서비스 레이어 API 호출 방식 통일 - UI 컴포넌트 마이너 개선
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:superport/core/errors/exceptions.dart';
|
||||
import 'package:superport/core/errors/failures.dart';
|
||||
@@ -32,9 +31,9 @@ class CompanyService {
|
||||
|
||||
return response.items.map((dto) => _convertListDtoToCompany(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch company list: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch company list: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,9 +54,9 @@ class CompanyService {
|
||||
final response = await _remoteDataSource.createCompany(request);
|
||||
return _convertResponseToCompany(response);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to create company: $e');
|
||||
throw ServerFailure(message: 'Failed to create company: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,9 +66,9 @@ class CompanyService {
|
||||
final response = await _remoteDataSource.getCompanyDetail(id);
|
||||
return _convertResponseToCompany(response);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch company detail: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch company detail: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +81,9 @@ class CompanyService {
|
||||
|
||||
return company.copyWith(branches: branches);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch company with branches: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch company with branches: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,9 +104,9 @@ class CompanyService {
|
||||
final response = await _remoteDataSource.updateCompany(id, request);
|
||||
return _convertResponseToCompany(response);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to update company: $e');
|
||||
throw ServerFailure(message: 'Failed to update company: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +115,9 @@ class CompanyService {
|
||||
try {
|
||||
await _remoteDataSource.deleteCompany(id);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to delete company: $e');
|
||||
throw ServerFailure(message: 'Failed to delete company: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,9 +130,9 @@ class CompanyService {
|
||||
'name': dto.name,
|
||||
}).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch company names: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch company names: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,9 +151,9 @@ class CompanyService {
|
||||
final response = await _remoteDataSource.createBranch(companyId, request);
|
||||
return _convertBranchResponseToBranch(response);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to create branch: $e');
|
||||
throw ServerFailure(message: 'Failed to create branch: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,9 +162,9 @@ class CompanyService {
|
||||
final response = await _remoteDataSource.getBranchDetail(companyId, branchId);
|
||||
return _convertBranchResponseToBranch(response);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch branch detail: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch branch detail: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,9 +182,9 @@ class CompanyService {
|
||||
final response = await _remoteDataSource.updateBranch(companyId, branchId, request);
|
||||
return _convertBranchResponseToBranch(response);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to update branch: $e');
|
||||
throw ServerFailure(message: 'Failed to update branch: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,9 +192,9 @@ class CompanyService {
|
||||
try {
|
||||
await _remoteDataSource.deleteBranch(companyId, branchId);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to delete branch: $e');
|
||||
throw ServerFailure(message: 'Failed to delete branch: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,9 +203,9 @@ class CompanyService {
|
||||
final dtoList = await _remoteDataSource.getCompanyBranches(companyId);
|
||||
return dtoList.map((dto) => _convertBranchDtoToBranch(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch company branches: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch company branches: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,9 +214,9 @@ class CompanyService {
|
||||
try {
|
||||
return await _remoteDataSource.getCompaniesWithBranches();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch companies with branches: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch companies with branches: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,9 +225,9 @@ class CompanyService {
|
||||
try {
|
||||
return await _remoteDataSource.checkDuplicateCompany(name);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to check duplicate: $e');
|
||||
throw ServerFailure(message: 'Failed to check duplicate: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,9 +237,9 @@ class CompanyService {
|
||||
final dtoList = await _remoteDataSource.searchCompanies(query);
|
||||
return dtoList.map((dto) => _convertListDtoToCompany(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to search companies: $e');
|
||||
throw ServerFailure(message: 'Failed to search companies: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,9 +248,9 @@ class CompanyService {
|
||||
try {
|
||||
await _remoteDataSource.updateCompanyStatus(id, isActive);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to update company status: $e');
|
||||
throw ServerFailure(message: 'Failed to update company status: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user