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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'package:superport/data/models/equipment/equipment_out_request.dart';
|
||||
import 'package:superport/data/models/equipment/equipment_request.dart';
|
||||
import 'package:superport/data/models/equipment/equipment_response.dart';
|
||||
import 'package:superport/models/equipment_unified_model.dart';
|
||||
import 'package:superport/utils/constants.dart';
|
||||
|
||||
class EquipmentService {
|
||||
final EquipmentRemoteDataSource _remoteDataSource = GetIt.instance<EquipmentRemoteDataSource>();
|
||||
@@ -34,9 +33,9 @@ class EquipmentService {
|
||||
|
||||
return dtoList.map((dto) => _convertListDtoToEquipment(dto)).toList();
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch equipment list: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch equipment list: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +58,9 @@ class EquipmentService {
|
||||
final response = await _remoteDataSource.createEquipment(request);
|
||||
return _convertResponseToEquipment(response);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to create equipment: $e');
|
||||
throw ServerFailure(message: 'Failed to create equipment: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,11 +70,16 @@ class EquipmentService {
|
||||
final response = await _remoteDataSource.getEquipmentDetail(id);
|
||||
return _convertResponseToEquipment(response);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch equipment detail: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch equipment detail: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 장비 조회 (getEquipmentDetail의 alias)
|
||||
Future<Equipment> getEquipment(int id) async {
|
||||
return getEquipmentDetail(id);
|
||||
}
|
||||
|
||||
// 장비 수정
|
||||
Future<Equipment> updateEquipment(int id, Equipment equipment) async {
|
||||
@@ -96,9 +100,9 @@ class EquipmentService {
|
||||
final response = await _remoteDataSource.updateEquipment(id, request);
|
||||
return _convertResponseToEquipment(response);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to update equipment: $e');
|
||||
throw ServerFailure(message: 'Failed to update equipment: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +111,9 @@ class EquipmentService {
|
||||
try {
|
||||
await _remoteDataSource.deleteEquipment(id);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to delete equipment: $e');
|
||||
throw ServerFailure(message: 'Failed to delete equipment: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,9 +123,9 @@ class EquipmentService {
|
||||
final response = await _remoteDataSource.changeEquipmentStatus(id, status, reason);
|
||||
return _convertResponseToEquipment(response);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to change equipment status: $e');
|
||||
throw ServerFailure(message: 'Failed to change equipment status: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,9 +141,9 @@ class EquipmentService {
|
||||
|
||||
return await _remoteDataSource.addEquipmentHistory(equipmentId, request);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to add equipment history: $e');
|
||||
throw ServerFailure(message: 'Failed to add equipment history: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,9 +152,9 @@ class EquipmentService {
|
||||
try {
|
||||
return await _remoteDataSource.getEquipmentHistory(equipmentId, page: page, perPage: perPage);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to fetch equipment history: $e');
|
||||
throw ServerFailure(message: 'Failed to fetch equipment history: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,9 +175,9 @@ class EquipmentService {
|
||||
|
||||
return await _remoteDataSource.equipmentIn(request);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to process equipment in: $e');
|
||||
throw ServerFailure(message: 'Failed to process equipment in: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,9 +200,9 @@ class EquipmentService {
|
||||
|
||||
return await _remoteDataSource.equipmentOut(request);
|
||||
} on ServerException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: 'Failed to process equipment out: $e');
|
||||
throw ServerFailure(message: 'Failed to process equipment out: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ import 'package:superport/models/license_model.dart';
|
||||
|
||||
@lazySingleton
|
||||
class LicenseService {
|
||||
final LicenseRemoteDataSource _remoteDataSource = GetIt.instance<LicenseRemoteDataSource>();
|
||||
final LicenseRemoteDataSource _remoteDataSource;
|
||||
|
||||
LicenseService(this._remoteDataSource);
|
||||
|
||||
// 라이선스 목록 조회
|
||||
Future<List<License>> getLicenses({
|
||||
@@ -32,9 +34,9 @@ class LicenseService {
|
||||
|
||||
return response.items.map((dto) => _convertDtoToLicense(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 목록을 불러오는 데 실패했습니다: $e');
|
||||
throw ServerFailure(message: '라이선스 목록을 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,36 +46,35 @@ class LicenseService {
|
||||
final dto = await _remoteDataSource.getLicenseById(id);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 정보를 불러오는 데 실패했습니다: $e');
|
||||
throw ServerFailure(message: '라이선스 정보를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 라이선스 생성
|
||||
Future<License> createLicense(License license) async {
|
||||
try {
|
||||
// Flutter 모델의 visitCycle과 durationMonths를 API 필드에 매핑
|
||||
// visitCycle은 remark에 저장하고, durationMonths는 날짜 계산에 사용
|
||||
final now = DateTime.now();
|
||||
final expiryDate = now.add(Duration(days: license.durationMonths * 30));
|
||||
|
||||
final request = CreateLicenseRequest(
|
||||
licenseKey: license.name, // name을 licenseKey로 매핑
|
||||
productName: '유지보수 계약', // 기본값 설정
|
||||
licenseType: 'maintenance', // 유지보수 타입으로 고정
|
||||
licenseKey: license.licenseKey,
|
||||
productName: license.productName,
|
||||
vendor: license.vendor,
|
||||
licenseType: license.licenseType,
|
||||
userCount: license.userCount,
|
||||
purchaseDate: license.purchaseDate,
|
||||
expiryDate: license.expiryDate,
|
||||
purchasePrice: license.purchasePrice,
|
||||
companyId: license.companyId,
|
||||
purchaseDate: now,
|
||||
expiryDate: expiryDate,
|
||||
remark: '방문주기: ${license.visitCycle}', // visitCycle을 remark에 저장
|
||||
branchId: license.branchId,
|
||||
remark: license.remark,
|
||||
);
|
||||
|
||||
final dto = await _remoteDataSource.createLicense(request);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 생성에 실패했습니다: $e');
|
||||
throw ServerFailure(message: '라이선스 생성에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,30 +82,28 @@ class LicenseService {
|
||||
Future<License> updateLicense(License license) async {
|
||||
try {
|
||||
if (license.id == null) {
|
||||
throw Failure(message: '라이선스 ID가 없습니다');
|
||||
}
|
||||
|
||||
// 기존 라이선스 정보를 먼저 조회
|
||||
final existingDto = await _remoteDataSource.getLicenseById(license.id!);
|
||||
|
||||
// 만료일 계산 (durationMonths가 변경된 경우)
|
||||
DateTime? newExpiryDate;
|
||||
if (existingDto.purchaseDate != null) {
|
||||
newExpiryDate = existingDto.purchaseDate!.add(Duration(days: license.durationMonths * 30));
|
||||
throw BusinessFailure(message: '라이선스 ID가 없습니다');
|
||||
}
|
||||
|
||||
final request = UpdateLicenseRequest(
|
||||
licenseKey: license.name,
|
||||
expiryDate: newExpiryDate,
|
||||
remark: '방문주기: ${license.visitCycle}',
|
||||
licenseKey: license.licenseKey,
|
||||
productName: license.productName,
|
||||
vendor: license.vendor,
|
||||
licenseType: license.licenseType,
|
||||
userCount: license.userCount,
|
||||
purchaseDate: license.purchaseDate,
|
||||
expiryDate: license.expiryDate,
|
||||
purchasePrice: license.purchasePrice,
|
||||
remark: license.remark,
|
||||
isActive: license.isActive,
|
||||
);
|
||||
|
||||
final dto = await _remoteDataSource.updateLicense(license.id!, request);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 수정에 실패했습니다: $e');
|
||||
throw ServerFailure(message: '라이선스 수정에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +112,9 @@ class LicenseService {
|
||||
try {
|
||||
await _remoteDataSource.deleteLicense(id);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 삭제에 실패했습니다: $e');
|
||||
throw ServerFailure(message: '라이선스 삭제에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,9 +125,9 @@ class LicenseService {
|
||||
final dto = await _remoteDataSource.assignLicense(licenseId, request);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 할당에 실패했습니다: $e');
|
||||
throw ServerFailure(message: '라이선스 할당에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +137,9 @@ class LicenseService {
|
||||
final dto = await _remoteDataSource.unassignLicense(licenseId);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 할당 해제에 실패했습니다: $e');
|
||||
throw ServerFailure(message: '라이선스 할당 해제에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,33 +158,34 @@ class LicenseService {
|
||||
|
||||
return response.items.map((dto) => _convertExpiringDtoToLicense(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '만료 예정 라이선스를 불러오는 데 실패했습니다: $e');
|
||||
throw ServerFailure(message: '만료 예정 라이선스를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// DTO를 Flutter 모델로 변환
|
||||
License _convertDtoToLicense(LicenseDto dto) {
|
||||
// remark에서 방문주기 추출
|
||||
String visitCycle = '미방문'; // 기본값
|
||||
if (dto.remark != null && dto.remark!.contains('방문주기:')) {
|
||||
visitCycle = dto.remark!.split('방문주기:').last.trim();
|
||||
}
|
||||
|
||||
// 기간 계산 (purchaseDate와 expiryDate 차이)
|
||||
int durationMonths = 12; // 기본값
|
||||
if (dto.purchaseDate != null && dto.expiryDate != null) {
|
||||
final difference = dto.expiryDate!.difference(dto.purchaseDate!);
|
||||
durationMonths = (difference.inDays / 30).round();
|
||||
}
|
||||
|
||||
return License(
|
||||
id: dto.id,
|
||||
companyId: dto.companyId ?? 0,
|
||||
name: dto.licenseKey,
|
||||
durationMonths: durationMonths,
|
||||
visitCycle: visitCycle,
|
||||
licenseKey: dto.licenseKey,
|
||||
productName: dto.productName,
|
||||
vendor: dto.vendor,
|
||||
licenseType: dto.licenseType,
|
||||
userCount: dto.userCount,
|
||||
purchaseDate: dto.purchaseDate,
|
||||
expiryDate: dto.expiryDate,
|
||||
purchasePrice: dto.purchasePrice,
|
||||
companyId: dto.companyId,
|
||||
branchId: dto.branchId,
|
||||
assignedUserId: dto.assignedUserId,
|
||||
remark: dto.remark,
|
||||
isActive: dto.isActive,
|
||||
createdAt: dto.createdAt,
|
||||
updatedAt: dto.updatedAt,
|
||||
companyName: dto.companyName,
|
||||
branchName: dto.branchName,
|
||||
assignedUserName: dto.assignedUserName,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -193,10 +193,24 @@ class LicenseService {
|
||||
License _convertExpiringDtoToLicense(ExpiringLicenseDto dto) {
|
||||
return License(
|
||||
id: dto.id,
|
||||
companyId: 0, // ExpiringLicenseDto에는 companyId가 없으므로 기본값 사용
|
||||
name: dto.licenseKey,
|
||||
durationMonths: 12, // 기본값
|
||||
visitCycle: '미방문', // 기본값
|
||||
licenseKey: dto.licenseKey,
|
||||
productName: dto.productName,
|
||||
vendor: null,
|
||||
licenseType: null,
|
||||
userCount: null,
|
||||
purchaseDate: null,
|
||||
expiryDate: dto.expiryDate,
|
||||
purchasePrice: null,
|
||||
companyId: null,
|
||||
branchId: null,
|
||||
assignedUserId: null,
|
||||
remark: null,
|
||||
isActive: dto.isActive,
|
||||
createdAt: null,
|
||||
updatedAt: null,
|
||||
companyName: dto.companyName,
|
||||
branchName: null,
|
||||
assignedUserName: null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -570,10 +570,12 @@ class MockDataService {
|
||||
for (final inspection in inspectionTypes) {
|
||||
addLicense(
|
||||
License(
|
||||
licenseKey: 'LIC-${DateTime.now().millisecondsSinceEpoch}-$visit-$inspection',
|
||||
productName: '12개월,$visit,$inspection',
|
||||
companyId: 1,
|
||||
name: '12개월,$visit,$inspection',
|
||||
durationMonths: 12,
|
||||
visitCycle: visit,
|
||||
purchaseDate: DateTime.now(),
|
||||
expiryDate: DateTime.now().add(const Duration(days: 365)),
|
||||
remark: '방문주기: $visit',
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -672,12 +674,12 @@ class MockDataService {
|
||||
|
||||
// 기존 입고 장비를 출고 상태로 변경
|
||||
void changeEquipmentStatus(int equipmentInId, EquipmentOut equipmentOut) {
|
||||
print('장비 상태 변경 시작: 입고 ID $equipmentInId');
|
||||
// 장비 상태 변경 시작: 입고 ID $equipmentInId
|
||||
|
||||
// 입고된 장비를 찾습니다
|
||||
final index = _equipmentIns.indexWhere((e) => e.id == equipmentInId);
|
||||
if (index != -1) {
|
||||
print('장비를 찾음: ${_equipmentIns[index].equipment.name}');
|
||||
// 장비를 찾음: ${_equipmentIns[index].equipment.name}
|
||||
|
||||
// 입고 장비의 상태를 출고(O)로 변경
|
||||
final equipment = _equipmentIns[index].equipment;
|
||||
@@ -687,7 +689,7 @@ class MockDataService {
|
||||
inDate: _equipmentIns[index].inDate,
|
||||
status: 'O', // 상태를 출고로 변경
|
||||
);
|
||||
print('입고 장비 상태를 "O"로 변경: ID ${_equipmentIns[index].id}');
|
||||
// 입고 장비 상태를 "O"로 변경: ID ${_equipmentIns[index].id}
|
||||
|
||||
// 출고 정보 저장
|
||||
final newEquipmentOut = EquipmentOut(
|
||||
@@ -702,11 +704,11 @@ class MockDataService {
|
||||
returnType: equipmentOut.returnType,
|
||||
);
|
||||
_equipmentOuts.add(newEquipmentOut);
|
||||
print('출고 정보 추가: ID ${newEquipmentOut.id}');
|
||||
// 출고 정보 추가: ID ${newEquipmentOut.id}
|
||||
|
||||
print('장비 상태 변경 완료');
|
||||
// 장비 상태 변경 완료
|
||||
} else {
|
||||
print('오류: ID $equipmentInId인 입고 장비를 찾을 수 없음');
|
||||
// 오류: ID $equipmentInId인 입고 장비를 찾을 수 없음
|
||||
}
|
||||
}
|
||||
|
||||
@@ -885,6 +887,19 @@ class MockDataService {
|
||||
_companies[index] = company;
|
||||
}
|
||||
}
|
||||
|
||||
void updateBranch(int companyId, Branch branch) {
|
||||
final companyIndex = _companies.indexWhere((c) => c.id == companyId);
|
||||
if (companyIndex != -1) {
|
||||
final company = _companies[companyIndex];
|
||||
if (company.branches != null) {
|
||||
final branchIndex = company.branches!.indexWhere((b) => b.id == branch.id);
|
||||
if (branchIndex != -1) {
|
||||
company.branches![branchIndex] = branch;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void deleteCompany(int id) {
|
||||
_companies.removeWhere((c) => c.id == id);
|
||||
@@ -944,10 +959,19 @@ class MockDataService {
|
||||
void addLicense(License license) {
|
||||
final newLicense = License(
|
||||
id: _licenseIdCounter++,
|
||||
licenseKey: license.licenseKey,
|
||||
productName: license.productName,
|
||||
vendor: license.vendor,
|
||||
licenseType: license.licenseType,
|
||||
userCount: license.userCount,
|
||||
purchaseDate: license.purchaseDate,
|
||||
expiryDate: license.expiryDate,
|
||||
purchasePrice: license.purchasePrice,
|
||||
companyId: license.companyId,
|
||||
name: license.name,
|
||||
durationMonths: license.durationMonths,
|
||||
visitCycle: license.visitCycle,
|
||||
branchId: license.branchId,
|
||||
assignedUserId: license.assignedUserId,
|
||||
remark: license.remark,
|
||||
isActive: license.isActive,
|
||||
);
|
||||
_licenses.add(newLicense);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:superport/core/errors/exceptions.dart';
|
||||
import 'package:superport/data/datasources/remote/user_remote_datasource.dart';
|
||||
import 'package:superport/data/models/user/user_dto.dart';
|
||||
import 'package:superport/models/user_model.dart';
|
||||
|
||||
@@ -26,9 +26,9 @@ class WarehouseService {
|
||||
|
||||
return response.items.map((dto) => _convertDtoToWarehouseLocation(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 목록을 불러오는 데 실패했습니다: $e');
|
||||
throw ServerFailure(message: '창고 위치 목록을 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ class WarehouseService {
|
||||
final dto = await _remoteDataSource.getWarehouseLocationById(id);
|
||||
return _convertDtoToWarehouseLocation(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 정보를 불러오는 데 실패했습니다: $e');
|
||||
throw ServerFailure(message: '창고 위치 정보를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ class WarehouseService {
|
||||
final dto = await _remoteDataSource.createWarehouseLocation(request);
|
||||
return _convertDtoToWarehouseLocation(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 생성에 실패했습니다: $e');
|
||||
throw ServerFailure(message: '창고 위치 생성에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ class WarehouseService {
|
||||
final dto = await _remoteDataSource.updateWarehouseLocation(location.id, request);
|
||||
return _convertDtoToWarehouseLocation(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 수정에 실패했습니다: $e');
|
||||
throw ServerFailure(message: '창고 위치 수정에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ class WarehouseService {
|
||||
try {
|
||||
await _remoteDataSource.deleteWarehouseLocation(id);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 삭제에 실패했습니다: $e');
|
||||
throw ServerFailure(message: '창고 위치 삭제에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,9 +118,9 @@ class WarehouseService {
|
||||
'storedAt': dto.storedAt,
|
||||
}).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 장비 목록을 불러오는 데 실패했습니다: $e');
|
||||
throw ServerFailure(message: '창고 장비 목록을 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ class WarehouseService {
|
||||
try {
|
||||
return await _remoteDataSource.getWarehouseCapacity(id);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 용량 정보를 불러오는 데 실패했습니다: $e');
|
||||
throw ServerFailure(message: '창고 용량 정보를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +141,9 @@ class WarehouseService {
|
||||
final dtos = await _remoteDataSource.getInUseWarehouseLocations();
|
||||
return dtos.map((dto) => _convertDtoToWarehouseLocation(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '사용 중인 창고 위치를 불러오는 데 실패했습니다: $e');
|
||||
throw ServerFailure(message: '사용 중인 창고 위치를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user