fix: API 응답 파싱 오류 수정 및 에러 처리 개선

주요 변경사항:
- 창고 관리 API 응답 구조와 DTO 불일치 수정
  - WarehouseLocationDto에 code, manager_phone 필드 추가
  - RemoteDataSource에서 API 응답을 DTO 구조에 맞게 변환
- 회사 관리 API 응답 파싱 오류 수정
  - CompanyResponse의 필수 필드를 nullable로 변경
  - PaginatedResponse 구조 매핑 로직 개선
- 에러 처리 및 로깅 개선
  - Service Layer에 상세 에러 로깅 추가
  - Controller에서 에러 타입별 처리
- 새로운 유틸리티 추가
  - ResponseInterceptor: API 응답 정규화
  - DebugLogger: 디버깅 도구
  - HealthCheckService: 서버 상태 확인
- 문서화
  - API 통합 테스트 가이드
  - 에러 분석 보고서
  - 리팩토링 계획서
This commit is contained in:
JiWoong Sul
2025-07-31 19:15:39 +09:00
parent ad2c699ff7
commit f08b7fec79
89 changed files with 10521 additions and 892 deletions

View File

@@ -45,14 +45,14 @@ class CompanyResponse with _$CompanyResponse {
required String name,
required String address,
@JsonKey(name: 'contact_name') required String contactName,
@JsonKey(name: 'contact_position') required String contactPosition,
@JsonKey(name: 'contact_position') String? contactPosition, // nullable로 변경
@JsonKey(name: 'contact_phone') required String contactPhone,
@JsonKey(name: 'contact_email') required String contactEmail,
@JsonKey(name: 'company_types') @Default([]) List<String> companyTypes,
String? remark,
@JsonKey(name: 'is_active') required bool isActive,
@JsonKey(name: 'created_at') required DateTime createdAt,
@JsonKey(name: 'updated_at') required DateTime updatedAt,
@JsonKey(name: 'updated_at') DateTime? updatedAt, // nullable로 변경
@JsonKey(name: 'address_id') int? addressId,
}) = _CompanyResponse;

View File

@@ -719,7 +719,8 @@ mixin _$CompanyResponse {
@JsonKey(name: 'contact_name')
String get contactName => throw _privateConstructorUsedError;
@JsonKey(name: 'contact_position')
String get contactPosition => throw _privateConstructorUsedError;
String? get contactPosition =>
throw _privateConstructorUsedError; // nullable로 변경
@JsonKey(name: 'contact_phone')
String get contactPhone => throw _privateConstructorUsedError;
@JsonKey(name: 'contact_email')
@@ -732,7 +733,7 @@ mixin _$CompanyResponse {
@JsonKey(name: 'created_at')
DateTime get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: 'updated_at')
DateTime get updatedAt => throw _privateConstructorUsedError;
DateTime? get updatedAt => throw _privateConstructorUsedError; // nullable로 변경
@JsonKey(name: 'address_id')
int? get addressId => throw _privateConstructorUsedError;
@@ -757,14 +758,14 @@ abstract class $CompanyResponseCopyWith<$Res> {
String name,
String address,
@JsonKey(name: 'contact_name') String contactName,
@JsonKey(name: 'contact_position') String contactPosition,
@JsonKey(name: 'contact_position') String? contactPosition,
@JsonKey(name: 'contact_phone') String contactPhone,
@JsonKey(name: 'contact_email') String contactEmail,
@JsonKey(name: 'company_types') List<String> companyTypes,
String? remark,
@JsonKey(name: 'is_active') bool isActive,
@JsonKey(name: 'created_at') DateTime createdAt,
@JsonKey(name: 'updated_at') DateTime updatedAt,
@JsonKey(name: 'updated_at') DateTime? updatedAt,
@JsonKey(name: 'address_id') int? addressId});
}
@@ -787,14 +788,14 @@ class _$CompanyResponseCopyWithImpl<$Res, $Val extends CompanyResponse>
Object? name = null,
Object? address = null,
Object? contactName = null,
Object? contactPosition = null,
Object? contactPosition = freezed,
Object? contactPhone = null,
Object? contactEmail = null,
Object? companyTypes = null,
Object? remark = freezed,
Object? isActive = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? updatedAt = freezed,
Object? addressId = freezed,
}) {
return _then(_value.copyWith(
@@ -814,10 +815,10 @@ class _$CompanyResponseCopyWithImpl<$Res, $Val extends CompanyResponse>
? _value.contactName
: contactName // ignore: cast_nullable_to_non_nullable
as String,
contactPosition: null == contactPosition
contactPosition: freezed == contactPosition
? _value.contactPosition
: contactPosition // ignore: cast_nullable_to_non_nullable
as String,
as String?,
contactPhone: null == contactPhone
? _value.contactPhone
: contactPhone // ignore: cast_nullable_to_non_nullable
@@ -842,10 +843,10 @@ class _$CompanyResponseCopyWithImpl<$Res, $Val extends CompanyResponse>
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
as DateTime?,
addressId: freezed == addressId
? _value.addressId
: addressId // ignore: cast_nullable_to_non_nullable
@@ -867,14 +868,14 @@ abstract class _$$CompanyResponseImplCopyWith<$Res>
String name,
String address,
@JsonKey(name: 'contact_name') String contactName,
@JsonKey(name: 'contact_position') String contactPosition,
@JsonKey(name: 'contact_position') String? contactPosition,
@JsonKey(name: 'contact_phone') String contactPhone,
@JsonKey(name: 'contact_email') String contactEmail,
@JsonKey(name: 'company_types') List<String> companyTypes,
String? remark,
@JsonKey(name: 'is_active') bool isActive,
@JsonKey(name: 'created_at') DateTime createdAt,
@JsonKey(name: 'updated_at') DateTime updatedAt,
@JsonKey(name: 'updated_at') DateTime? updatedAt,
@JsonKey(name: 'address_id') int? addressId});
}
@@ -895,14 +896,14 @@ class __$$CompanyResponseImplCopyWithImpl<$Res>
Object? name = null,
Object? address = null,
Object? contactName = null,
Object? contactPosition = null,
Object? contactPosition = freezed,
Object? contactPhone = null,
Object? contactEmail = null,
Object? companyTypes = null,
Object? remark = freezed,
Object? isActive = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? updatedAt = freezed,
Object? addressId = freezed,
}) {
return _then(_$CompanyResponseImpl(
@@ -922,10 +923,10 @@ class __$$CompanyResponseImplCopyWithImpl<$Res>
? _value.contactName
: contactName // ignore: cast_nullable_to_non_nullable
as String,
contactPosition: null == contactPosition
contactPosition: freezed == contactPosition
? _value.contactPosition
: contactPosition // ignore: cast_nullable_to_non_nullable
as String,
as String?,
contactPhone: null == contactPhone
? _value.contactPhone
: contactPhone // ignore: cast_nullable_to_non_nullable
@@ -950,10 +951,10 @@ class __$$CompanyResponseImplCopyWithImpl<$Res>
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
as DateTime?,
addressId: freezed == addressId
? _value.addressId
: addressId // ignore: cast_nullable_to_non_nullable
@@ -970,7 +971,7 @@ class _$CompanyResponseImpl implements _CompanyResponse {
required this.name,
required this.address,
@JsonKey(name: 'contact_name') required this.contactName,
@JsonKey(name: 'contact_position') required this.contactPosition,
@JsonKey(name: 'contact_position') this.contactPosition,
@JsonKey(name: 'contact_phone') required this.contactPhone,
@JsonKey(name: 'contact_email') required this.contactEmail,
@JsonKey(name: 'company_types')
@@ -978,7 +979,7 @@ class _$CompanyResponseImpl implements _CompanyResponse {
this.remark,
@JsonKey(name: 'is_active') required this.isActive,
@JsonKey(name: 'created_at') required this.createdAt,
@JsonKey(name: 'updated_at') required this.updatedAt,
@JsonKey(name: 'updated_at') this.updatedAt,
@JsonKey(name: 'address_id') this.addressId})
: _companyTypes = companyTypes;
@@ -996,7 +997,8 @@ class _$CompanyResponseImpl implements _CompanyResponse {
final String contactName;
@override
@JsonKey(name: 'contact_position')
final String contactPosition;
final String? contactPosition;
// nullable로 변경
@override
@JsonKey(name: 'contact_phone')
final String contactPhone;
@@ -1022,7 +1024,8 @@ class _$CompanyResponseImpl implements _CompanyResponse {
final DateTime createdAt;
@override
@JsonKey(name: 'updated_at')
final DateTime updatedAt;
final DateTime? updatedAt;
// nullable로 변경
@override
@JsonKey(name: 'address_id')
final int? addressId;
@@ -1098,20 +1101,20 @@ class _$CompanyResponseImpl implements _CompanyResponse {
abstract class _CompanyResponse implements CompanyResponse {
const factory _CompanyResponse(
{required final int id,
required final String name,
required final String address,
@JsonKey(name: 'contact_name') required final String contactName,
@JsonKey(name: 'contact_position') required final String contactPosition,
@JsonKey(name: 'contact_phone') required final String contactPhone,
@JsonKey(name: 'contact_email') required final String contactEmail,
@JsonKey(name: 'company_types') final List<String> companyTypes,
final String? remark,
@JsonKey(name: 'is_active') required final bool isActive,
@JsonKey(name: 'created_at') required final DateTime createdAt,
@JsonKey(name: 'updated_at') required final DateTime updatedAt,
@JsonKey(name: 'address_id')
final int? addressId}) = _$CompanyResponseImpl;
{required final int id,
required final String name,
required final String address,
@JsonKey(name: 'contact_name') required final String contactName,
@JsonKey(name: 'contact_position') final String? contactPosition,
@JsonKey(name: 'contact_phone') required final String contactPhone,
@JsonKey(name: 'contact_email') required final String contactEmail,
@JsonKey(name: 'company_types') final List<String> companyTypes,
final String? remark,
@JsonKey(name: 'is_active') required final bool isActive,
@JsonKey(name: 'created_at') required final DateTime createdAt,
@JsonKey(name: 'updated_at') final DateTime? updatedAt,
@JsonKey(name: 'address_id') final int? addressId}) =
_$CompanyResponseImpl;
factory _CompanyResponse.fromJson(Map<String, dynamic> json) =
_$CompanyResponseImpl.fromJson;
@@ -1127,7 +1130,7 @@ abstract class _CompanyResponse implements CompanyResponse {
String get contactName;
@override
@JsonKey(name: 'contact_position')
String get contactPosition;
String? get contactPosition; // nullable로 변경
@override
@JsonKey(name: 'contact_phone')
String get contactPhone;
@@ -1147,7 +1150,7 @@ abstract class _CompanyResponse implements CompanyResponse {
DateTime get createdAt;
@override
@JsonKey(name: 'updated_at')
DateTime get updatedAt;
DateTime? get updatedAt; // nullable로 변경
@override
@JsonKey(name: 'address_id')
int? get addressId;

View File

@@ -72,7 +72,7 @@ _$CompanyResponseImpl _$$CompanyResponseImplFromJson(
name: json['name'] as String,
address: json['address'] as String,
contactName: json['contact_name'] as String,
contactPosition: json['contact_position'] as String,
contactPosition: json['contact_position'] as String?,
contactPhone: json['contact_phone'] as String,
contactEmail: json['contact_email'] as String,
companyTypes: (json['company_types'] as List<dynamic>?)
@@ -82,7 +82,9 @@ _$CompanyResponseImpl _$$CompanyResponseImplFromJson(
remark: json['remark'] as String?,
isActive: json['is_active'] as bool,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
addressId: (json['address_id'] as num?)?.toInt(),
);
@@ -100,7 +102,7 @@ Map<String, dynamic> _$$CompanyResponseImplToJson(
'remark': instance.remark,
'is_active': instance.isActive,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'updated_at': instance.updatedAt?.toIso8601String(),
'address_id': instance.addressId,
};

View File

@@ -13,7 +13,9 @@ class CompanyListDto with _$CompanyListDto {
required String address,
@JsonKey(name: 'contact_name') required String contactName,
@JsonKey(name: 'contact_phone') required String contactPhone,
@JsonKey(name: 'contact_email') String? contactEmail,
@JsonKey(name: 'is_active') required bool isActive,
@JsonKey(name: 'created_at') DateTime? createdAt,
@JsonKey(name: 'branch_count') @Default(0) int branchCount,
}) = _CompanyListDto;

View File

@@ -27,8 +27,12 @@ mixin _$CompanyListDto {
String get contactName => throw _privateConstructorUsedError;
@JsonKey(name: 'contact_phone')
String get contactPhone => throw _privateConstructorUsedError;
@JsonKey(name: 'contact_email')
String? get contactEmail => throw _privateConstructorUsedError;
@JsonKey(name: 'is_active')
bool get isActive => throw _privateConstructorUsedError;
@JsonKey(name: 'created_at')
DateTime? get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: 'branch_count')
int get branchCount => throw _privateConstructorUsedError;
@@ -54,7 +58,9 @@ abstract class $CompanyListDtoCopyWith<$Res> {
String address,
@JsonKey(name: 'contact_name') String contactName,
@JsonKey(name: 'contact_phone') String contactPhone,
@JsonKey(name: 'contact_email') String? contactEmail,
@JsonKey(name: 'is_active') bool isActive,
@JsonKey(name: 'created_at') DateTime? createdAt,
@JsonKey(name: 'branch_count') int branchCount});
}
@@ -78,7 +84,9 @@ class _$CompanyListDtoCopyWithImpl<$Res, $Val extends CompanyListDto>
Object? address = null,
Object? contactName = null,
Object? contactPhone = null,
Object? contactEmail = freezed,
Object? isActive = null,
Object? createdAt = freezed,
Object? branchCount = null,
}) {
return _then(_value.copyWith(
@@ -102,10 +110,18 @@ class _$CompanyListDtoCopyWithImpl<$Res, $Val extends CompanyListDto>
? _value.contactPhone
: contactPhone // ignore: cast_nullable_to_non_nullable
as String,
contactEmail: freezed == contactEmail
? _value.contactEmail
: contactEmail // ignore: cast_nullable_to_non_nullable
as String?,
isActive: null == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
branchCount: null == branchCount
? _value.branchCount
: branchCount // ignore: cast_nullable_to_non_nullable
@@ -128,7 +144,9 @@ abstract class _$$CompanyListDtoImplCopyWith<$Res>
String address,
@JsonKey(name: 'contact_name') String contactName,
@JsonKey(name: 'contact_phone') String contactPhone,
@JsonKey(name: 'contact_email') String? contactEmail,
@JsonKey(name: 'is_active') bool isActive,
@JsonKey(name: 'created_at') DateTime? createdAt,
@JsonKey(name: 'branch_count') int branchCount});
}
@@ -150,7 +168,9 @@ class __$$CompanyListDtoImplCopyWithImpl<$Res>
Object? address = null,
Object? contactName = null,
Object? contactPhone = null,
Object? contactEmail = freezed,
Object? isActive = null,
Object? createdAt = freezed,
Object? branchCount = null,
}) {
return _then(_$CompanyListDtoImpl(
@@ -174,10 +194,18 @@ class __$$CompanyListDtoImplCopyWithImpl<$Res>
? _value.contactPhone
: contactPhone // ignore: cast_nullable_to_non_nullable
as String,
contactEmail: freezed == contactEmail
? _value.contactEmail
: contactEmail // ignore: cast_nullable_to_non_nullable
as String?,
isActive: null == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
branchCount: null == branchCount
? _value.branchCount
: branchCount // ignore: cast_nullable_to_non_nullable
@@ -195,7 +223,9 @@ class _$CompanyListDtoImpl implements _CompanyListDto {
required this.address,
@JsonKey(name: 'contact_name') required this.contactName,
@JsonKey(name: 'contact_phone') required this.contactPhone,
@JsonKey(name: 'contact_email') this.contactEmail,
@JsonKey(name: 'is_active') required this.isActive,
@JsonKey(name: 'created_at') this.createdAt,
@JsonKey(name: 'branch_count') this.branchCount = 0});
factory _$CompanyListDtoImpl.fromJson(Map<String, dynamic> json) =>
@@ -214,15 +244,21 @@ class _$CompanyListDtoImpl implements _CompanyListDto {
@JsonKey(name: 'contact_phone')
final String contactPhone;
@override
@JsonKey(name: 'contact_email')
final String? contactEmail;
@override
@JsonKey(name: 'is_active')
final bool isActive;
@override
@JsonKey(name: 'created_at')
final DateTime? createdAt;
@override
@JsonKey(name: 'branch_count')
final int branchCount;
@override
String toString() {
return 'CompanyListDto(id: $id, name: $name, address: $address, contactName: $contactName, contactPhone: $contactPhone, isActive: $isActive, branchCount: $branchCount)';
return 'CompanyListDto(id: $id, name: $name, address: $address, contactName: $contactName, contactPhone: $contactPhone, contactEmail: $contactEmail, isActive: $isActive, createdAt: $createdAt, branchCount: $branchCount)';
}
@override
@@ -237,8 +273,12 @@ class _$CompanyListDtoImpl implements _CompanyListDto {
other.contactName == contactName) &&
(identical(other.contactPhone, contactPhone) ||
other.contactPhone == contactPhone) &&
(identical(other.contactEmail, contactEmail) ||
other.contactEmail == contactEmail) &&
(identical(other.isActive, isActive) ||
other.isActive == isActive) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.branchCount, branchCount) ||
other.branchCount == branchCount));
}
@@ -246,7 +286,7 @@ class _$CompanyListDtoImpl implements _CompanyListDto {
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, name, address, contactName,
contactPhone, isActive, branchCount);
contactPhone, contactEmail, isActive, createdAt, branchCount);
/// Create a copy of CompanyListDto
/// with the given fields replaced by the non-null parameter values.
@@ -272,7 +312,9 @@ abstract class _CompanyListDto implements CompanyListDto {
required final String address,
@JsonKey(name: 'contact_name') required final String contactName,
@JsonKey(name: 'contact_phone') required final String contactPhone,
@JsonKey(name: 'contact_email') final String? contactEmail,
@JsonKey(name: 'is_active') required final bool isActive,
@JsonKey(name: 'created_at') final DateTime? createdAt,
@JsonKey(name: 'branch_count') final int branchCount}) =
_$CompanyListDtoImpl;
@@ -292,9 +334,15 @@ abstract class _CompanyListDto implements CompanyListDto {
@JsonKey(name: 'contact_phone')
String get contactPhone;
@override
@JsonKey(name: 'contact_email')
String? get contactEmail;
@override
@JsonKey(name: 'is_active')
bool get isActive;
@override
@JsonKey(name: 'created_at')
DateTime? get createdAt;
@override
@JsonKey(name: 'branch_count')
int get branchCount;

View File

@@ -13,7 +13,11 @@ _$CompanyListDtoImpl _$$CompanyListDtoImplFromJson(Map<String, dynamic> json) =>
address: json['address'] as String,
contactName: json['contact_name'] as String,
contactPhone: json['contact_phone'] as String,
contactEmail: json['contact_email'] as String?,
isActive: json['is_active'] as bool,
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
branchCount: (json['branch_count'] as num?)?.toInt() ?? 0,
);
@@ -25,7 +29,9 @@ Map<String, dynamic> _$$CompanyListDtoImplToJson(
'address': instance.address,
'contact_name': instance.contactName,
'contact_phone': instance.contactPhone,
'contact_email': instance.contactEmail,
'is_active': instance.isActive,
'created_at': instance.createdAt?.toIso8601String(),
'branch_count': instance.branchCount,
};