test: 통합 테스트 오류 및 경고 수정
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled

- 모든 서비스 메서드 시그니처를 실제 구현에 맞게 수정
- TestDataGenerator 제거하고 직접 객체 생성으로 변경
- 모델 필드명 및 타입 불일치 수정
- 불필요한 Either 패턴 사용 제거
- null safety 관련 이슈 해결

수정된 파일:
- test/integration/screens/company_integration_test.dart
- test/integration/screens/equipment_integration_test.dart
- test/integration/screens/user_integration_test.dart
- test/integration/screens/login_integration_test.dart
This commit is contained in:
JiWoong Sul
2025-08-05 20:24:05 +09:00
parent d6f34c0a52
commit 198aac6525
145 changed files with 41527 additions and 5220 deletions

View File

@@ -19,20 +19,28 @@ class ApiClient {
ApiClient._internal() {
try {
print('[ApiClient] 초기화 시작');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[ApiClient] 초기화 시작');
}
_dio = Dio(_baseOptions);
print('[ApiClient] Dio 인스턴스 생성 완료');
print('[ApiClient] Base URL: ${_dio.options.baseUrl}');
print('[ApiClient] Connect Timeout: ${_dio.options.connectTimeout}');
print('[ApiClient] Receive Timeout: ${_dio.options.receiveTimeout}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[ApiClient] Dio 인스턴스 생성 완료');
debugPrint('[ApiClient] Base URL: ${_dio.options.baseUrl}');
debugPrint('[ApiClient] Connect Timeout: ${_dio.options.connectTimeout}');
debugPrint('[ApiClient] Receive Timeout: ${_dio.options.receiveTimeout}');
}
_setupInterceptors();
print('[ApiClient] 인터셉터 설정 완료');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[ApiClient] 인터셉터 설정 완료');
}
} catch (e, stackTrace) {
print('[ApiClient] ⚠️ 에러 발생: $e');
print('[ApiClient] Stack trace: $stackTrace');
if (kDebugMode) {
debugPrint('[ApiClient] ⚠️ 에러 발생: $e');
debugPrint('[ApiClient] Stack trace: $stackTrace');
}
// 기본값으로 초기화
_dio = Dio(BaseOptions(
baseUrl: 'https://superport.naturebridgeai.com/api/v1',
baseUrl: 'http://43.201.34.104:8080/api/v1',
connectTimeout: const Duration(seconds: 30),
receiveTimeout: const Duration(seconds: 30),
headers: {
@@ -41,7 +49,9 @@ class ApiClient {
},
));
_setupInterceptors();
print('[ApiClient] 기본값으로 초기화 완료');
if (kDebugMode) {
debugPrint('[ApiClient] 기본값으로 초기화 완료');
}
}
}
@@ -66,7 +76,7 @@ class ApiClient {
} catch (e) {
// Environment가 초기화되지 않은 경우 기본값 사용
return BaseOptions(
baseUrl: 'https://superport.naturebridgeai.com/api/v1',
baseUrl: 'http://43.201.34.104:8080/api/v1',
connectTimeout: const Duration(seconds: 30),
receiveTimeout: const Duration(seconds: 30),
headers: {
@@ -143,8 +153,10 @@ class ApiClient {
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) {
print('[ApiClient] POST 요청 시작: $path');
print('[ApiClient] 요청 데이터: $data');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[ApiClient] POST 요청 시작: $path');
debugPrint('[ApiClient] 요청 데이터: $data');
}
return _dio.post<T>(
path,
@@ -155,14 +167,18 @@ class ApiClient {
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
).then((response) {
print('[ApiClient] POST 응답 수신: ${response.statusCode}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[ApiClient] POST 응답 수신: ${response.statusCode}');
}
return response;
}).catchError((error) {
print('[ApiClient] POST 에러 발생: $error');
if (error is DioException) {
print('[ApiClient] DioException 타입: ${error.type}');
print('[ApiClient] DioException 메시지: ${error.message}');
print('[ApiClient] DioException 에러: ${error.error}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[ApiClient] POST 에러 발생: $error');
if (error is DioException) {
debugPrint('[ApiClient] DioException 타입: ${error.type}');
debugPrint('[ApiClient] DioException 메시지: ${error.message}');
debugPrint('[ApiClient] DioException 에러: ${error.error}');
}
}
throw error;
});

View File

@@ -47,11 +47,11 @@ class AuthRemoteDataSourceImpl implements AuthRemoteDataSource {
if (responseData is Map && responseData['success'] == true && responseData['data'] != null) {
DebugLogger.logLogin('응답 형식 1 감지', data: {'format': 'wrapped'});
// 응답 데이터 구조 검증
// 응답 데이터 구조 검증 (snake_case 키 확인)
final dataFields = responseData['data'] as Map<String, dynamic>;
DebugLogger.validateResponseStructure(
dataFields,
['accessToken', 'refreshToken', 'user'],
['access_token', 'refresh_token', 'user'],
responseName: 'LoginResponse.data',
);
@@ -78,10 +78,10 @@ class AuthRemoteDataSourceImpl implements AuthRemoteDataSource {
responseData.containsKey('access_token'))) {
DebugLogger.logLogin('응답 형식 2 감지', data: {'format': 'direct'});
// 응답 데이터 구조 검증
// 응답 데이터 구조 검증 (snake_case 키 확인)
DebugLogger.validateResponseStructure(
responseData as Map<String, dynamic>,
['accessToken', 'refreshToken', 'user'],
['access_token', 'refresh_token', 'user'],
responseName: 'LoginResponse',
);
@@ -151,7 +151,7 @@ class AuthRemoteDataSourceImpl implements AuthRemoteDataSource {
// 기본 DioException 처리
if (e.response?.statusCode == 401) {
return Left(AuthenticationFailure(
message: '이메일 또는 비밀번호가 올바르지 않습니다.',
message: '자격 증명이 올바르지 않습니다. 이메일과 비밀번호를 확인해주세요.',
));
}

View File

@@ -1,7 +1,9 @@
import 'package:dio/dio.dart';
import 'package:get_it/get_it.dart';
import 'package:flutter/foundation.dart';
import '../../../../core/constants/api_endpoints.dart';
import '../../../../services/auth_service.dart';
import '../../../../core/config/environment.dart';
/// 인증 인터셉터
class AuthInterceptor extends Interceptor {
@@ -15,7 +17,9 @@ class AuthInterceptor extends Interceptor {
_authService ??= GetIt.instance<AuthService>();
return _authService;
} catch (e) {
print('Failed to get AuthService in AuthInterceptor: $e');
if (kDebugMode) {
debugPrint('Failed to get AuthService in AuthInterceptor: $e');
}
return null;
}
}
@@ -25,34 +29,50 @@ class AuthInterceptor extends Interceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) async {
print('[AuthInterceptor] onRequest: ${options.method} ${options.path}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] onRequest: ${options.method} ${options.path}');
}
// 로그인, 토큰 갱신 요청은 토큰 없이 진행
if (_isAuthEndpoint(options.path)) {
print('[AuthInterceptor] Auth endpoint detected, skipping token attachment');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Auth endpoint detected, skipping token attachment');
}
handler.next(options);
return;
}
// 저장된 액세스 토큰 가져오기
final service = authService;
print('[AuthInterceptor] AuthService available: ${service != null}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] AuthService available: ${service != null}');
}
if (service != null) {
final accessToken = await service.getAccessToken();
print('[AuthInterceptor] Access token retrieved: ${accessToken != null ? 'Yes (${accessToken.substring(0, 10)}...)' : 'No'}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Access token retrieved: ${accessToken != null ? 'Yes (${accessToken.substring(0, 10)}...)' : 'No'}');
}
if (accessToken != null) {
options.headers['Authorization'] = 'Bearer $accessToken';
print('[AuthInterceptor] Authorization header set: Bearer ${accessToken.substring(0, 10)}...');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Authorization header set: Bearer ${accessToken.substring(0, 10)}...');
}
} else {
print('[AuthInterceptor] WARNING: No access token available for protected endpoint');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] WARNING: No access token available for protected endpoint');
}
}
} else {
print('[AuthInterceptor] ERROR: AuthService not available from GetIt');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] ERROR: AuthService not available from GetIt');
}
}
print('[AuthInterceptor] Final headers: ${options.headers}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Final headers: ${options.headers}');
}
handler.next(options);
}
@@ -61,30 +81,40 @@ class AuthInterceptor extends Interceptor {
DioException err,
ErrorInterceptorHandler handler,
) async {
print('[AuthInterceptor] onError: ${err.response?.statusCode} ${err.message}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] onError: ${err.response?.statusCode} ${err.message}');
}
// 401 Unauthorized 에러 처리
if (err.response?.statusCode == 401) {
// 인증 관련 엔드포인트는 재시도하지 않음
if (_isAuthEndpoint(err.requestOptions.path)) {
print('[AuthInterceptor] Auth endpoint 401 error, skipping retry');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Auth endpoint 401 error, skipping retry');
}
handler.next(err);
return;
}
final service = authService;
if (service != null) {
print('[AuthInterceptor] Attempting token refresh...');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Attempting token refresh...');
}
// 토큰 갱신 시도
final refreshResult = await service.refreshToken();
final refreshSuccess = refreshResult.fold(
(failure) {
print('[AuthInterceptor] Token refresh failed: ${failure.message}');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Token refresh failed: ${failure.message}');
}
return false;
},
(tokenResponse) {
print('[AuthInterceptor] Token refresh successful');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Token refresh successful');
}
return true;
},
);
@@ -95,7 +125,9 @@ class AuthInterceptor extends Interceptor {
final newAccessToken = await service.getAccessToken();
if (newAccessToken != null) {
print('[AuthInterceptor] Retrying request with new token');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Retrying request with new token');
}
err.requestOptions.headers['Authorization'] = 'Bearer $newAccessToken';
// dio 인스턴스를 통해 재시도
@@ -104,7 +136,9 @@ class AuthInterceptor extends Interceptor {
return;
}
} catch (e) {
print('[AuthInterceptor] Request retry failed: $e');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Request retry failed: $e');
}
// 재시도 실패
handler.next(err);
return;
@@ -112,7 +146,9 @@ class AuthInterceptor extends Interceptor {
}
// 토큰 갱신 실패 시 로그인 화면으로 이동
print('[AuthInterceptor] Clearing session due to auth failure');
if (Environment.enableLogging && kDebugMode) {
debugPrint('[AuthInterceptor] Clearing session due to auth failure');
}
await service.clearSession();
// TODO: Navigate to login screen
}

View File

@@ -6,8 +6,8 @@ part 'login_request.g.dart';
@freezed
class LoginRequest with _$LoginRequest {
const factory LoginRequest({
String? username,
String? email,
@JsonKey(includeIfNull: false) String? username,
@JsonKey(includeIfNull: false) String? email,
required String password,
}) = _LoginRequest;

View File

@@ -20,7 +20,9 @@ LoginRequest _$LoginRequestFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$LoginRequest {
@JsonKey(includeIfNull: false)
String? get username => throw _privateConstructorUsedError;
@JsonKey(includeIfNull: false)
String? get email => throw _privateConstructorUsedError;
String get password => throw _privateConstructorUsedError;
@@ -40,7 +42,10 @@ abstract class $LoginRequestCopyWith<$Res> {
LoginRequest value, $Res Function(LoginRequest) then) =
_$LoginRequestCopyWithImpl<$Res, LoginRequest>;
@useResult
$Res call({String? username, String? email, String password});
$Res call(
{@JsonKey(includeIfNull: false) String? username,
@JsonKey(includeIfNull: false) String? email,
String password});
}
/// @nodoc
@@ -87,7 +92,10 @@ abstract class _$$LoginRequestImplCopyWith<$Res>
__$$LoginRequestImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String? username, String? email, String password});
$Res call(
{@JsonKey(includeIfNull: false) String? username,
@JsonKey(includeIfNull: false) String? email,
String password});
}
/// @nodoc
@@ -127,14 +135,19 @@ class __$$LoginRequestImplCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$LoginRequestImpl implements _LoginRequest {
const _$LoginRequestImpl({this.username, this.email, required this.password});
const _$LoginRequestImpl(
{@JsonKey(includeIfNull: false) this.username,
@JsonKey(includeIfNull: false) this.email,
required this.password});
factory _$LoginRequestImpl.fromJson(Map<String, dynamic> json) =>
_$$LoginRequestImplFromJson(json);
@override
@JsonKey(includeIfNull: false)
final String? username;
@override
@JsonKey(includeIfNull: false)
final String? email;
@override
final String password;
@@ -178,16 +191,18 @@ class _$LoginRequestImpl implements _LoginRequest {
abstract class _LoginRequest implements LoginRequest {
const factory _LoginRequest(
{final String? username,
final String? email,
{@JsonKey(includeIfNull: false) final String? username,
@JsonKey(includeIfNull: false) final String? email,
required final String password}) = _$LoginRequestImpl;
factory _LoginRequest.fromJson(Map<String, dynamic> json) =
_$LoginRequestImpl.fromJson;
@override
@JsonKey(includeIfNull: false)
String? get username;
@override
@JsonKey(includeIfNull: false)
String? get email;
@override
String get password;

View File

@@ -15,7 +15,7 @@ _$LoginRequestImpl _$$LoginRequestImplFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> _$$LoginRequestImplToJson(_$LoginRequestImpl instance) =>
<String, dynamic>{
'username': instance.username,
'email': instance.email,
if (instance.username case final value?) 'username': value,
if (instance.email case final value?) 'email': value,
'password': instance.password,
};

View File

@@ -0,0 +1,34 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'equipment_dto.freezed.dart';
part 'equipment_dto.g.dart';
@freezed
class EquipmentDto with _$EquipmentDto {
const factory EquipmentDto({
required int id,
@JsonKey(name: 'serial_number') required String serialNumber,
required String name,
String? category,
String? manufacturer,
String? model,
required String status,
@JsonKey(name: 'company_id') required int companyId,
@JsonKey(name: 'company_name') String? companyName,
@JsonKey(name: 'warehouse_location_id') int? warehouseLocationId,
@JsonKey(name: 'warehouse_name') String? warehouseName,
@JsonKey(name: 'purchase_date') String? purchaseDate,
@JsonKey(name: 'purchase_price') double? purchasePrice,
@JsonKey(name: 'current_value') double? currentValue,
@JsonKey(name: 'warranty_expiry') String? warrantyExpiry,
@JsonKey(name: 'last_maintenance_date') String? lastMaintenanceDate,
@JsonKey(name: 'next_maintenance_date') String? nextMaintenanceDate,
Map<String, dynamic>? specifications,
String? notes,
@JsonKey(name: 'created_at') DateTime? createdAt,
@JsonKey(name: 'updated_at') DateTime? updatedAt,
}) = _EquipmentDto;
factory EquipmentDto.fromJson(Map<String, dynamic> json) =>
_$EquipmentDtoFromJson(json);
}

View File

@@ -0,0 +1,657 @@
// 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 'equipment_dto.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');
EquipmentDto _$EquipmentDtoFromJson(Map<String, dynamic> json) {
return _EquipmentDto.fromJson(json);
}
/// @nodoc
mixin _$EquipmentDto {
int get id => throw _privateConstructorUsedError;
@JsonKey(name: 'serial_number')
String get serialNumber => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String? get category => throw _privateConstructorUsedError;
String? get manufacturer => throw _privateConstructorUsedError;
String? get model => throw _privateConstructorUsedError;
String get status => throw _privateConstructorUsedError;
@JsonKey(name: 'company_id')
int get companyId => throw _privateConstructorUsedError;
@JsonKey(name: 'company_name')
String? get companyName => throw _privateConstructorUsedError;
@JsonKey(name: 'warehouse_location_id')
int? get warehouseLocationId => throw _privateConstructorUsedError;
@JsonKey(name: 'warehouse_name')
String? get warehouseName => throw _privateConstructorUsedError;
@JsonKey(name: 'purchase_date')
String? get purchaseDate => throw _privateConstructorUsedError;
@JsonKey(name: 'purchase_price')
double? get purchasePrice => throw _privateConstructorUsedError;
@JsonKey(name: 'current_value')
double? get currentValue => throw _privateConstructorUsedError;
@JsonKey(name: 'warranty_expiry')
String? get warrantyExpiry => throw _privateConstructorUsedError;
@JsonKey(name: 'last_maintenance_date')
String? get lastMaintenanceDate => throw _privateConstructorUsedError;
@JsonKey(name: 'next_maintenance_date')
String? get nextMaintenanceDate => throw _privateConstructorUsedError;
Map<String, dynamic>? get specifications =>
throw _privateConstructorUsedError;
String? get notes => throw _privateConstructorUsedError;
@JsonKey(name: 'created_at')
DateTime? get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: 'updated_at')
DateTime? get updatedAt => throw _privateConstructorUsedError;
/// Serializes this EquipmentDto to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of EquipmentDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$EquipmentDtoCopyWith<EquipmentDto> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $EquipmentDtoCopyWith<$Res> {
factory $EquipmentDtoCopyWith(
EquipmentDto value, $Res Function(EquipmentDto) then) =
_$EquipmentDtoCopyWithImpl<$Res, EquipmentDto>;
@useResult
$Res call(
{int id,
@JsonKey(name: 'serial_number') String serialNumber,
String name,
String? category,
String? manufacturer,
String? model,
String status,
@JsonKey(name: 'company_id') int companyId,
@JsonKey(name: 'company_name') String? companyName,
@JsonKey(name: 'warehouse_location_id') int? warehouseLocationId,
@JsonKey(name: 'warehouse_name') String? warehouseName,
@JsonKey(name: 'purchase_date') String? purchaseDate,
@JsonKey(name: 'purchase_price') double? purchasePrice,
@JsonKey(name: 'current_value') double? currentValue,
@JsonKey(name: 'warranty_expiry') String? warrantyExpiry,
@JsonKey(name: 'last_maintenance_date') String? lastMaintenanceDate,
@JsonKey(name: 'next_maintenance_date') String? nextMaintenanceDate,
Map<String, dynamic>? specifications,
String? notes,
@JsonKey(name: 'created_at') DateTime? createdAt,
@JsonKey(name: 'updated_at') DateTime? updatedAt});
}
/// @nodoc
class _$EquipmentDtoCopyWithImpl<$Res, $Val extends EquipmentDto>
implements $EquipmentDtoCopyWith<$Res> {
_$EquipmentDtoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of EquipmentDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? serialNumber = null,
Object? name = null,
Object? category = freezed,
Object? manufacturer = freezed,
Object? model = freezed,
Object? status = null,
Object? companyId = null,
Object? companyName = freezed,
Object? warehouseLocationId = freezed,
Object? warehouseName = freezed,
Object? purchaseDate = freezed,
Object? purchasePrice = freezed,
Object? currentValue = freezed,
Object? warrantyExpiry = freezed,
Object? lastMaintenanceDate = freezed,
Object? nextMaintenanceDate = freezed,
Object? specifications = freezed,
Object? notes = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
serialNumber: null == serialNumber
? _value.serialNumber
: serialNumber // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
category: freezed == category
? _value.category
: category // ignore: cast_nullable_to_non_nullable
as String?,
manufacturer: freezed == manufacturer
? _value.manufacturer
: manufacturer // ignore: cast_nullable_to_non_nullable
as String?,
model: freezed == model
? _value.model
: model // ignore: cast_nullable_to_non_nullable
as String?,
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
companyId: null == companyId
? _value.companyId
: companyId // ignore: cast_nullable_to_non_nullable
as int,
companyName: freezed == companyName
? _value.companyName
: companyName // ignore: cast_nullable_to_non_nullable
as String?,
warehouseLocationId: freezed == warehouseLocationId
? _value.warehouseLocationId
: warehouseLocationId // ignore: cast_nullable_to_non_nullable
as int?,
warehouseName: freezed == warehouseName
? _value.warehouseName
: warehouseName // ignore: cast_nullable_to_non_nullable
as String?,
purchaseDate: freezed == purchaseDate
? _value.purchaseDate
: purchaseDate // ignore: cast_nullable_to_non_nullable
as String?,
purchasePrice: freezed == purchasePrice
? _value.purchasePrice
: purchasePrice // ignore: cast_nullable_to_non_nullable
as double?,
currentValue: freezed == currentValue
? _value.currentValue
: currentValue // ignore: cast_nullable_to_non_nullable
as double?,
warrantyExpiry: freezed == warrantyExpiry
? _value.warrantyExpiry
: warrantyExpiry // ignore: cast_nullable_to_non_nullable
as String?,
lastMaintenanceDate: freezed == lastMaintenanceDate
? _value.lastMaintenanceDate
: lastMaintenanceDate // ignore: cast_nullable_to_non_nullable
as String?,
nextMaintenanceDate: freezed == nextMaintenanceDate
? _value.nextMaintenanceDate
: nextMaintenanceDate // ignore: cast_nullable_to_non_nullable
as String?,
specifications: freezed == specifications
? _value.specifications
: specifications // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
notes: freezed == notes
? _value.notes
: notes // ignore: cast_nullable_to_non_nullable
as String?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
) as $Val);
}
}
/// @nodoc
abstract class _$$EquipmentDtoImplCopyWith<$Res>
implements $EquipmentDtoCopyWith<$Res> {
factory _$$EquipmentDtoImplCopyWith(
_$EquipmentDtoImpl value, $Res Function(_$EquipmentDtoImpl) then) =
__$$EquipmentDtoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
@JsonKey(name: 'serial_number') String serialNumber,
String name,
String? category,
String? manufacturer,
String? model,
String status,
@JsonKey(name: 'company_id') int companyId,
@JsonKey(name: 'company_name') String? companyName,
@JsonKey(name: 'warehouse_location_id') int? warehouseLocationId,
@JsonKey(name: 'warehouse_name') String? warehouseName,
@JsonKey(name: 'purchase_date') String? purchaseDate,
@JsonKey(name: 'purchase_price') double? purchasePrice,
@JsonKey(name: 'current_value') double? currentValue,
@JsonKey(name: 'warranty_expiry') String? warrantyExpiry,
@JsonKey(name: 'last_maintenance_date') String? lastMaintenanceDate,
@JsonKey(name: 'next_maintenance_date') String? nextMaintenanceDate,
Map<String, dynamic>? specifications,
String? notes,
@JsonKey(name: 'created_at') DateTime? createdAt,
@JsonKey(name: 'updated_at') DateTime? updatedAt});
}
/// @nodoc
class __$$EquipmentDtoImplCopyWithImpl<$Res>
extends _$EquipmentDtoCopyWithImpl<$Res, _$EquipmentDtoImpl>
implements _$$EquipmentDtoImplCopyWith<$Res> {
__$$EquipmentDtoImplCopyWithImpl(
_$EquipmentDtoImpl _value, $Res Function(_$EquipmentDtoImpl) _then)
: super(_value, _then);
/// Create a copy of EquipmentDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? serialNumber = null,
Object? name = null,
Object? category = freezed,
Object? manufacturer = freezed,
Object? model = freezed,
Object? status = null,
Object? companyId = null,
Object? companyName = freezed,
Object? warehouseLocationId = freezed,
Object? warehouseName = freezed,
Object? purchaseDate = freezed,
Object? purchasePrice = freezed,
Object? currentValue = freezed,
Object? warrantyExpiry = freezed,
Object? lastMaintenanceDate = freezed,
Object? nextMaintenanceDate = freezed,
Object? specifications = freezed,
Object? notes = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(_$EquipmentDtoImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
serialNumber: null == serialNumber
? _value.serialNumber
: serialNumber // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
category: freezed == category
? _value.category
: category // ignore: cast_nullable_to_non_nullable
as String?,
manufacturer: freezed == manufacturer
? _value.manufacturer
: manufacturer // ignore: cast_nullable_to_non_nullable
as String?,
model: freezed == model
? _value.model
: model // ignore: cast_nullable_to_non_nullable
as String?,
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
companyId: null == companyId
? _value.companyId
: companyId // ignore: cast_nullable_to_non_nullable
as int,
companyName: freezed == companyName
? _value.companyName
: companyName // ignore: cast_nullable_to_non_nullable
as String?,
warehouseLocationId: freezed == warehouseLocationId
? _value.warehouseLocationId
: warehouseLocationId // ignore: cast_nullable_to_non_nullable
as int?,
warehouseName: freezed == warehouseName
? _value.warehouseName
: warehouseName // ignore: cast_nullable_to_non_nullable
as String?,
purchaseDate: freezed == purchaseDate
? _value.purchaseDate
: purchaseDate // ignore: cast_nullable_to_non_nullable
as String?,
purchasePrice: freezed == purchasePrice
? _value.purchasePrice
: purchasePrice // ignore: cast_nullable_to_non_nullable
as double?,
currentValue: freezed == currentValue
? _value.currentValue
: currentValue // ignore: cast_nullable_to_non_nullable
as double?,
warrantyExpiry: freezed == warrantyExpiry
? _value.warrantyExpiry
: warrantyExpiry // ignore: cast_nullable_to_non_nullable
as String?,
lastMaintenanceDate: freezed == lastMaintenanceDate
? _value.lastMaintenanceDate
: lastMaintenanceDate // ignore: cast_nullable_to_non_nullable
as String?,
nextMaintenanceDate: freezed == nextMaintenanceDate
? _value.nextMaintenanceDate
: nextMaintenanceDate // ignore: cast_nullable_to_non_nullable
as String?,
specifications: freezed == specifications
? _value._specifications
: specifications // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
notes: freezed == notes
? _value.notes
: notes // ignore: cast_nullable_to_non_nullable
as String?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
));
}
}
/// @nodoc
@JsonSerializable()
class _$EquipmentDtoImpl implements _EquipmentDto {
const _$EquipmentDtoImpl(
{required this.id,
@JsonKey(name: 'serial_number') required this.serialNumber,
required this.name,
this.category,
this.manufacturer,
this.model,
required this.status,
@JsonKey(name: 'company_id') required this.companyId,
@JsonKey(name: 'company_name') this.companyName,
@JsonKey(name: 'warehouse_location_id') this.warehouseLocationId,
@JsonKey(name: 'warehouse_name') this.warehouseName,
@JsonKey(name: 'purchase_date') this.purchaseDate,
@JsonKey(name: 'purchase_price') this.purchasePrice,
@JsonKey(name: 'current_value') this.currentValue,
@JsonKey(name: 'warranty_expiry') this.warrantyExpiry,
@JsonKey(name: 'last_maintenance_date') this.lastMaintenanceDate,
@JsonKey(name: 'next_maintenance_date') this.nextMaintenanceDate,
final Map<String, dynamic>? specifications,
this.notes,
@JsonKey(name: 'created_at') this.createdAt,
@JsonKey(name: 'updated_at') this.updatedAt})
: _specifications = specifications;
factory _$EquipmentDtoImpl.fromJson(Map<String, dynamic> json) =>
_$$EquipmentDtoImplFromJson(json);
@override
final int id;
@override
@JsonKey(name: 'serial_number')
final String serialNumber;
@override
final String name;
@override
final String? category;
@override
final String? manufacturer;
@override
final String? model;
@override
final String status;
@override
@JsonKey(name: 'company_id')
final int companyId;
@override
@JsonKey(name: 'company_name')
final String? companyName;
@override
@JsonKey(name: 'warehouse_location_id')
final int? warehouseLocationId;
@override
@JsonKey(name: 'warehouse_name')
final String? warehouseName;
@override
@JsonKey(name: 'purchase_date')
final String? purchaseDate;
@override
@JsonKey(name: 'purchase_price')
final double? purchasePrice;
@override
@JsonKey(name: 'current_value')
final double? currentValue;
@override
@JsonKey(name: 'warranty_expiry')
final String? warrantyExpiry;
@override
@JsonKey(name: 'last_maintenance_date')
final String? lastMaintenanceDate;
@override
@JsonKey(name: 'next_maintenance_date')
final String? nextMaintenanceDate;
final Map<String, dynamic>? _specifications;
@override
Map<String, dynamic>? get specifications {
final value = _specifications;
if (value == null) return null;
if (_specifications is EqualUnmodifiableMapView) return _specifications;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
@override
final String? notes;
@override
@JsonKey(name: 'created_at')
final DateTime? createdAt;
@override
@JsonKey(name: 'updated_at')
final DateTime? updatedAt;
@override
String toString() {
return 'EquipmentDto(id: $id, serialNumber: $serialNumber, name: $name, category: $category, manufacturer: $manufacturer, model: $model, status: $status, companyId: $companyId, companyName: $companyName, warehouseLocationId: $warehouseLocationId, warehouseName: $warehouseName, purchaseDate: $purchaseDate, purchasePrice: $purchasePrice, currentValue: $currentValue, warrantyExpiry: $warrantyExpiry, lastMaintenanceDate: $lastMaintenanceDate, nextMaintenanceDate: $nextMaintenanceDate, specifications: $specifications, notes: $notes, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$EquipmentDtoImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.serialNumber, serialNumber) ||
other.serialNumber == serialNumber) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.category, category) ||
other.category == category) &&
(identical(other.manufacturer, manufacturer) ||
other.manufacturer == manufacturer) &&
(identical(other.model, model) || other.model == model) &&
(identical(other.status, status) || other.status == status) &&
(identical(other.companyId, companyId) ||
other.companyId == companyId) &&
(identical(other.companyName, companyName) ||
other.companyName == companyName) &&
(identical(other.warehouseLocationId, warehouseLocationId) ||
other.warehouseLocationId == warehouseLocationId) &&
(identical(other.warehouseName, warehouseName) ||
other.warehouseName == warehouseName) &&
(identical(other.purchaseDate, purchaseDate) ||
other.purchaseDate == purchaseDate) &&
(identical(other.purchasePrice, purchasePrice) ||
other.purchasePrice == purchasePrice) &&
(identical(other.currentValue, currentValue) ||
other.currentValue == currentValue) &&
(identical(other.warrantyExpiry, warrantyExpiry) ||
other.warrantyExpiry == warrantyExpiry) &&
(identical(other.lastMaintenanceDate, lastMaintenanceDate) ||
other.lastMaintenanceDate == lastMaintenanceDate) &&
(identical(other.nextMaintenanceDate, nextMaintenanceDate) ||
other.nextMaintenanceDate == nextMaintenanceDate) &&
const DeepCollectionEquality()
.equals(other._specifications, _specifications) &&
(identical(other.notes, notes) || other.notes == notes) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hashAll([
runtimeType,
id,
serialNumber,
name,
category,
manufacturer,
model,
status,
companyId,
companyName,
warehouseLocationId,
warehouseName,
purchaseDate,
purchasePrice,
currentValue,
warrantyExpiry,
lastMaintenanceDate,
nextMaintenanceDate,
const DeepCollectionEquality().hash(_specifications),
notes,
createdAt,
updatedAt
]);
/// Create a copy of EquipmentDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$EquipmentDtoImplCopyWith<_$EquipmentDtoImpl> get copyWith =>
__$$EquipmentDtoImplCopyWithImpl<_$EquipmentDtoImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$EquipmentDtoImplToJson(
this,
);
}
}
abstract class _EquipmentDto implements EquipmentDto {
const factory _EquipmentDto(
{required final int id,
@JsonKey(name: 'serial_number') required final String serialNumber,
required final String name,
final String? category,
final String? manufacturer,
final String? model,
required final String status,
@JsonKey(name: 'company_id') required final int companyId,
@JsonKey(name: 'company_name') final String? companyName,
@JsonKey(name: 'warehouse_location_id') final int? warehouseLocationId,
@JsonKey(name: 'warehouse_name') final String? warehouseName,
@JsonKey(name: 'purchase_date') final String? purchaseDate,
@JsonKey(name: 'purchase_price') final double? purchasePrice,
@JsonKey(name: 'current_value') final double? currentValue,
@JsonKey(name: 'warranty_expiry') final String? warrantyExpiry,
@JsonKey(name: 'last_maintenance_date') final String? lastMaintenanceDate,
@JsonKey(name: 'next_maintenance_date') final String? nextMaintenanceDate,
final Map<String, dynamic>? specifications,
final String? notes,
@JsonKey(name: 'created_at') final DateTime? createdAt,
@JsonKey(name: 'updated_at')
final DateTime? updatedAt}) = _$EquipmentDtoImpl;
factory _EquipmentDto.fromJson(Map<String, dynamic> json) =
_$EquipmentDtoImpl.fromJson;
@override
int get id;
@override
@JsonKey(name: 'serial_number')
String get serialNumber;
@override
String get name;
@override
String? get category;
@override
String? get manufacturer;
@override
String? get model;
@override
String get status;
@override
@JsonKey(name: 'company_id')
int get companyId;
@override
@JsonKey(name: 'company_name')
String? get companyName;
@override
@JsonKey(name: 'warehouse_location_id')
int? get warehouseLocationId;
@override
@JsonKey(name: 'warehouse_name')
String? get warehouseName;
@override
@JsonKey(name: 'purchase_date')
String? get purchaseDate;
@override
@JsonKey(name: 'purchase_price')
double? get purchasePrice;
@override
@JsonKey(name: 'current_value')
double? get currentValue;
@override
@JsonKey(name: 'warranty_expiry')
String? get warrantyExpiry;
@override
@JsonKey(name: 'last_maintenance_date')
String? get lastMaintenanceDate;
@override
@JsonKey(name: 'next_maintenance_date')
String? get nextMaintenanceDate;
@override
Map<String, dynamic>? get specifications;
@override
String? get notes;
@override
@JsonKey(name: 'created_at')
DateTime? get createdAt;
@override
@JsonKey(name: 'updated_at')
DateTime? get updatedAt;
/// Create a copy of EquipmentDto
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$EquipmentDtoImplCopyWith<_$EquipmentDtoImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,61 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'equipment_dto.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$EquipmentDtoImpl _$$EquipmentDtoImplFromJson(Map<String, dynamic> json) =>
_$EquipmentDtoImpl(
id: (json['id'] as num).toInt(),
serialNumber: json['serial_number'] as String,
name: json['name'] as String,
category: json['category'] as String?,
manufacturer: json['manufacturer'] as String?,
model: json['model'] as String?,
status: json['status'] as String,
companyId: (json['company_id'] as num).toInt(),
companyName: json['company_name'] as String?,
warehouseLocationId: (json['warehouse_location_id'] as num?)?.toInt(),
warehouseName: json['warehouse_name'] as String?,
purchaseDate: json['purchase_date'] as String?,
purchasePrice: (json['purchase_price'] as num?)?.toDouble(),
currentValue: (json['current_value'] as num?)?.toDouble(),
warrantyExpiry: json['warranty_expiry'] as String?,
lastMaintenanceDate: json['last_maintenance_date'] as String?,
nextMaintenanceDate: json['next_maintenance_date'] as String?,
specifications: json['specifications'] as Map<String, dynamic>?,
notes: json['notes'] as String?,
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
);
Map<String, dynamic> _$$EquipmentDtoImplToJson(_$EquipmentDtoImpl instance) =>
<String, dynamic>{
'id': instance.id,
'serial_number': instance.serialNumber,
'name': instance.name,
'category': instance.category,
'manufacturer': instance.manufacturer,
'model': instance.model,
'status': instance.status,
'company_id': instance.companyId,
'company_name': instance.companyName,
'warehouse_location_id': instance.warehouseLocationId,
'warehouse_name': instance.warehouseName,
'purchase_date': instance.purchaseDate,
'purchase_price': instance.purchasePrice,
'current_value': instance.currentValue,
'warranty_expiry': instance.warrantyExpiry,
'last_maintenance_date': instance.lastMaintenanceDate,
'next_maintenance_date': instance.nextMaintenanceDate,
'specifications': instance.specifications,
'notes': instance.notes,
'created_at': instance.createdAt?.toIso8601String(),
'updated_at': instance.updatedAt?.toIso8601String(),
};

View File

@@ -15,6 +15,7 @@ class CreateWarehouseLocationRequest with _$CreateWarehouseLocationRequest {
String? country,
int? capacity,
@JsonKey(name: 'manager_id') int? managerId,
@JsonKey(name: 'company_id') int? companyId,
}) = _CreateWarehouseLocationRequest;
factory CreateWarehouseLocationRequest.fromJson(Map<String, dynamic> json) =>

View File

@@ -31,6 +31,8 @@ mixin _$CreateWarehouseLocationRequest {
int? get capacity => throw _privateConstructorUsedError;
@JsonKey(name: 'manager_id')
int? get managerId => throw _privateConstructorUsedError;
@JsonKey(name: 'company_id')
int? get companyId => throw _privateConstructorUsedError;
/// Serializes this CreateWarehouseLocationRequest to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -58,7 +60,8 @@ abstract class $CreateWarehouseLocationRequestCopyWith<$Res> {
@JsonKey(name: 'postal_code') String? postalCode,
String? country,
int? capacity,
@JsonKey(name: 'manager_id') int? managerId});
@JsonKey(name: 'manager_id') int? managerId,
@JsonKey(name: 'company_id') int? companyId});
}
/// @nodoc
@@ -85,6 +88,7 @@ class _$CreateWarehouseLocationRequestCopyWithImpl<$Res,
Object? country = freezed,
Object? capacity = freezed,
Object? managerId = freezed,
Object? companyId = freezed,
}) {
return _then(_value.copyWith(
name: null == name
@@ -119,6 +123,10 @@ class _$CreateWarehouseLocationRequestCopyWithImpl<$Res,
? _value.managerId
: managerId // ignore: cast_nullable_to_non_nullable
as int?,
companyId: freezed == companyId
? _value.companyId
: companyId // ignore: cast_nullable_to_non_nullable
as int?,
) as $Val);
}
}
@@ -140,7 +148,8 @@ abstract class _$$CreateWarehouseLocationRequestImplCopyWith<$Res>
@JsonKey(name: 'postal_code') String? postalCode,
String? country,
int? capacity,
@JsonKey(name: 'manager_id') int? managerId});
@JsonKey(name: 'manager_id') int? managerId,
@JsonKey(name: 'company_id') int? companyId});
}
/// @nodoc
@@ -166,6 +175,7 @@ class __$$CreateWarehouseLocationRequestImplCopyWithImpl<$Res>
Object? country = freezed,
Object? capacity = freezed,
Object? managerId = freezed,
Object? companyId = freezed,
}) {
return _then(_$CreateWarehouseLocationRequestImpl(
name: null == name
@@ -200,6 +210,10 @@ class __$$CreateWarehouseLocationRequestImplCopyWithImpl<$Res>
? _value.managerId
: managerId // ignore: cast_nullable_to_non_nullable
as int?,
companyId: freezed == companyId
? _value.companyId
: companyId // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
@@ -216,7 +230,8 @@ class _$CreateWarehouseLocationRequestImpl
@JsonKey(name: 'postal_code') this.postalCode,
this.country,
this.capacity,
@JsonKey(name: 'manager_id') this.managerId});
@JsonKey(name: 'manager_id') this.managerId,
@JsonKey(name: 'company_id') this.companyId});
factory _$CreateWarehouseLocationRequestImpl.fromJson(
Map<String, dynamic> json) =>
@@ -240,10 +255,13 @@ class _$CreateWarehouseLocationRequestImpl
@override
@JsonKey(name: 'manager_id')
final int? managerId;
@override
@JsonKey(name: 'company_id')
final int? companyId;
@override
String toString() {
return 'CreateWarehouseLocationRequest(name: $name, address: $address, city: $city, state: $state, postalCode: $postalCode, country: $country, capacity: $capacity, managerId: $managerId)';
return 'CreateWarehouseLocationRequest(name: $name, address: $address, city: $city, state: $state, postalCode: $postalCode, country: $country, capacity: $capacity, managerId: $managerId, companyId: $companyId)';
}
@override
@@ -261,13 +279,15 @@ class _$CreateWarehouseLocationRequestImpl
(identical(other.capacity, capacity) ||
other.capacity == capacity) &&
(identical(other.managerId, managerId) ||
other.managerId == managerId));
other.managerId == managerId) &&
(identical(other.companyId, companyId) ||
other.companyId == companyId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, name, address, city, state,
postalCode, country, capacity, managerId);
postalCode, country, capacity, managerId, companyId);
/// Create a copy of CreateWarehouseLocationRequest
/// with the given fields replaced by the non-null parameter values.
@@ -297,7 +317,8 @@ abstract class _CreateWarehouseLocationRequest
@JsonKey(name: 'postal_code') final String? postalCode,
final String? country,
final int? capacity,
@JsonKey(name: 'manager_id') final int? managerId}) =
@JsonKey(name: 'manager_id') final int? managerId,
@JsonKey(name: 'company_id') final int? companyId}) =
_$CreateWarehouseLocationRequestImpl;
factory _CreateWarehouseLocationRequest.fromJson(Map<String, dynamic> json) =
@@ -321,6 +342,9 @@ abstract class _CreateWarehouseLocationRequest
@override
@JsonKey(name: 'manager_id')
int? get managerId;
@override
@JsonKey(name: 'company_id')
int? get companyId;
/// Create a copy of CreateWarehouseLocationRequest
/// with the given fields replaced by the non-null parameter values.

View File

@@ -17,6 +17,7 @@ _$CreateWarehouseLocationRequestImpl
country: json['country'] as String?,
capacity: (json['capacity'] as num?)?.toInt(),
managerId: (json['manager_id'] as num?)?.toInt(),
companyId: (json['company_id'] as num?)?.toInt(),
);
Map<String, dynamic> _$$CreateWarehouseLocationRequestImplToJson(
@@ -30,6 +31,7 @@ Map<String, dynamic> _$$CreateWarehouseLocationRequestImplToJson(
'country': instance.country,
'capacity': instance.capacity,
'manager_id': instance.managerId,
'company_id': instance.companyId,
};
_$UpdateWarehouseLocationRequestImpl