refactor: Clean Architecture 적용 및 코드베이스 전면 리팩토링
## 주요 변경사항 ### 아키텍처 개선 - Clean Architecture 패턴 적용 (Domain, Data, Presentation 레이어 분리) - Use Case 패턴 도입으로 비즈니스 로직 캡슐화 - Repository 패턴으로 데이터 접근 추상화 - 의존성 주입 구조 개선 ### 상태 관리 최적화 - 모든 Controller에서 불필요한 상태 관리 로직 제거 - 페이지네이션 로직 통일 및 간소화 - 에러 처리 로직 개선 (에러 메시지 한글화) - 로딩 상태 관리 최적화 ### Mock 서비스 제거 - MockDataService 완전 제거 - 모든 화면을 실제 API 전용으로 전환 - 불필요한 Mock 관련 코드 정리 ### UI/UX 개선 - Overview 화면 대시보드 기능 강화 - 라이선스 만료 알림 위젯 추가 - 사이드바 네비게이션 개선 - 일관된 UI 컴포넌트 사용 ### 코드 품질 - 중복 코드 제거 및 함수 추출 - 파일별 책임 분리 명확화 - 테스트 코드 업데이트 ## 영향 범위 - 모든 화면의 Controller 리팩토링 - API 통신 레이어 구조 개선 - 에러 처리 및 로깅 시스템 개선 ## 향후 계획 - 단위 테스트 커버리지 확대 - 통합 테스트 시나리오 추가 - 성능 모니터링 도구 통합
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../../../core/config/environment.dart';
|
||||
import '../../../core/constants/app_constants.dart';
|
||||
import 'interceptors/auth_interceptor.dart';
|
||||
import 'interceptors/error_interceptor.dart';
|
||||
import 'interceptors/logging_interceptor.dart';
|
||||
@@ -41,8 +42,8 @@ class ApiClient {
|
||||
// 기본값으로 초기화
|
||||
_dio = Dio(BaseOptions(
|
||||
baseUrl: 'http://43.201.34.104:8080/api/v1',
|
||||
connectTimeout: const Duration(seconds: 30),
|
||||
receiveTimeout: const Duration(seconds: 30),
|
||||
connectTimeout: AppConstants.apiConnectTimeout,
|
||||
receiveTimeout: AppConstants.apiReceiveTimeout,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
@@ -77,8 +78,8 @@ class ApiClient {
|
||||
// Environment가 초기화되지 않은 경우 기본값 사용
|
||||
return BaseOptions(
|
||||
baseUrl: 'http://43.201.34.104:8080/api/v1',
|
||||
connectTimeout: const Duration(seconds: 30),
|
||||
receiveTimeout: const Duration(seconds: 30),
|
||||
connectTimeout: AppConstants.apiConnectTimeout,
|
||||
receiveTimeout: AppConstants.apiReceiveTimeout,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:superport/core/errors/exceptions.dart';
|
||||
import 'package:superport/data/datasources/remote/api_client.dart';
|
||||
import 'package:superport/data/models/license/license_dto.dart';
|
||||
import 'package:superport/data/models/license/license_request_dto.dart';
|
||||
import 'package:superport/data/models/license/license_query_dto.dart';
|
||||
|
||||
abstract class LicenseRemoteDataSource {
|
||||
Future<LicenseListResponseDto> getLicenses({
|
||||
|
||||
@@ -0,0 +1,277 @@
|
||||
import 'package:flutter/foundation.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 WarehouseLocationRemoteDataSource {
|
||||
Future<WarehouseLocationListDto> getWarehouseLocations({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
String? search,
|
||||
Map<String, dynamic>? filters,
|
||||
});
|
||||
|
||||
Future<WarehouseLocationDto> getWarehouseLocationDetail(int id);
|
||||
Future<WarehouseLocationDto> createWarehouseLocation(CreateWarehouseLocationRequest request);
|
||||
Future<WarehouseLocationDto> updateWarehouseLocation(int id, UpdateWarehouseLocationRequest request);
|
||||
Future<void> deleteWarehouseLocation(int id);
|
||||
Future<WarehouseCapacityInfo> getWarehouseCapacity(int id);
|
||||
Future<WarehouseEquipmentListDto> getWarehouseEquipment({
|
||||
required int warehouseId,
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
});
|
||||
}
|
||||
|
||||
@LazySingleton(as: WarehouseLocationRemoteDataSource)
|
||||
class WarehouseLocationRemoteDataSourceImpl implements WarehouseLocationRemoteDataSource {
|
||||
final ApiClient _apiClient;
|
||||
|
||||
WarehouseLocationRemoteDataSourceImpl({
|
||||
required ApiClient apiClient,
|
||||
}) : _apiClient = apiClient;
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationListDto> getWarehouseLocations({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
String? search,
|
||||
Map<String, dynamic>? filters,
|
||||
}) async {
|
||||
try {
|
||||
final queryParams = <String, dynamic>{
|
||||
'page': page,
|
||||
'per_page': perPage,
|
||||
};
|
||||
|
||||
if (search != null && search.isNotEmpty) {
|
||||
queryParams['search'] = search;
|
||||
}
|
||||
|
||||
// 필터 적용
|
||||
if (filters != null) {
|
||||
filters.forEach((key, value) {
|
||||
if (value != null) {
|
||||
queryParams[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final response = await _apiClient.get(
|
||||
ApiEndpoints.warehouseLocations,
|
||||
queryParameters: queryParams,
|
||||
);
|
||||
|
||||
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
||||
// API 응답이 배열인 경우와 객체인 경우를 모두 처리
|
||||
final data = response.data['data'];
|
||||
if (data is List) {
|
||||
// 배열 응답을 WarehouseLocationListDto 형식으로 변환
|
||||
final List<WarehouseLocationDto> warehouses = [];
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
try {
|
||||
final item = data[i];
|
||||
debugPrint('📦 Parsing warehouse location item $i: ${item['name']}');
|
||||
|
||||
// null 검사 및 기본값 설정
|
||||
final warehouseDto = WarehouseLocationDto.fromJson({
|
||||
...item,
|
||||
// 필수 필드 보장
|
||||
'name': item['name'] ?? '',
|
||||
'is_active': item['is_active'] ?? true,
|
||||
'created_at': item['created_at'] ?? DateTime.now().toIso8601String(),
|
||||
});
|
||||
warehouses.add(warehouseDto);
|
||||
} catch (e, stackTrace) {
|
||||
debugPrint('❌ Error parsing warehouse location item $i: $e');
|
||||
debugPrint('Item data: ${data[i]}');
|
||||
debugPrint('Stack trace: $stackTrace');
|
||||
// 파싱 실패한 항목은 건너뛰고 계속
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final pagination = response.data['pagination'] ?? {};
|
||||
return WarehouseLocationListDto(
|
||||
items: warehouses,
|
||||
total: pagination['total'] ?? warehouses.length,
|
||||
page: pagination['page'] ?? page,
|
||||
perPage: pagination['per_page'] ?? perPage,
|
||||
totalPages: pagination['total_pages'] ?? 1,
|
||||
);
|
||||
} else if (data['items'] != null) {
|
||||
// 이미 WarehouseLocationListDto 형식인 경우
|
||||
return WarehouseLocationListDto.fromJson(data);
|
||||
} else {
|
||||
// 예상치 못한 형식인 경우
|
||||
throw ApiException(
|
||||
message: 'Unexpected response format for warehouse location list',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw ApiException(
|
||||
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse locations',
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationDto> getWarehouseLocationDetail(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 create 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 update 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<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<WarehouseEquipmentListDto> getWarehouseEquipment({
|
||||
required 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) {
|
||||
final data = response.data['data'];
|
||||
final pagination = response.data['pagination'] ?? {};
|
||||
|
||||
if (data is List) {
|
||||
// 배열 응답을 WarehouseEquipmentListDto 형식으로 변환
|
||||
final List<WarehouseEquipmentDto> equipment = [];
|
||||
|
||||
for (var item in data) {
|
||||
try {
|
||||
equipment.add(WarehouseEquipmentDto.fromJson(item));
|
||||
} catch (e) {
|
||||
debugPrint('❌ Error parsing warehouse equipment: $e');
|
||||
debugPrint('Item data: $item');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return WarehouseEquipmentListDto(
|
||||
items: equipment,
|
||||
total: pagination['total'] ?? equipment.length,
|
||||
page: pagination['page'] ?? page,
|
||||
perPage: pagination['per_page'] ?? perPage,
|
||||
totalPages: pagination['total_pages'] ?? 1,
|
||||
);
|
||||
} else {
|
||||
// 이미 올바른 형식인 경우
|
||||
return WarehouseEquipmentListDto.fromJson(data);
|
||||
}
|
||||
} else {
|
||||
throw ApiException(
|
||||
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse equipment',
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
Exception _handleError(dynamic error) {
|
||||
if (error is ApiException) {
|
||||
return error;
|
||||
}
|
||||
return ApiException(
|
||||
message: error.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
52
lib/data/models/common/pagination_params.dart
Normal file
52
lib/data/models/common/pagination_params.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:superport/core/constants/app_constants.dart';
|
||||
|
||||
part 'pagination_params.freezed.dart';
|
||||
part 'pagination_params.g.dart';
|
||||
|
||||
/// 페이지네이션 요청 파라미터를 위한 표준화된 클래스
|
||||
@freezed
|
||||
class PaginationParams with _$PaginationParams {
|
||||
const factory PaginationParams({
|
||||
@Default(1) int page,
|
||||
@Default(AppConstants.defaultPageSize) int perPage,
|
||||
String? search,
|
||||
String? sortBy,
|
||||
@Default('asc') String sortOrder,
|
||||
Map<String, dynamic>? filters,
|
||||
}) = _PaginationParams;
|
||||
|
||||
factory PaginationParams.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaginationParamsFromJson(json);
|
||||
}
|
||||
|
||||
/// 페이지네이션 메타데이터
|
||||
@freezed
|
||||
class PaginationMeta with _$PaginationMeta {
|
||||
const factory PaginationMeta({
|
||||
required int currentPage,
|
||||
required int perPage,
|
||||
required int total,
|
||||
required int totalPages,
|
||||
required bool hasNext,
|
||||
required bool hasPrevious,
|
||||
}) = _PaginationMeta;
|
||||
|
||||
factory PaginationMeta.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaginationMetaFromJson(json);
|
||||
}
|
||||
|
||||
/// 페이지네이션된 결과를 위한 래퍼 클래스
|
||||
@Freezed(genericArgumentFactories: true)
|
||||
class PagedResult<T> with _$PagedResult<T> {
|
||||
const factory PagedResult({
|
||||
required List<T> items,
|
||||
required PaginationMeta meta,
|
||||
}) = _PagedResult<T>;
|
||||
|
||||
factory PagedResult.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
T Function(Object?) fromJsonT,
|
||||
) =>
|
||||
_$PagedResultFromJson<T>(json, fromJsonT);
|
||||
}
|
||||
733
lib/data/models/common/pagination_params.freezed.dart
Normal file
733
lib/data/models/common/pagination_params.freezed.dart
Normal file
@@ -0,0 +1,733 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'pagination_params.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
PaginationParams _$PaginationParamsFromJson(Map<String, dynamic> json) {
|
||||
return _PaginationParams.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaginationParams {
|
||||
int get page => throw _privateConstructorUsedError;
|
||||
int get perPage => throw _privateConstructorUsedError;
|
||||
String? get search => throw _privateConstructorUsedError;
|
||||
String? get sortBy => throw _privateConstructorUsedError;
|
||||
String get sortOrder => throw _privateConstructorUsedError;
|
||||
Map<String, dynamic>? get filters => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this PaginationParams to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaginationParams
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaginationParamsCopyWith<PaginationParams> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaginationParamsCopyWith<$Res> {
|
||||
factory $PaginationParamsCopyWith(
|
||||
PaginationParams value, $Res Function(PaginationParams) then) =
|
||||
_$PaginationParamsCopyWithImpl<$Res, PaginationParams>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int page,
|
||||
int perPage,
|
||||
String? search,
|
||||
String? sortBy,
|
||||
String sortOrder,
|
||||
Map<String, dynamic>? filters});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaginationParamsCopyWithImpl<$Res, $Val extends PaginationParams>
|
||||
implements $PaginationParamsCopyWith<$Res> {
|
||||
_$PaginationParamsCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaginationParams
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? page = null,
|
||||
Object? perPage = null,
|
||||
Object? search = freezed,
|
||||
Object? sortBy = freezed,
|
||||
Object? sortOrder = null,
|
||||
Object? filters = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
page: null == page
|
||||
? _value.page
|
||||
: page // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
perPage: null == perPage
|
||||
? _value.perPage
|
||||
: perPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
search: freezed == search
|
||||
? _value.search
|
||||
: search // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
sortBy: freezed == sortBy
|
||||
? _value.sortBy
|
||||
: sortBy // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
sortOrder: null == sortOrder
|
||||
? _value.sortOrder
|
||||
: sortOrder // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
filters: freezed == filters
|
||||
? _value.filters
|
||||
: filters // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaginationParamsImplCopyWith<$Res>
|
||||
implements $PaginationParamsCopyWith<$Res> {
|
||||
factory _$$PaginationParamsImplCopyWith(_$PaginationParamsImpl value,
|
||||
$Res Function(_$PaginationParamsImpl) then) =
|
||||
__$$PaginationParamsImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int page,
|
||||
int perPage,
|
||||
String? search,
|
||||
String? sortBy,
|
||||
String sortOrder,
|
||||
Map<String, dynamic>? filters});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaginationParamsImplCopyWithImpl<$Res>
|
||||
extends _$PaginationParamsCopyWithImpl<$Res, _$PaginationParamsImpl>
|
||||
implements _$$PaginationParamsImplCopyWith<$Res> {
|
||||
__$$PaginationParamsImplCopyWithImpl(_$PaginationParamsImpl _value,
|
||||
$Res Function(_$PaginationParamsImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of PaginationParams
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? page = null,
|
||||
Object? perPage = null,
|
||||
Object? search = freezed,
|
||||
Object? sortBy = freezed,
|
||||
Object? sortOrder = null,
|
||||
Object? filters = freezed,
|
||||
}) {
|
||||
return _then(_$PaginationParamsImpl(
|
||||
page: null == page
|
||||
? _value.page
|
||||
: page // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
perPage: null == perPage
|
||||
? _value.perPage
|
||||
: perPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
search: freezed == search
|
||||
? _value.search
|
||||
: search // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
sortBy: freezed == sortBy
|
||||
? _value.sortBy
|
||||
: sortBy // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
sortOrder: null == sortOrder
|
||||
? _value.sortOrder
|
||||
: sortOrder // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
filters: freezed == filters
|
||||
? _value._filters
|
||||
: filters // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PaginationParamsImpl implements _PaginationParams {
|
||||
const _$PaginationParamsImpl(
|
||||
{this.page = 1,
|
||||
this.perPage = AppConstants.defaultPageSize,
|
||||
this.search,
|
||||
this.sortBy,
|
||||
this.sortOrder = 'asc',
|
||||
final Map<String, dynamic>? filters})
|
||||
: _filters = filters;
|
||||
|
||||
factory _$PaginationParamsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$PaginationParamsImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final int page;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int perPage;
|
||||
@override
|
||||
final String? search;
|
||||
@override
|
||||
final String? sortBy;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String sortOrder;
|
||||
final Map<String, dynamic>? _filters;
|
||||
@override
|
||||
Map<String, dynamic>? get filters {
|
||||
final value = _filters;
|
||||
if (value == null) return null;
|
||||
if (_filters is EqualUnmodifiableMapView) return _filters;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaginationParams(page: $page, perPage: $perPage, search: $search, sortBy: $sortBy, sortOrder: $sortOrder, filters: $filters)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaginationParamsImpl &&
|
||||
(identical(other.page, page) || other.page == page) &&
|
||||
(identical(other.perPage, perPage) || other.perPage == perPage) &&
|
||||
(identical(other.search, search) || other.search == search) &&
|
||||
(identical(other.sortBy, sortBy) || other.sortBy == sortBy) &&
|
||||
(identical(other.sortOrder, sortOrder) ||
|
||||
other.sortOrder == sortOrder) &&
|
||||
const DeepCollectionEquality().equals(other._filters, _filters));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, page, perPage, search, sortBy,
|
||||
sortOrder, const DeepCollectionEquality().hash(_filters));
|
||||
|
||||
/// Create a copy of PaginationParams
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaginationParamsImplCopyWith<_$PaginationParamsImpl> get copyWith =>
|
||||
__$$PaginationParamsImplCopyWithImpl<_$PaginationParamsImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PaginationParamsImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _PaginationParams implements PaginationParams {
|
||||
const factory _PaginationParams(
|
||||
{final int page,
|
||||
final int perPage,
|
||||
final String? search,
|
||||
final String? sortBy,
|
||||
final String sortOrder,
|
||||
final Map<String, dynamic>? filters}) = _$PaginationParamsImpl;
|
||||
|
||||
factory _PaginationParams.fromJson(Map<String, dynamic> json) =
|
||||
_$PaginationParamsImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get page;
|
||||
@override
|
||||
int get perPage;
|
||||
@override
|
||||
String? get search;
|
||||
@override
|
||||
String? get sortBy;
|
||||
@override
|
||||
String get sortOrder;
|
||||
@override
|
||||
Map<String, dynamic>? get filters;
|
||||
|
||||
/// Create a copy of PaginationParams
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaginationParamsImplCopyWith<_$PaginationParamsImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
PaginationMeta _$PaginationMetaFromJson(Map<String, dynamic> json) {
|
||||
return _PaginationMeta.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaginationMeta {
|
||||
int get currentPage => throw _privateConstructorUsedError;
|
||||
int get perPage => throw _privateConstructorUsedError;
|
||||
int get total => throw _privateConstructorUsedError;
|
||||
int get totalPages => throw _privateConstructorUsedError;
|
||||
bool get hasNext => throw _privateConstructorUsedError;
|
||||
bool get hasPrevious => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this PaginationMeta to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaginationMeta
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaginationMetaCopyWith<PaginationMeta> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaginationMetaCopyWith<$Res> {
|
||||
factory $PaginationMetaCopyWith(
|
||||
PaginationMeta value, $Res Function(PaginationMeta) then) =
|
||||
_$PaginationMetaCopyWithImpl<$Res, PaginationMeta>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int currentPage,
|
||||
int perPage,
|
||||
int total,
|
||||
int totalPages,
|
||||
bool hasNext,
|
||||
bool hasPrevious});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaginationMetaCopyWithImpl<$Res, $Val extends PaginationMeta>
|
||||
implements $PaginationMetaCopyWith<$Res> {
|
||||
_$PaginationMetaCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaginationMeta
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? currentPage = null,
|
||||
Object? perPage = null,
|
||||
Object? total = null,
|
||||
Object? totalPages = null,
|
||||
Object? hasNext = null,
|
||||
Object? hasPrevious = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
currentPage: null == currentPage
|
||||
? _value.currentPage
|
||||
: currentPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
perPage: null == perPage
|
||||
? _value.perPage
|
||||
: perPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
total: null == total
|
||||
? _value.total
|
||||
: total // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
totalPages: null == totalPages
|
||||
? _value.totalPages
|
||||
: totalPages // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
hasNext: null == hasNext
|
||||
? _value.hasNext
|
||||
: hasNext // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
hasPrevious: null == hasPrevious
|
||||
? _value.hasPrevious
|
||||
: hasPrevious // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaginationMetaImplCopyWith<$Res>
|
||||
implements $PaginationMetaCopyWith<$Res> {
|
||||
factory _$$PaginationMetaImplCopyWith(_$PaginationMetaImpl value,
|
||||
$Res Function(_$PaginationMetaImpl) then) =
|
||||
__$$PaginationMetaImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int currentPage,
|
||||
int perPage,
|
||||
int total,
|
||||
int totalPages,
|
||||
bool hasNext,
|
||||
bool hasPrevious});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaginationMetaImplCopyWithImpl<$Res>
|
||||
extends _$PaginationMetaCopyWithImpl<$Res, _$PaginationMetaImpl>
|
||||
implements _$$PaginationMetaImplCopyWith<$Res> {
|
||||
__$$PaginationMetaImplCopyWithImpl(
|
||||
_$PaginationMetaImpl _value, $Res Function(_$PaginationMetaImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of PaginationMeta
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? currentPage = null,
|
||||
Object? perPage = null,
|
||||
Object? total = null,
|
||||
Object? totalPages = null,
|
||||
Object? hasNext = null,
|
||||
Object? hasPrevious = null,
|
||||
}) {
|
||||
return _then(_$PaginationMetaImpl(
|
||||
currentPage: null == currentPage
|
||||
? _value.currentPage
|
||||
: currentPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
perPage: null == perPage
|
||||
? _value.perPage
|
||||
: perPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
total: null == total
|
||||
? _value.total
|
||||
: total // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
totalPages: null == totalPages
|
||||
? _value.totalPages
|
||||
: totalPages // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
hasNext: null == hasNext
|
||||
? _value.hasNext
|
||||
: hasNext // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
hasPrevious: null == hasPrevious
|
||||
? _value.hasPrevious
|
||||
: hasPrevious // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PaginationMetaImpl implements _PaginationMeta {
|
||||
const _$PaginationMetaImpl(
|
||||
{required this.currentPage,
|
||||
required this.perPage,
|
||||
required this.total,
|
||||
required this.totalPages,
|
||||
required this.hasNext,
|
||||
required this.hasPrevious});
|
||||
|
||||
factory _$PaginationMetaImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$PaginationMetaImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int currentPage;
|
||||
@override
|
||||
final int perPage;
|
||||
@override
|
||||
final int total;
|
||||
@override
|
||||
final int totalPages;
|
||||
@override
|
||||
final bool hasNext;
|
||||
@override
|
||||
final bool hasPrevious;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaginationMeta(currentPage: $currentPage, perPage: $perPage, total: $total, totalPages: $totalPages, hasNext: $hasNext, hasPrevious: $hasPrevious)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaginationMetaImpl &&
|
||||
(identical(other.currentPage, currentPage) ||
|
||||
other.currentPage == currentPage) &&
|
||||
(identical(other.perPage, perPage) || other.perPage == perPage) &&
|
||||
(identical(other.total, total) || other.total == total) &&
|
||||
(identical(other.totalPages, totalPages) ||
|
||||
other.totalPages == totalPages) &&
|
||||
(identical(other.hasNext, hasNext) || other.hasNext == hasNext) &&
|
||||
(identical(other.hasPrevious, hasPrevious) ||
|
||||
other.hasPrevious == hasPrevious));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, currentPage, perPage, total,
|
||||
totalPages, hasNext, hasPrevious);
|
||||
|
||||
/// Create a copy of PaginationMeta
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaginationMetaImplCopyWith<_$PaginationMetaImpl> get copyWith =>
|
||||
__$$PaginationMetaImplCopyWithImpl<_$PaginationMetaImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PaginationMetaImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _PaginationMeta implements PaginationMeta {
|
||||
const factory _PaginationMeta(
|
||||
{required final int currentPage,
|
||||
required final int perPage,
|
||||
required final int total,
|
||||
required final int totalPages,
|
||||
required final bool hasNext,
|
||||
required final bool hasPrevious}) = _$PaginationMetaImpl;
|
||||
|
||||
factory _PaginationMeta.fromJson(Map<String, dynamic> json) =
|
||||
_$PaginationMetaImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get currentPage;
|
||||
@override
|
||||
int get perPage;
|
||||
@override
|
||||
int get total;
|
||||
@override
|
||||
int get totalPages;
|
||||
@override
|
||||
bool get hasNext;
|
||||
@override
|
||||
bool get hasPrevious;
|
||||
|
||||
/// Create a copy of PaginationMeta
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaginationMetaImplCopyWith<_$PaginationMetaImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
PagedResult<T> _$PagedResultFromJson<T>(
|
||||
Map<String, dynamic> json, T Function(Object?) fromJsonT) {
|
||||
return _PagedResult<T>.fromJson(json, fromJsonT);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PagedResult<T> {
|
||||
List<T> get items => throw _privateConstructorUsedError;
|
||||
PaginationMeta get meta => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this PagedResult to a JSON map.
|
||||
Map<String, dynamic> toJson(Object? Function(T) toJsonT) =>
|
||||
throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PagedResult
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PagedResultCopyWith<T, PagedResult<T>> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PagedResultCopyWith<T, $Res> {
|
||||
factory $PagedResultCopyWith(
|
||||
PagedResult<T> value, $Res Function(PagedResult<T>) then) =
|
||||
_$PagedResultCopyWithImpl<T, $Res, PagedResult<T>>;
|
||||
@useResult
|
||||
$Res call({List<T> items, PaginationMeta meta});
|
||||
|
||||
$PaginationMetaCopyWith<$Res> get meta;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PagedResultCopyWithImpl<T, $Res, $Val extends PagedResult<T>>
|
||||
implements $PagedResultCopyWith<T, $Res> {
|
||||
_$PagedResultCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PagedResult
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? items = null,
|
||||
Object? meta = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
items: null == items
|
||||
? _value.items
|
||||
: items // ignore: cast_nullable_to_non_nullable
|
||||
as List<T>,
|
||||
meta: null == meta
|
||||
? _value.meta
|
||||
: meta // ignore: cast_nullable_to_non_nullable
|
||||
as PaginationMeta,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
/// Create a copy of PagedResult
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$PaginationMetaCopyWith<$Res> get meta {
|
||||
return $PaginationMetaCopyWith<$Res>(_value.meta, (value) {
|
||||
return _then(_value.copyWith(meta: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PagedResultImplCopyWith<T, $Res>
|
||||
implements $PagedResultCopyWith<T, $Res> {
|
||||
factory _$$PagedResultImplCopyWith(_$PagedResultImpl<T> value,
|
||||
$Res Function(_$PagedResultImpl<T>) then) =
|
||||
__$$PagedResultImplCopyWithImpl<T, $Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({List<T> items, PaginationMeta meta});
|
||||
|
||||
@override
|
||||
$PaginationMetaCopyWith<$Res> get meta;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PagedResultImplCopyWithImpl<T, $Res>
|
||||
extends _$PagedResultCopyWithImpl<T, $Res, _$PagedResultImpl<T>>
|
||||
implements _$$PagedResultImplCopyWith<T, $Res> {
|
||||
__$$PagedResultImplCopyWithImpl(
|
||||
_$PagedResultImpl<T> _value, $Res Function(_$PagedResultImpl<T>) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of PagedResult
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? items = null,
|
||||
Object? meta = null,
|
||||
}) {
|
||||
return _then(_$PagedResultImpl<T>(
|
||||
items: null == items
|
||||
? _value._items
|
||||
: items // ignore: cast_nullable_to_non_nullable
|
||||
as List<T>,
|
||||
meta: null == meta
|
||||
? _value.meta
|
||||
: meta // ignore: cast_nullable_to_non_nullable
|
||||
as PaginationMeta,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable(genericArgumentFactories: true)
|
||||
class _$PagedResultImpl<T> implements _PagedResult<T> {
|
||||
const _$PagedResultImpl({required final List<T> items, required this.meta})
|
||||
: _items = items;
|
||||
|
||||
factory _$PagedResultImpl.fromJson(
|
||||
Map<String, dynamic> json, T Function(Object?) fromJsonT) =>
|
||||
_$$PagedResultImplFromJson(json, fromJsonT);
|
||||
|
||||
final List<T> _items;
|
||||
@override
|
||||
List<T> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
@override
|
||||
final PaginationMeta meta;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PagedResult<$T>(items: $items, meta: $meta)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PagedResultImpl<T> &&
|
||||
const DeepCollectionEquality().equals(other._items, _items) &&
|
||||
(identical(other.meta, meta) || other.meta == meta));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, const DeepCollectionEquality().hash(_items), meta);
|
||||
|
||||
/// Create a copy of PagedResult
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PagedResultImplCopyWith<T, _$PagedResultImpl<T>> get copyWith =>
|
||||
__$$PagedResultImplCopyWithImpl<T, _$PagedResultImpl<T>>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson(Object? Function(T) toJsonT) {
|
||||
return _$$PagedResultImplToJson<T>(this, toJsonT);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _PagedResult<T> implements PagedResult<T> {
|
||||
const factory _PagedResult(
|
||||
{required final List<T> items,
|
||||
required final PaginationMeta meta}) = _$PagedResultImpl<T>;
|
||||
|
||||
factory _PagedResult.fromJson(
|
||||
Map<String, dynamic> json, T Function(Object?) fromJsonT) =
|
||||
_$PagedResultImpl<T>.fromJson;
|
||||
|
||||
@override
|
||||
List<T> get items;
|
||||
@override
|
||||
PaginationMeta get meta;
|
||||
|
||||
/// Create a copy of PagedResult
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PagedResultImplCopyWith<T, _$PagedResultImpl<T>> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
69
lib/data/models/common/pagination_params.g.dart
Normal file
69
lib/data/models/common/pagination_params.g.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pagination_params.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$PaginationParamsImpl _$$PaginationParamsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$PaginationParamsImpl(
|
||||
page: (json['page'] as num?)?.toInt() ?? 1,
|
||||
perPage:
|
||||
(json['perPage'] as num?)?.toInt() ?? AppConstants.defaultPageSize,
|
||||
search: json['search'] as String?,
|
||||
sortBy: json['sortBy'] as String?,
|
||||
sortOrder: json['sortOrder'] as String? ?? 'asc',
|
||||
filters: json['filters'] as Map<String, dynamic>?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PaginationParamsImplToJson(
|
||||
_$PaginationParamsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'page': instance.page,
|
||||
'perPage': instance.perPage,
|
||||
'search': instance.search,
|
||||
'sortBy': instance.sortBy,
|
||||
'sortOrder': instance.sortOrder,
|
||||
'filters': instance.filters,
|
||||
};
|
||||
|
||||
_$PaginationMetaImpl _$$PaginationMetaImplFromJson(Map<String, dynamic> json) =>
|
||||
_$PaginationMetaImpl(
|
||||
currentPage: (json['currentPage'] as num).toInt(),
|
||||
perPage: (json['perPage'] as num).toInt(),
|
||||
total: (json['total'] as num).toInt(),
|
||||
totalPages: (json['totalPages'] as num).toInt(),
|
||||
hasNext: json['hasNext'] as bool,
|
||||
hasPrevious: json['hasPrevious'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PaginationMetaImplToJson(
|
||||
_$PaginationMetaImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'currentPage': instance.currentPage,
|
||||
'perPage': instance.perPage,
|
||||
'total': instance.total,
|
||||
'totalPages': instance.totalPages,
|
||||
'hasNext': instance.hasNext,
|
||||
'hasPrevious': instance.hasPrevious,
|
||||
};
|
||||
|
||||
_$PagedResultImpl<T> _$$PagedResultImplFromJson<T>(
|
||||
Map<String, dynamic> json,
|
||||
T Function(Object? json) fromJsonT,
|
||||
) =>
|
||||
_$PagedResultImpl<T>(
|
||||
items: (json['items'] as List<dynamic>).map(fromJsonT).toList(),
|
||||
meta: PaginationMeta.fromJson(json['meta'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PagedResultImplToJson<T>(
|
||||
_$PagedResultImpl<T> instance,
|
||||
Object? Function(T value) toJsonT,
|
||||
) =>
|
||||
<String, dynamic>{
|
||||
'items': instance.items.map(toJsonT).toList(),
|
||||
'meta': instance.meta,
|
||||
};
|
||||
24
lib/data/repositories/license_repository.dart
Normal file
24
lib/data/repositories/license_repository.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import '../models/license/license_dto.dart';
|
||||
|
||||
/// 라이선스 Repository 인터페이스
|
||||
abstract class LicenseRepository {
|
||||
/// 라이선스 목록 조회
|
||||
Future<LicenseListResponseDto> getLicenses({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
String? search,
|
||||
Map<String, dynamic>? filters,
|
||||
});
|
||||
|
||||
/// 라이선스 상세 조회
|
||||
Future<LicenseDto> getLicenseDetail(int id);
|
||||
|
||||
/// 라이선스 생성
|
||||
Future<LicenseDto> createLicense(Map<String, dynamic> data);
|
||||
|
||||
/// 라이선스 수정
|
||||
Future<LicenseDto> updateLicense(int id, Map<String, dynamic> data);
|
||||
|
||||
/// 라이선스 삭제
|
||||
Future<void> deleteLicense(int id);
|
||||
}
|
||||
58
lib/data/repositories/license_repository_impl.dart
Normal file
58
lib/data/repositories/license_repository_impl.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../datasources/remote/license_remote_datasource.dart';
|
||||
import '../models/license/license_dto.dart';
|
||||
import '../models/license/license_request_dto.dart';
|
||||
import 'license_repository.dart';
|
||||
|
||||
/// 라이선스 Repository 구현체
|
||||
@Injectable(as: LicenseRepository)
|
||||
class LicenseRepositoryImpl implements LicenseRepository {
|
||||
final LicenseRemoteDataSource remoteDataSource;
|
||||
|
||||
LicenseRepositoryImpl(this.remoteDataSource);
|
||||
|
||||
@override
|
||||
Future<LicenseListResponseDto> getLicenses({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
String? search,
|
||||
Map<String, dynamic>? filters,
|
||||
}) async {
|
||||
// 검색 및 필터 파라미터를 DataSource 형식에 맞게 변환
|
||||
bool? isActive = filters?['is_active'];
|
||||
int? companyId = filters?['company_id'];
|
||||
int? assignedUserId = filters?['assigned_user_id'];
|
||||
String? licenseType = filters?['license_type'];
|
||||
|
||||
return await remoteDataSource.getLicenses(
|
||||
page: page,
|
||||
perPage: perPage,
|
||||
isActive: isActive,
|
||||
companyId: companyId,
|
||||
assignedUserId: assignedUserId,
|
||||
licenseType: licenseType,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LicenseDto> getLicenseDetail(int id) async {
|
||||
return await remoteDataSource.getLicenseById(id);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LicenseDto> createLicense(Map<String, dynamic> data) async {
|
||||
final request = CreateLicenseRequest.fromJson(data);
|
||||
return await remoteDataSource.createLicense(request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LicenseDto> updateLicense(int id, Map<String, dynamic> data) async {
|
||||
final request = UpdateLicenseRequest.fromJson(data);
|
||||
return await remoteDataSource.updateLicense(id, request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteLicense(int id) async {
|
||||
await remoteDataSource.deleteLicense(id);
|
||||
}
|
||||
}
|
||||
27
lib/data/repositories/warehouse_location_repository.dart
Normal file
27
lib/data/repositories/warehouse_location_repository.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import '../models/warehouse/warehouse_dto.dart';
|
||||
|
||||
/// 창고 위치 Repository 인터페이스
|
||||
abstract class WarehouseLocationRepository {
|
||||
/// 창고 위치 목록 조회
|
||||
Future<WarehouseLocationListDto> getWarehouseLocations({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
String? search,
|
||||
Map<String, dynamic>? filters,
|
||||
});
|
||||
|
||||
/// 창고 위치 상세 조회
|
||||
Future<WarehouseLocationDto> getWarehouseLocationDetail(int id);
|
||||
|
||||
/// 창고 위치 생성
|
||||
Future<WarehouseLocationDto> createWarehouseLocation(Map<String, dynamic> data);
|
||||
|
||||
/// 창고 위치 수정
|
||||
Future<WarehouseLocationDto> updateWarehouseLocation(int id, Map<String, dynamic> data);
|
||||
|
||||
/// 창고 위치 삭제
|
||||
Future<void> deleteWarehouseLocation(int id);
|
||||
|
||||
/// 창고에 장비가 있는지 확인
|
||||
Future<bool> checkWarehouseHasEquipment(int id);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../datasources/remote/warehouse_location_remote_datasource.dart';
|
||||
import '../models/warehouse/warehouse_dto.dart';
|
||||
import 'warehouse_location_repository.dart';
|
||||
|
||||
/// 창고 위치 Repository 구현체
|
||||
@Injectable(as: WarehouseLocationRepository)
|
||||
class WarehouseLocationRepositoryImpl implements WarehouseLocationRepository {
|
||||
final WarehouseLocationRemoteDataSource remoteDataSource;
|
||||
|
||||
WarehouseLocationRepositoryImpl(this.remoteDataSource);
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationListDto> getWarehouseLocations({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
String? search,
|
||||
Map<String, dynamic>? filters,
|
||||
}) async {
|
||||
return await remoteDataSource.getWarehouseLocations(
|
||||
page: page,
|
||||
perPage: perPage,
|
||||
search: search,
|
||||
filters: filters,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationDto> getWarehouseLocationDetail(int id) async {
|
||||
return await remoteDataSource.getWarehouseLocationDetail(id);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationDto> createWarehouseLocation(Map<String, dynamic> data) async {
|
||||
final request = CreateWarehouseLocationRequest.fromJson(data);
|
||||
return await remoteDataSource.createWarehouseLocation(request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationDto> updateWarehouseLocation(int id, Map<String, dynamic> data) async {
|
||||
final request = UpdateWarehouseLocationRequest.fromJson(data);
|
||||
return await remoteDataSource.updateWarehouseLocation(id, request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteWarehouseLocation(int id) async {
|
||||
await remoteDataSource.deleteWarehouseLocation(id);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> checkWarehouseHasEquipment(int id) async {
|
||||
// TODO: API 엔드포인트 구현 필요
|
||||
// 현재는 항상 false 반환
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user