feat: API 연동 개선 및 라이선스 모델 확장
- 라이선스 모델 전면 개편 (상세 필드 추가, 계산 필드 구현) - API 응답 처리 개선 (HTTP 상태 코드 기반) - 장비 출고 폼 컨트롤러 추가 - 회사 지점 정보 모델 추가 - 공통 데이터 모델 구조 추가 - 전체 서비스 레이어 API 호출 방식 통일 - UI 컴포넌트 마이너 개선
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:superport/core/constants/api_endpoints.dart';
|
||||
import 'package:superport/core/errors/exceptions.dart';
|
||||
import 'package:superport/core/errors/failures.dart';
|
||||
import 'package:superport/data/datasources/remote/api_client.dart';
|
||||
import 'package:superport/data/models/dashboard/equipment_status_distribution.dart';
|
||||
@@ -32,12 +30,12 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
|
||||
final stats = OverviewStats.fromJson(response.data);
|
||||
return Right(stats);
|
||||
} else {
|
||||
return Left(ServerFailure('응답 데이터가 없습니다'));
|
||||
return Left(ServerFailure(message: '응답 데이터가 없습니다'));
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
return Left(_handleDioError(e));
|
||||
} catch (e) {
|
||||
return Left(ServerFailure('통계 데이터를 가져오는 중 오류가 발생했습니다'));
|
||||
return Left(ServerFailure(message: '통계 데이터를 가져오는 중 오류가 발생했습니다'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +50,12 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
|
||||
.toList();
|
||||
return Right(activities);
|
||||
} else {
|
||||
return Left(ServerFailure('응답 데이터가 올바르지 않습니다'));
|
||||
return Left(ServerFailure(message: '응답 데이터가 올바르지 않습니다'));
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
return Left(_handleDioError(e));
|
||||
} catch (e) {
|
||||
return Left(ServerFailure('최근 활동을 가져오는 중 오류가 발생했습니다'));
|
||||
return Left(ServerFailure(message: '최근 활동을 가져오는 중 오류가 발생했습니다'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +68,12 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
|
||||
final distribution = EquipmentStatusDistribution.fromJson(response.data);
|
||||
return Right(distribution);
|
||||
} else {
|
||||
return Left(ServerFailure('응답 데이터가 없습니다'));
|
||||
return Left(ServerFailure(message: '응답 데이터가 없습니다'));
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
return Left(_handleDioError(e));
|
||||
} catch (e) {
|
||||
return Left(ServerFailure('장비 상태 분포를 가져오는 중 오류가 발생했습니다'));
|
||||
return Left(ServerFailure(message: '장비 상태 분포를 가져오는 중 오류가 발생했습니다'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +91,12 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
|
||||
.toList();
|
||||
return Right(licenses);
|
||||
} else {
|
||||
return Left(ServerFailure('응답 데이터가 올바르지 않습니다'));
|
||||
return Left(ServerFailure(message: '응답 데이터가 올바르지 않습니다'));
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
return Left(_handleDioError(e));
|
||||
} catch (e) {
|
||||
return Left(ServerFailure('만료 예정 라이선스를 가져오는 중 오류가 발생했습니다'));
|
||||
return Left(ServerFailure(message: '만료 예정 라이선스를 가져오는 중 오류가 발생했습니다'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,26 +105,26 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
|
||||
case DioExceptionType.connectionTimeout:
|
||||
case DioExceptionType.sendTimeout:
|
||||
case DioExceptionType.receiveTimeout:
|
||||
return NetworkFailure('네트워크 연결 시간이 초과되었습니다');
|
||||
return NetworkFailure(message: '네트워크 연결 시간이 초과되었습니다');
|
||||
case DioExceptionType.connectionError:
|
||||
return NetworkFailure('서버에 연결할 수 없습니다');
|
||||
return NetworkFailure(message: '서버에 연결할 수 없습니다');
|
||||
case DioExceptionType.badResponse:
|
||||
final statusCode = error.response?.statusCode ?? 0;
|
||||
final message = error.response?.data?['message'] ?? '서버 오류가 발생했습니다';
|
||||
|
||||
if (statusCode == 401) {
|
||||
return AuthFailure('인증이 만료되었습니다');
|
||||
return AuthenticationFailure(message: '인증이 만료되었습니다');
|
||||
} else if (statusCode == 403) {
|
||||
return AuthFailure('접근 권한이 없습니다');
|
||||
return AuthenticationFailure(message: '접근 권한이 없습니다');
|
||||
} else if (statusCode >= 400 && statusCode < 500) {
|
||||
return ServerFailure(message);
|
||||
return ServerFailure(message: message);
|
||||
} else {
|
||||
return ServerFailure('서버 오류가 발생했습니다 ($statusCode)');
|
||||
return ServerFailure(message: '서버 오류가 발생했습니다 ($statusCode)');
|
||||
}
|
||||
case DioExceptionType.cancel:
|
||||
return ServerFailure('요청이 취소되었습니다');
|
||||
return ServerFailure(message: '요청이 취소되었습니다');
|
||||
default:
|
||||
return ServerFailure('알 수 없는 오류가 발생했습니다');
|
||||
return ServerFailure(message: '알 수 없는 오류가 발생했습니다');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user