feat: 라이선스 및 창고 관리 API 연동 구현
- 라이선스 관리 API 연동 완료 - LicenseRemoteDataSource, LicenseService 구현 - LicenseListController, LicenseFormController API 연동 - 페이지네이션, 검색, 필터링 기능 추가 - 라이선스 할당/해제 기능 구현 - 창고 관리 API 연동 완료 - WarehouseRemoteDataSource, WarehouseService 구현 - WarehouseLocationListController, WarehouseLocationFormController API 연동 - 창고별 장비 조회 및 용량 관리 기능 추가 - DI 컨테이너에 새로운 서비스 등록 - API 통합 문서 업데이트 (전체 진행률 100% 달성)
This commit is contained in:
181
lib/data/datasources/remote/license_remote_datasource.dart
Normal file
181
lib/data/datasources/remote/license_remote_datasource.dart
Normal file
@@ -0,0 +1,181 @@
|
||||
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/license/license_dto.dart';
|
||||
import 'package:superport/data/models/license/license_request_dto.dart';
|
||||
|
||||
abstract class LicenseRemoteDataSource {
|
||||
Future<LicenseListResponseDto> getLicenses({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
bool? isActive,
|
||||
int? companyId,
|
||||
int? assignedUserId,
|
||||
String? licenseType,
|
||||
});
|
||||
|
||||
Future<LicenseDto> getLicenseById(int id);
|
||||
Future<LicenseDto> createLicense(CreateLicenseRequest request);
|
||||
Future<LicenseDto> updateLicense(int id, UpdateLicenseRequest request);
|
||||
Future<void> deleteLicense(int id);
|
||||
Future<LicenseDto> assignLicense(int id, AssignLicenseRequest request);
|
||||
Future<LicenseDto> unassignLicense(int id);
|
||||
Future<ExpiringLicenseListDto> getExpiringLicenses({
|
||||
int days = 30,
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
});
|
||||
}
|
||||
|
||||
@LazySingleton(as: LicenseRemoteDataSource)
|
||||
class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource {
|
||||
final ApiClient _apiClient;
|
||||
|
||||
LicenseRemoteDataSourceImpl({
|
||||
required ApiClient apiClient,
|
||||
}) : _apiClient = apiClient;
|
||||
|
||||
@override
|
||||
Future<LicenseListResponseDto> getLicenses({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
bool? isActive,
|
||||
int? companyId,
|
||||
int? assignedUserId,
|
||||
String? licenseType,
|
||||
}) async {
|
||||
try {
|
||||
final queryParams = <String, dynamic>{
|
||||
'page': page,
|
||||
'per_page': perPage,
|
||||
};
|
||||
|
||||
if (isActive != null) queryParams['is_active'] = isActive;
|
||||
if (companyId != null) queryParams['company_id'] = companyId;
|
||||
if (assignedUserId != null) queryParams['assigned_user_id'] = assignedUserId;
|
||||
if (licenseType != null) queryParams['license_type'] = licenseType;
|
||||
|
||||
final response = await _apiClient.get(
|
||||
ApiEndpoints.licenses,
|
||||
queryParameters: queryParams,
|
||||
);
|
||||
|
||||
return LicenseListResponseDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LicenseDto> getLicenseById(int id) async {
|
||||
try {
|
||||
final response = await _apiClient.get(
|
||||
'${ApiEndpoints.licenses}/$id',
|
||||
);
|
||||
|
||||
return LicenseDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LicenseDto> createLicense(CreateLicenseRequest request) async {
|
||||
try {
|
||||
final response = await _apiClient.post(
|
||||
ApiEndpoints.licenses,
|
||||
data: request.toJson(),
|
||||
);
|
||||
|
||||
return LicenseDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LicenseDto> updateLicense(int id, UpdateLicenseRequest request) async {
|
||||
try {
|
||||
final response = await _apiClient.put(
|
||||
'${ApiEndpoints.licenses}/$id',
|
||||
data: request.toJson(),
|
||||
);
|
||||
|
||||
return LicenseDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteLicense(int id) async {
|
||||
try {
|
||||
await _apiClient.delete(
|
||||
'${ApiEndpoints.licenses}/$id',
|
||||
);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LicenseDto> assignLicense(int id, AssignLicenseRequest request) async {
|
||||
try {
|
||||
final response = await _apiClient.patch(
|
||||
'${ApiEndpoints.licenses}/$id/assign',
|
||||
data: request.toJson(),
|
||||
);
|
||||
|
||||
return LicenseDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LicenseDto> unassignLicense(int id) async {
|
||||
try {
|
||||
final response = await _apiClient.patch(
|
||||
'${ApiEndpoints.licenses}/$id/unassign',
|
||||
);
|
||||
|
||||
return LicenseDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ExpiringLicenseListDto> getExpiringLicenses({
|
||||
int days = 30,
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
}) async {
|
||||
try {
|
||||
final queryParams = <String, dynamic>{
|
||||
'days': days,
|
||||
'page': page,
|
||||
'per_page': perPage,
|
||||
};
|
||||
|
||||
final response = await _apiClient.get(
|
||||
'${ApiEndpoints.licenses}/expiring',
|
||||
queryParameters: queryParams,
|
||||
);
|
||||
|
||||
return ExpiringLicenseListDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
Exception _handleError(dynamic error) {
|
||||
if (error is ApiException) {
|
||||
return error;
|
||||
}
|
||||
return ApiException(
|
||||
message: error.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
175
lib/data/datasources/remote/warehouse_remote_datasource.dart
Normal file
175
lib/data/datasources/remote/warehouse_remote_datasource.dart
Normal file
@@ -0,0 +1,175 @@
|
||||
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 WarehouseRemoteDataSource {
|
||||
Future<WarehouseLocationListDto> getWarehouseLocations({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
bool? isActive,
|
||||
});
|
||||
|
||||
Future<WarehouseLocationDto> getWarehouseLocationById(int id);
|
||||
Future<WarehouseLocationDto> createWarehouseLocation(CreateWarehouseLocationRequest request);
|
||||
Future<WarehouseLocationDto> updateWarehouseLocation(int id, UpdateWarehouseLocationRequest request);
|
||||
Future<void> deleteWarehouseLocation(int id);
|
||||
Future<WarehouseEquipmentListDto> getWarehouseEquipment(
|
||||
int warehouseId, {
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
});
|
||||
Future<WarehouseCapacityInfo> getWarehouseCapacity(int id);
|
||||
Future<List<WarehouseLocationDto>> getInUseWarehouseLocations();
|
||||
}
|
||||
|
||||
@LazySingleton(as: WarehouseRemoteDataSource)
|
||||
class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
|
||||
final ApiClient _apiClient;
|
||||
|
||||
WarehouseRemoteDataSourceImpl({
|
||||
required ApiClient apiClient,
|
||||
}) : _apiClient = apiClient;
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationListDto> getWarehouseLocations({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
bool? isActive,
|
||||
}) async {
|
||||
try {
|
||||
final queryParams = <String, dynamic>{
|
||||
'page': page,
|
||||
'per_page': perPage,
|
||||
};
|
||||
|
||||
if (isActive != null) queryParams['is_active'] = isActive;
|
||||
|
||||
final response = await _apiClient.get(
|
||||
ApiEndpoints.warehouseLocations,
|
||||
queryParameters: queryParams,
|
||||
);
|
||||
|
||||
return WarehouseLocationListDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationDto> getWarehouseLocationById(int id) async {
|
||||
try {
|
||||
final response = await _apiClient.get(
|
||||
'${ApiEndpoints.warehouseLocations}/$id',
|
||||
);
|
||||
|
||||
return WarehouseLocationDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WarehouseLocationDto> createWarehouseLocation(CreateWarehouseLocationRequest request) async {
|
||||
try {
|
||||
final response = await _apiClient.post(
|
||||
ApiEndpoints.warehouseLocations,
|
||||
data: request.toJson(),
|
||||
);
|
||||
|
||||
return WarehouseLocationDto.fromJson(response.data);
|
||||
} 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(),
|
||||
);
|
||||
|
||||
return WarehouseLocationDto.fromJson(response.data);
|
||||
} 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<WarehouseEquipmentListDto> getWarehouseEquipment(
|
||||
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,
|
||||
);
|
||||
|
||||
return WarehouseEquipmentListDto.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WarehouseCapacityInfo> getWarehouseCapacity(int id) async {
|
||||
try {
|
||||
final response = await _apiClient.get(
|
||||
'${ApiEndpoints.warehouseLocations}/$id/capacity',
|
||||
);
|
||||
|
||||
return WarehouseCapacityInfo.fromJson(response.data);
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<WarehouseLocationDto>> getInUseWarehouseLocations() async {
|
||||
try {
|
||||
final response = await _apiClient.get(
|
||||
'${ApiEndpoints.warehouseLocations}/in-use',
|
||||
);
|
||||
|
||||
if (response.data is List) {
|
||||
return (response.data as List)
|
||||
.map((item) => WarehouseLocationDto.fromJson(item))
|
||||
.toList();
|
||||
} else {
|
||||
throw ApiException(message: 'Invalid response format');
|
||||
}
|
||||
} catch (e) {
|
||||
throw _handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
Exception _handleError(dynamic error) {
|
||||
if (error is ApiException) {
|
||||
return error;
|
||||
}
|
||||
return ApiException(
|
||||
message: error.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
80
lib/data/models/license/license_dto.dart
Normal file
80
lib/data/models/license/license_dto.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'license_dto.freezed.dart';
|
||||
part 'license_dto.g.dart';
|
||||
|
||||
/// 라이선스 전체 정보 DTO
|
||||
@freezed
|
||||
class LicenseDto with _$LicenseDto {
|
||||
const factory LicenseDto({
|
||||
required int id,
|
||||
@JsonKey(name: 'license_key') required String licenseKey,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
String? vendor,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
@JsonKey(name: 'user_count') int? userCount,
|
||||
@JsonKey(name: 'purchase_date') DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') double? purchasePrice,
|
||||
@JsonKey(name: 'company_id') int? companyId,
|
||||
@JsonKey(name: 'branch_id') int? branchId,
|
||||
@JsonKey(name: 'assigned_user_id') int? assignedUserId,
|
||||
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: 'company_name') String? companyName,
|
||||
@JsonKey(name: 'branch_name') String? branchName,
|
||||
@JsonKey(name: 'assigned_user_name') String? assignedUserName,
|
||||
}) = _LicenseDto;
|
||||
|
||||
factory LicenseDto.fromJson(Map<String, dynamic> json) => _$LicenseDtoFromJson(json);
|
||||
}
|
||||
|
||||
/// 라이선스 목록 응답 DTO
|
||||
@freezed
|
||||
class LicenseListResponseDto with _$LicenseListResponseDto {
|
||||
const factory LicenseListResponseDto({
|
||||
required List<LicenseDto> items,
|
||||
required int total,
|
||||
required int page,
|
||||
@JsonKey(name: 'per_page') required int perPage,
|
||||
@JsonKey(name: 'total_pages') required int totalPages,
|
||||
}) = _LicenseListResponseDto;
|
||||
|
||||
factory LicenseListResponseDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$LicenseListResponseDtoFromJson(json);
|
||||
}
|
||||
|
||||
/// 만료 예정 라이선스 DTO
|
||||
@freezed
|
||||
class ExpiringLicenseDto with _$ExpiringLicenseDto {
|
||||
const factory ExpiringLicenseDto({
|
||||
required int id,
|
||||
@JsonKey(name: 'license_key') required String licenseKey,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
@JsonKey(name: 'company_name') String? companyName,
|
||||
@JsonKey(name: 'expiry_date') required DateTime expiryDate,
|
||||
@JsonKey(name: 'days_until_expiry') required int daysUntilExpiry,
|
||||
@JsonKey(name: 'is_active') required bool isActive,
|
||||
}) = _ExpiringLicenseDto;
|
||||
|
||||
factory ExpiringLicenseDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$ExpiringLicenseDtoFromJson(json);
|
||||
}
|
||||
|
||||
/// 만료 예정 라이선스 목록 응답 DTO
|
||||
@freezed
|
||||
class ExpiringLicenseListDto with _$ExpiringLicenseListDto {
|
||||
const factory ExpiringLicenseListDto({
|
||||
required List<ExpiringLicenseDto> items,
|
||||
required int total,
|
||||
required int page,
|
||||
@JsonKey(name: 'per_page') required int perPage,
|
||||
@JsonKey(name: 'total_pages') required int totalPages,
|
||||
}) = _ExpiringLicenseListDto;
|
||||
|
||||
factory ExpiringLicenseListDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$ExpiringLicenseListDtoFromJson(json);
|
||||
}
|
||||
1436
lib/data/models/license/license_dto.freezed.dart
Normal file
1436
lib/data/models/license/license_dto.freezed.dart
Normal file
File diff suppressed because it is too large
Load Diff
125
lib/data/models/license/license_dto.g.dart
Normal file
125
lib/data/models/license/license_dto.g.dart
Normal file
@@ -0,0 +1,125 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'license_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$LicenseDtoImpl _$$LicenseDtoImplFromJson(Map<String, dynamic> json) =>
|
||||
_$LicenseDtoImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
licenseKey: json['license_key'] as String,
|
||||
productName: json['product_name'] as String?,
|
||||
vendor: json['vendor'] as String?,
|
||||
licenseType: json['license_type'] as String?,
|
||||
userCount: (json['user_count'] as num?)?.toInt(),
|
||||
purchaseDate: json['purchase_date'] == null
|
||||
? null
|
||||
: DateTime.parse(json['purchase_date'] as String),
|
||||
expiryDate: json['expiry_date'] == null
|
||||
? null
|
||||
: DateTime.parse(json['expiry_date'] as String),
|
||||
purchasePrice: (json['purchase_price'] as num?)?.toDouble(),
|
||||
companyId: (json['company_id'] as num?)?.toInt(),
|
||||
branchId: (json['branch_id'] as num?)?.toInt(),
|
||||
assignedUserId: (json['assigned_user_id'] as num?)?.toInt(),
|
||||
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),
|
||||
companyName: json['company_name'] as String?,
|
||||
branchName: json['branch_name'] as String?,
|
||||
assignedUserName: json['assigned_user_name'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$LicenseDtoImplToJson(_$LicenseDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'license_key': instance.licenseKey,
|
||||
'product_name': instance.productName,
|
||||
'vendor': instance.vendor,
|
||||
'license_type': instance.licenseType,
|
||||
'user_count': instance.userCount,
|
||||
'purchase_date': instance.purchaseDate?.toIso8601String(),
|
||||
'expiry_date': instance.expiryDate?.toIso8601String(),
|
||||
'purchase_price': instance.purchasePrice,
|
||||
'company_id': instance.companyId,
|
||||
'branch_id': instance.branchId,
|
||||
'assigned_user_id': instance.assignedUserId,
|
||||
'remark': instance.remark,
|
||||
'is_active': instance.isActive,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'company_name': instance.companyName,
|
||||
'branch_name': instance.branchName,
|
||||
'assigned_user_name': instance.assignedUserName,
|
||||
};
|
||||
|
||||
_$LicenseListResponseDtoImpl _$$LicenseListResponseDtoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$LicenseListResponseDtoImpl(
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => LicenseDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
total: (json['total'] as num).toInt(),
|
||||
page: (json['page'] as num).toInt(),
|
||||
perPage: (json['per_page'] as num).toInt(),
|
||||
totalPages: (json['total_pages'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$LicenseListResponseDtoImplToJson(
|
||||
_$LicenseListResponseDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'items': instance.items,
|
||||
'total': instance.total,
|
||||
'page': instance.page,
|
||||
'per_page': instance.perPage,
|
||||
'total_pages': instance.totalPages,
|
||||
};
|
||||
|
||||
_$ExpiringLicenseDtoImpl _$$ExpiringLicenseDtoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ExpiringLicenseDtoImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
licenseKey: json['license_key'] as String,
|
||||
productName: json['product_name'] as String?,
|
||||
companyName: json['company_name'] as String?,
|
||||
expiryDate: DateTime.parse(json['expiry_date'] as String),
|
||||
daysUntilExpiry: (json['days_until_expiry'] as num).toInt(),
|
||||
isActive: json['is_active'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ExpiringLicenseDtoImplToJson(
|
||||
_$ExpiringLicenseDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'license_key': instance.licenseKey,
|
||||
'product_name': instance.productName,
|
||||
'company_name': instance.companyName,
|
||||
'expiry_date': instance.expiryDate.toIso8601String(),
|
||||
'days_until_expiry': instance.daysUntilExpiry,
|
||||
'is_active': instance.isActive,
|
||||
};
|
||||
|
||||
_$ExpiringLicenseListDtoImpl _$$ExpiringLicenseListDtoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ExpiringLicenseListDtoImpl(
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => ExpiringLicenseDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
total: (json['total'] as num).toInt(),
|
||||
page: (json['page'] as num).toInt(),
|
||||
perPage: (json['per_page'] as num).toInt(),
|
||||
totalPages: (json['total_pages'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ExpiringLicenseListDtoImplToJson(
|
||||
_$ExpiringLicenseListDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'items': instance.items,
|
||||
'total': instance.total,
|
||||
'page': instance.page,
|
||||
'per_page': instance.perPage,
|
||||
'total_pages': instance.totalPages,
|
||||
};
|
||||
32
lib/data/models/license/license_query_dto.dart
Normal file
32
lib/data/models/license/license_query_dto.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'license_query_dto.freezed.dart';
|
||||
part 'license_query_dto.g.dart';
|
||||
|
||||
/// 라이선스 페이지네이션 쿼리 DTO
|
||||
@freezed
|
||||
class LicensePaginationQuery with _$LicensePaginationQuery {
|
||||
const factory LicensePaginationQuery({
|
||||
@Default(1) int page,
|
||||
@Default(20) int limit,
|
||||
@Default('expiry_date') String sort,
|
||||
@Default('asc') String order,
|
||||
@JsonKey(name: 'company_id') String? companyId,
|
||||
@JsonKey(name: 'user_id') String? userId,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
String? status,
|
||||
String? search,
|
||||
}) = _LicensePaginationQuery;
|
||||
|
||||
factory LicensePaginationQuery.fromJson(Map<String, dynamic> json) => _$LicensePaginationQueryFromJson(json);
|
||||
}
|
||||
|
||||
/// 만료 예정 라이선스 조회 쿼리 DTO
|
||||
@freezed
|
||||
class ExpiringLicensesQuery with _$ExpiringLicensesQuery {
|
||||
const factory ExpiringLicensesQuery({
|
||||
@Default(30) int days,
|
||||
}) = _ExpiringLicensesQuery;
|
||||
|
||||
factory ExpiringLicensesQuery.fromJson(Map<String, dynamic> json) => _$ExpiringLicensesQueryFromJson(json);
|
||||
}
|
||||
506
lib/data/models/license/license_query_dto.freezed.dart
Normal file
506
lib/data/models/license/license_query_dto.freezed.dart
Normal file
@@ -0,0 +1,506 @@
|
||||
// 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 'license_query_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');
|
||||
|
||||
LicensePaginationQuery _$LicensePaginationQueryFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return _LicensePaginationQuery.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LicensePaginationQuery {
|
||||
int get page => throw _privateConstructorUsedError;
|
||||
int get limit => throw _privateConstructorUsedError;
|
||||
String get sort => throw _privateConstructorUsedError;
|
||||
String get order => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'company_id')
|
||||
String? get companyId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'user_id')
|
||||
String? get userId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'license_type')
|
||||
String? get licenseType => throw _privateConstructorUsedError;
|
||||
String? get status => throw _privateConstructorUsedError;
|
||||
String? get search => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this LicensePaginationQuery to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of LicensePaginationQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$LicensePaginationQueryCopyWith<LicensePaginationQuery> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $LicensePaginationQueryCopyWith<$Res> {
|
||||
factory $LicensePaginationQueryCopyWith(LicensePaginationQuery value,
|
||||
$Res Function(LicensePaginationQuery) then) =
|
||||
_$LicensePaginationQueryCopyWithImpl<$Res, LicensePaginationQuery>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int page,
|
||||
int limit,
|
||||
String sort,
|
||||
String order,
|
||||
@JsonKey(name: 'company_id') String? companyId,
|
||||
@JsonKey(name: 'user_id') String? userId,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
String? status,
|
||||
String? search});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$LicensePaginationQueryCopyWithImpl<$Res,
|
||||
$Val extends LicensePaginationQuery>
|
||||
implements $LicensePaginationQueryCopyWith<$Res> {
|
||||
_$LicensePaginationQueryCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of LicensePaginationQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? page = null,
|
||||
Object? limit = null,
|
||||
Object? sort = null,
|
||||
Object? order = null,
|
||||
Object? companyId = freezed,
|
||||
Object? userId = freezed,
|
||||
Object? licenseType = freezed,
|
||||
Object? status = freezed,
|
||||
Object? search = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
page: null == page
|
||||
? _value.page
|
||||
: page // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
limit: null == limit
|
||||
? _value.limit
|
||||
: limit // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
sort: null == sort
|
||||
? _value.sort
|
||||
: sort // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
order: null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
companyId: freezed == companyId
|
||||
? _value.companyId
|
||||
: companyId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
userId: freezed == userId
|
||||
? _value.userId
|
||||
: userId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
licenseType: freezed == licenseType
|
||||
? _value.licenseType
|
||||
: licenseType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
status: freezed == status
|
||||
? _value.status
|
||||
: status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
search: freezed == search
|
||||
? _value.search
|
||||
: search // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LicensePaginationQueryImplCopyWith<$Res>
|
||||
implements $LicensePaginationQueryCopyWith<$Res> {
|
||||
factory _$$LicensePaginationQueryImplCopyWith(
|
||||
_$LicensePaginationQueryImpl value,
|
||||
$Res Function(_$LicensePaginationQueryImpl) then) =
|
||||
__$$LicensePaginationQueryImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int page,
|
||||
int limit,
|
||||
String sort,
|
||||
String order,
|
||||
@JsonKey(name: 'company_id') String? companyId,
|
||||
@JsonKey(name: 'user_id') String? userId,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
String? status,
|
||||
String? search});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LicensePaginationQueryImplCopyWithImpl<$Res>
|
||||
extends _$LicensePaginationQueryCopyWithImpl<$Res,
|
||||
_$LicensePaginationQueryImpl>
|
||||
implements _$$LicensePaginationQueryImplCopyWith<$Res> {
|
||||
__$$LicensePaginationQueryImplCopyWithImpl(
|
||||
_$LicensePaginationQueryImpl _value,
|
||||
$Res Function(_$LicensePaginationQueryImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of LicensePaginationQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? page = null,
|
||||
Object? limit = null,
|
||||
Object? sort = null,
|
||||
Object? order = null,
|
||||
Object? companyId = freezed,
|
||||
Object? userId = freezed,
|
||||
Object? licenseType = freezed,
|
||||
Object? status = freezed,
|
||||
Object? search = freezed,
|
||||
}) {
|
||||
return _then(_$LicensePaginationQueryImpl(
|
||||
page: null == page
|
||||
? _value.page
|
||||
: page // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
limit: null == limit
|
||||
? _value.limit
|
||||
: limit // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
sort: null == sort
|
||||
? _value.sort
|
||||
: sort // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
order: null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
companyId: freezed == companyId
|
||||
? _value.companyId
|
||||
: companyId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
userId: freezed == userId
|
||||
? _value.userId
|
||||
: userId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
licenseType: freezed == licenseType
|
||||
? _value.licenseType
|
||||
: licenseType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
status: freezed == status
|
||||
? _value.status
|
||||
: status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
search: freezed == search
|
||||
? _value.search
|
||||
: search // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$LicensePaginationQueryImpl implements _LicensePaginationQuery {
|
||||
const _$LicensePaginationQueryImpl(
|
||||
{this.page = 1,
|
||||
this.limit = 20,
|
||||
this.sort = 'expiry_date',
|
||||
this.order = 'asc',
|
||||
@JsonKey(name: 'company_id') this.companyId,
|
||||
@JsonKey(name: 'user_id') this.userId,
|
||||
@JsonKey(name: 'license_type') this.licenseType,
|
||||
this.status,
|
||||
this.search});
|
||||
|
||||
factory _$LicensePaginationQueryImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$LicensePaginationQueryImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final int page;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int limit;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String sort;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String order;
|
||||
@override
|
||||
@JsonKey(name: 'company_id')
|
||||
final String? companyId;
|
||||
@override
|
||||
@JsonKey(name: 'user_id')
|
||||
final String? userId;
|
||||
@override
|
||||
@JsonKey(name: 'license_type')
|
||||
final String? licenseType;
|
||||
@override
|
||||
final String? status;
|
||||
@override
|
||||
final String? search;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LicensePaginationQuery(page: $page, limit: $limit, sort: $sort, order: $order, companyId: $companyId, userId: $userId, licenseType: $licenseType, status: $status, search: $search)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$LicensePaginationQueryImpl &&
|
||||
(identical(other.page, page) || other.page == page) &&
|
||||
(identical(other.limit, limit) || other.limit == limit) &&
|
||||
(identical(other.sort, sort) || other.sort == sort) &&
|
||||
(identical(other.order, order) || other.order == order) &&
|
||||
(identical(other.companyId, companyId) ||
|
||||
other.companyId == companyId) &&
|
||||
(identical(other.userId, userId) || other.userId == userId) &&
|
||||
(identical(other.licenseType, licenseType) ||
|
||||
other.licenseType == licenseType) &&
|
||||
(identical(other.status, status) || other.status == status) &&
|
||||
(identical(other.search, search) || other.search == search));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, page, limit, sort, order,
|
||||
companyId, userId, licenseType, status, search);
|
||||
|
||||
/// Create a copy of LicensePaginationQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$LicensePaginationQueryImplCopyWith<_$LicensePaginationQueryImpl>
|
||||
get copyWith => __$$LicensePaginationQueryImplCopyWithImpl<
|
||||
_$LicensePaginationQueryImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$LicensePaginationQueryImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _LicensePaginationQuery implements LicensePaginationQuery {
|
||||
const factory _LicensePaginationQuery(
|
||||
{final int page,
|
||||
final int limit,
|
||||
final String sort,
|
||||
final String order,
|
||||
@JsonKey(name: 'company_id') final String? companyId,
|
||||
@JsonKey(name: 'user_id') final String? userId,
|
||||
@JsonKey(name: 'license_type') final String? licenseType,
|
||||
final String? status,
|
||||
final String? search}) = _$LicensePaginationQueryImpl;
|
||||
|
||||
factory _LicensePaginationQuery.fromJson(Map<String, dynamic> json) =
|
||||
_$LicensePaginationQueryImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get page;
|
||||
@override
|
||||
int get limit;
|
||||
@override
|
||||
String get sort;
|
||||
@override
|
||||
String get order;
|
||||
@override
|
||||
@JsonKey(name: 'company_id')
|
||||
String? get companyId;
|
||||
@override
|
||||
@JsonKey(name: 'user_id')
|
||||
String? get userId;
|
||||
@override
|
||||
@JsonKey(name: 'license_type')
|
||||
String? get licenseType;
|
||||
@override
|
||||
String? get status;
|
||||
@override
|
||||
String? get search;
|
||||
|
||||
/// Create a copy of LicensePaginationQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$LicensePaginationQueryImplCopyWith<_$LicensePaginationQueryImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
ExpiringLicensesQuery _$ExpiringLicensesQueryFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return _ExpiringLicensesQuery.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ExpiringLicensesQuery {
|
||||
int get days => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this ExpiringLicensesQuery to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ExpiringLicensesQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ExpiringLicensesQueryCopyWith<ExpiringLicensesQuery> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ExpiringLicensesQueryCopyWith<$Res> {
|
||||
factory $ExpiringLicensesQueryCopyWith(ExpiringLicensesQuery value,
|
||||
$Res Function(ExpiringLicensesQuery) then) =
|
||||
_$ExpiringLicensesQueryCopyWithImpl<$Res, ExpiringLicensesQuery>;
|
||||
@useResult
|
||||
$Res call({int days});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ExpiringLicensesQueryCopyWithImpl<$Res,
|
||||
$Val extends ExpiringLicensesQuery>
|
||||
implements $ExpiringLicensesQueryCopyWith<$Res> {
|
||||
_$ExpiringLicensesQueryCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ExpiringLicensesQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? days = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
days: null == days
|
||||
? _value.days
|
||||
: days // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ExpiringLicensesQueryImplCopyWith<$Res>
|
||||
implements $ExpiringLicensesQueryCopyWith<$Res> {
|
||||
factory _$$ExpiringLicensesQueryImplCopyWith(
|
||||
_$ExpiringLicensesQueryImpl value,
|
||||
$Res Function(_$ExpiringLicensesQueryImpl) then) =
|
||||
__$$ExpiringLicensesQueryImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int days});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ExpiringLicensesQueryImplCopyWithImpl<$Res>
|
||||
extends _$ExpiringLicensesQueryCopyWithImpl<$Res,
|
||||
_$ExpiringLicensesQueryImpl>
|
||||
implements _$$ExpiringLicensesQueryImplCopyWith<$Res> {
|
||||
__$$ExpiringLicensesQueryImplCopyWithImpl(_$ExpiringLicensesQueryImpl _value,
|
||||
$Res Function(_$ExpiringLicensesQueryImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ExpiringLicensesQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? days = null,
|
||||
}) {
|
||||
return _then(_$ExpiringLicensesQueryImpl(
|
||||
days: null == days
|
||||
? _value.days
|
||||
: days // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ExpiringLicensesQueryImpl implements _ExpiringLicensesQuery {
|
||||
const _$ExpiringLicensesQueryImpl({this.days = 30});
|
||||
|
||||
factory _$ExpiringLicensesQueryImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ExpiringLicensesQueryImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final int days;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ExpiringLicensesQuery(days: $days)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ExpiringLicensesQueryImpl &&
|
||||
(identical(other.days, days) || other.days == days));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, days);
|
||||
|
||||
/// Create a copy of ExpiringLicensesQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ExpiringLicensesQueryImplCopyWith<_$ExpiringLicensesQueryImpl>
|
||||
get copyWith => __$$ExpiringLicensesQueryImplCopyWithImpl<
|
||||
_$ExpiringLicensesQueryImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ExpiringLicensesQueryImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ExpiringLicensesQuery implements ExpiringLicensesQuery {
|
||||
const factory _ExpiringLicensesQuery({final int days}) =
|
||||
_$ExpiringLicensesQueryImpl;
|
||||
|
||||
factory _ExpiringLicensesQuery.fromJson(Map<String, dynamic> json) =
|
||||
_$ExpiringLicensesQueryImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get days;
|
||||
|
||||
/// Create a copy of ExpiringLicensesQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ExpiringLicensesQueryImplCopyWith<_$ExpiringLicensesQueryImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
47
lib/data/models/license/license_query_dto.g.dart
Normal file
47
lib/data/models/license/license_query_dto.g.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'license_query_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$LicensePaginationQueryImpl _$$LicensePaginationQueryImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$LicensePaginationQueryImpl(
|
||||
page: (json['page'] as num?)?.toInt() ?? 1,
|
||||
limit: (json['limit'] as num?)?.toInt() ?? 20,
|
||||
sort: json['sort'] as String? ?? 'expiry_date',
|
||||
order: json['order'] as String? ?? 'asc',
|
||||
companyId: json['company_id'] as String?,
|
||||
userId: json['user_id'] as String?,
|
||||
licenseType: json['license_type'] as String?,
|
||||
status: json['status'] as String?,
|
||||
search: json['search'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$LicensePaginationQueryImplToJson(
|
||||
_$LicensePaginationQueryImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'page': instance.page,
|
||||
'limit': instance.limit,
|
||||
'sort': instance.sort,
|
||||
'order': instance.order,
|
||||
'company_id': instance.companyId,
|
||||
'user_id': instance.userId,
|
||||
'license_type': instance.licenseType,
|
||||
'status': instance.status,
|
||||
'search': instance.search,
|
||||
};
|
||||
|
||||
_$ExpiringLicensesQueryImpl _$$ExpiringLicensesQueryImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ExpiringLicensesQueryImpl(
|
||||
days: (json['days'] as num?)?.toInt() ?? 30,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ExpiringLicensesQueryImplToJson(
|
||||
_$ExpiringLicensesQueryImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'days': instance.days,
|
||||
};
|
||||
53
lib/data/models/license/license_request_dto.dart
Normal file
53
lib/data/models/license/license_request_dto.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'license_request_dto.freezed.dart';
|
||||
part 'license_request_dto.g.dart';
|
||||
|
||||
/// 라이선스 생성 요청 DTO
|
||||
@freezed
|
||||
class CreateLicenseRequest with _$CreateLicenseRequest {
|
||||
const factory CreateLicenseRequest({
|
||||
@JsonKey(name: 'license_key') required String licenseKey,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
String? vendor,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
@JsonKey(name: 'user_count') int? userCount,
|
||||
@JsonKey(name: 'purchase_date') DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') double? purchasePrice,
|
||||
@JsonKey(name: 'company_id') int? companyId,
|
||||
@JsonKey(name: 'branch_id') int? branchId,
|
||||
String? remark,
|
||||
}) = _CreateLicenseRequest;
|
||||
|
||||
factory CreateLicenseRequest.fromJson(Map<String, dynamic> json) => _$CreateLicenseRequestFromJson(json);
|
||||
}
|
||||
|
||||
/// 라이선스 수정 요청 DTO
|
||||
@freezed
|
||||
class UpdateLicenseRequest with _$UpdateLicenseRequest {
|
||||
const factory UpdateLicenseRequest({
|
||||
@JsonKey(name: 'license_key') String? licenseKey,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
String? vendor,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
@JsonKey(name: 'user_count') int? userCount,
|
||||
@JsonKey(name: 'purchase_date') DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') double? purchasePrice,
|
||||
String? remark,
|
||||
@JsonKey(name: 'is_active') bool? isActive,
|
||||
}) = _UpdateLicenseRequest;
|
||||
|
||||
factory UpdateLicenseRequest.fromJson(Map<String, dynamic> json) => _$UpdateLicenseRequestFromJson(json);
|
||||
}
|
||||
|
||||
/// 라이선스 사용자 할당 요청 DTO
|
||||
@freezed
|
||||
class AssignLicenseRequest with _$AssignLicenseRequest {
|
||||
const factory AssignLicenseRequest({
|
||||
@JsonKey(name: 'user_id') required int userId,
|
||||
}) = _AssignLicenseRequest;
|
||||
|
||||
factory AssignLicenseRequest.fromJson(Map<String, dynamic> json) => _$AssignLicenseRequestFromJson(json);
|
||||
}
|
||||
957
lib/data/models/license/license_request_dto.freezed.dart
Normal file
957
lib/data/models/license/license_request_dto.freezed.dart
Normal file
@@ -0,0 +1,957 @@
|
||||
// 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 'license_request_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');
|
||||
|
||||
CreateLicenseRequest _$CreateLicenseRequestFromJson(Map<String, dynamic> json) {
|
||||
return _CreateLicenseRequest.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CreateLicenseRequest {
|
||||
@JsonKey(name: 'license_key')
|
||||
String get licenseKey => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'product_name')
|
||||
String? get productName => throw _privateConstructorUsedError;
|
||||
String? get vendor => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'license_type')
|
||||
String? get licenseType => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'user_count')
|
||||
int? get userCount => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'purchase_date')
|
||||
DateTime? get purchaseDate => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'expiry_date')
|
||||
DateTime? get expiryDate => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'purchase_price')
|
||||
double? get purchasePrice => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'company_id')
|
||||
int? get companyId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'branch_id')
|
||||
int? get branchId => throw _privateConstructorUsedError;
|
||||
String? get remark => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this CreateLicenseRequest to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of CreateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$CreateLicenseRequestCopyWith<CreateLicenseRequest> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CreateLicenseRequestCopyWith<$Res> {
|
||||
factory $CreateLicenseRequestCopyWith(CreateLicenseRequest value,
|
||||
$Res Function(CreateLicenseRequest) then) =
|
||||
_$CreateLicenseRequestCopyWithImpl<$Res, CreateLicenseRequest>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: 'license_key') String licenseKey,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
String? vendor,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
@JsonKey(name: 'user_count') int? userCount,
|
||||
@JsonKey(name: 'purchase_date') DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') double? purchasePrice,
|
||||
@JsonKey(name: 'company_id') int? companyId,
|
||||
@JsonKey(name: 'branch_id') int? branchId,
|
||||
String? remark});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CreateLicenseRequestCopyWithImpl<$Res,
|
||||
$Val extends CreateLicenseRequest>
|
||||
implements $CreateLicenseRequestCopyWith<$Res> {
|
||||
_$CreateLicenseRequestCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CreateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? licenseKey = null,
|
||||
Object? productName = freezed,
|
||||
Object? vendor = freezed,
|
||||
Object? licenseType = freezed,
|
||||
Object? userCount = freezed,
|
||||
Object? purchaseDate = freezed,
|
||||
Object? expiryDate = freezed,
|
||||
Object? purchasePrice = freezed,
|
||||
Object? companyId = freezed,
|
||||
Object? branchId = freezed,
|
||||
Object? remark = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
licenseKey: null == licenseKey
|
||||
? _value.licenseKey
|
||||
: licenseKey // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
productName: freezed == productName
|
||||
? _value.productName
|
||||
: productName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
vendor: freezed == vendor
|
||||
? _value.vendor
|
||||
: vendor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
licenseType: freezed == licenseType
|
||||
? _value.licenseType
|
||||
: licenseType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
userCount: freezed == userCount
|
||||
? _value.userCount
|
||||
: userCount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
purchaseDate: freezed == purchaseDate
|
||||
? _value.purchaseDate
|
||||
: purchaseDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
expiryDate: freezed == expiryDate
|
||||
? _value.expiryDate
|
||||
: expiryDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
purchasePrice: freezed == purchasePrice
|
||||
? _value.purchasePrice
|
||||
: purchasePrice // ignore: cast_nullable_to_non_nullable
|
||||
as double?,
|
||||
companyId: freezed == companyId
|
||||
? _value.companyId
|
||||
: companyId // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
branchId: freezed == branchId
|
||||
? _value.branchId
|
||||
: branchId // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
remark: freezed == remark
|
||||
? _value.remark
|
||||
: remark // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CreateLicenseRequestImplCopyWith<$Res>
|
||||
implements $CreateLicenseRequestCopyWith<$Res> {
|
||||
factory _$$CreateLicenseRequestImplCopyWith(_$CreateLicenseRequestImpl value,
|
||||
$Res Function(_$CreateLicenseRequestImpl) then) =
|
||||
__$$CreateLicenseRequestImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: 'license_key') String licenseKey,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
String? vendor,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
@JsonKey(name: 'user_count') int? userCount,
|
||||
@JsonKey(name: 'purchase_date') DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') double? purchasePrice,
|
||||
@JsonKey(name: 'company_id') int? companyId,
|
||||
@JsonKey(name: 'branch_id') int? branchId,
|
||||
String? remark});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CreateLicenseRequestImplCopyWithImpl<$Res>
|
||||
extends _$CreateLicenseRequestCopyWithImpl<$Res, _$CreateLicenseRequestImpl>
|
||||
implements _$$CreateLicenseRequestImplCopyWith<$Res> {
|
||||
__$$CreateLicenseRequestImplCopyWithImpl(_$CreateLicenseRequestImpl _value,
|
||||
$Res Function(_$CreateLicenseRequestImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of CreateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? licenseKey = null,
|
||||
Object? productName = freezed,
|
||||
Object? vendor = freezed,
|
||||
Object? licenseType = freezed,
|
||||
Object? userCount = freezed,
|
||||
Object? purchaseDate = freezed,
|
||||
Object? expiryDate = freezed,
|
||||
Object? purchasePrice = freezed,
|
||||
Object? companyId = freezed,
|
||||
Object? branchId = freezed,
|
||||
Object? remark = freezed,
|
||||
}) {
|
||||
return _then(_$CreateLicenseRequestImpl(
|
||||
licenseKey: null == licenseKey
|
||||
? _value.licenseKey
|
||||
: licenseKey // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
productName: freezed == productName
|
||||
? _value.productName
|
||||
: productName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
vendor: freezed == vendor
|
||||
? _value.vendor
|
||||
: vendor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
licenseType: freezed == licenseType
|
||||
? _value.licenseType
|
||||
: licenseType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
userCount: freezed == userCount
|
||||
? _value.userCount
|
||||
: userCount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
purchaseDate: freezed == purchaseDate
|
||||
? _value.purchaseDate
|
||||
: purchaseDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
expiryDate: freezed == expiryDate
|
||||
? _value.expiryDate
|
||||
: expiryDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
purchasePrice: freezed == purchasePrice
|
||||
? _value.purchasePrice
|
||||
: purchasePrice // ignore: cast_nullable_to_non_nullable
|
||||
as double?,
|
||||
companyId: freezed == companyId
|
||||
? _value.companyId
|
||||
: companyId // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
branchId: freezed == branchId
|
||||
? _value.branchId
|
||||
: branchId // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
remark: freezed == remark
|
||||
? _value.remark
|
||||
: remark // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$CreateLicenseRequestImpl implements _CreateLicenseRequest {
|
||||
const _$CreateLicenseRequestImpl(
|
||||
{@JsonKey(name: 'license_key') required this.licenseKey,
|
||||
@JsonKey(name: 'product_name') this.productName,
|
||||
this.vendor,
|
||||
@JsonKey(name: 'license_type') this.licenseType,
|
||||
@JsonKey(name: 'user_count') this.userCount,
|
||||
@JsonKey(name: 'purchase_date') this.purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') this.expiryDate,
|
||||
@JsonKey(name: 'purchase_price') this.purchasePrice,
|
||||
@JsonKey(name: 'company_id') this.companyId,
|
||||
@JsonKey(name: 'branch_id') this.branchId,
|
||||
this.remark});
|
||||
|
||||
factory _$CreateLicenseRequestImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CreateLicenseRequestImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'license_key')
|
||||
final String licenseKey;
|
||||
@override
|
||||
@JsonKey(name: 'product_name')
|
||||
final String? productName;
|
||||
@override
|
||||
final String? vendor;
|
||||
@override
|
||||
@JsonKey(name: 'license_type')
|
||||
final String? licenseType;
|
||||
@override
|
||||
@JsonKey(name: 'user_count')
|
||||
final int? userCount;
|
||||
@override
|
||||
@JsonKey(name: 'purchase_date')
|
||||
final DateTime? purchaseDate;
|
||||
@override
|
||||
@JsonKey(name: 'expiry_date')
|
||||
final DateTime? expiryDate;
|
||||
@override
|
||||
@JsonKey(name: 'purchase_price')
|
||||
final double? purchasePrice;
|
||||
@override
|
||||
@JsonKey(name: 'company_id')
|
||||
final int? companyId;
|
||||
@override
|
||||
@JsonKey(name: 'branch_id')
|
||||
final int? branchId;
|
||||
@override
|
||||
final String? remark;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CreateLicenseRequest(licenseKey: $licenseKey, productName: $productName, vendor: $vendor, licenseType: $licenseType, userCount: $userCount, purchaseDate: $purchaseDate, expiryDate: $expiryDate, purchasePrice: $purchasePrice, companyId: $companyId, branchId: $branchId, remark: $remark)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CreateLicenseRequestImpl &&
|
||||
(identical(other.licenseKey, licenseKey) ||
|
||||
other.licenseKey == licenseKey) &&
|
||||
(identical(other.productName, productName) ||
|
||||
other.productName == productName) &&
|
||||
(identical(other.vendor, vendor) || other.vendor == vendor) &&
|
||||
(identical(other.licenseType, licenseType) ||
|
||||
other.licenseType == licenseType) &&
|
||||
(identical(other.userCount, userCount) ||
|
||||
other.userCount == userCount) &&
|
||||
(identical(other.purchaseDate, purchaseDate) ||
|
||||
other.purchaseDate == purchaseDate) &&
|
||||
(identical(other.expiryDate, expiryDate) ||
|
||||
other.expiryDate == expiryDate) &&
|
||||
(identical(other.purchasePrice, purchasePrice) ||
|
||||
other.purchasePrice == purchasePrice) &&
|
||||
(identical(other.companyId, companyId) ||
|
||||
other.companyId == companyId) &&
|
||||
(identical(other.branchId, branchId) ||
|
||||
other.branchId == branchId) &&
|
||||
(identical(other.remark, remark) || other.remark == remark));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
licenseKey,
|
||||
productName,
|
||||
vendor,
|
||||
licenseType,
|
||||
userCount,
|
||||
purchaseDate,
|
||||
expiryDate,
|
||||
purchasePrice,
|
||||
companyId,
|
||||
branchId,
|
||||
remark);
|
||||
|
||||
/// Create a copy of CreateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CreateLicenseRequestImplCopyWith<_$CreateLicenseRequestImpl>
|
||||
get copyWith =>
|
||||
__$$CreateLicenseRequestImplCopyWithImpl<_$CreateLicenseRequestImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$CreateLicenseRequestImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CreateLicenseRequest implements CreateLicenseRequest {
|
||||
const factory _CreateLicenseRequest(
|
||||
{@JsonKey(name: 'license_key') required final String licenseKey,
|
||||
@JsonKey(name: 'product_name') final String? productName,
|
||||
final String? vendor,
|
||||
@JsonKey(name: 'license_type') final String? licenseType,
|
||||
@JsonKey(name: 'user_count') final int? userCount,
|
||||
@JsonKey(name: 'purchase_date') final DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') final DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') final double? purchasePrice,
|
||||
@JsonKey(name: 'company_id') final int? companyId,
|
||||
@JsonKey(name: 'branch_id') final int? branchId,
|
||||
final String? remark}) = _$CreateLicenseRequestImpl;
|
||||
|
||||
factory _CreateLicenseRequest.fromJson(Map<String, dynamic> json) =
|
||||
_$CreateLicenseRequestImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'license_key')
|
||||
String get licenseKey;
|
||||
@override
|
||||
@JsonKey(name: 'product_name')
|
||||
String? get productName;
|
||||
@override
|
||||
String? get vendor;
|
||||
@override
|
||||
@JsonKey(name: 'license_type')
|
||||
String? get licenseType;
|
||||
@override
|
||||
@JsonKey(name: 'user_count')
|
||||
int? get userCount;
|
||||
@override
|
||||
@JsonKey(name: 'purchase_date')
|
||||
DateTime? get purchaseDate;
|
||||
@override
|
||||
@JsonKey(name: 'expiry_date')
|
||||
DateTime? get expiryDate;
|
||||
@override
|
||||
@JsonKey(name: 'purchase_price')
|
||||
double? get purchasePrice;
|
||||
@override
|
||||
@JsonKey(name: 'company_id')
|
||||
int? get companyId;
|
||||
@override
|
||||
@JsonKey(name: 'branch_id')
|
||||
int? get branchId;
|
||||
@override
|
||||
String? get remark;
|
||||
|
||||
/// Create a copy of CreateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CreateLicenseRequestImplCopyWith<_$CreateLicenseRequestImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
UpdateLicenseRequest _$UpdateLicenseRequestFromJson(Map<String, dynamic> json) {
|
||||
return _UpdateLicenseRequest.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UpdateLicenseRequest {
|
||||
@JsonKey(name: 'license_key')
|
||||
String? get licenseKey => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'product_name')
|
||||
String? get productName => throw _privateConstructorUsedError;
|
||||
String? get vendor => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'license_type')
|
||||
String? get licenseType => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'user_count')
|
||||
int? get userCount => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'purchase_date')
|
||||
DateTime? get purchaseDate => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'expiry_date')
|
||||
DateTime? get expiryDate => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'purchase_price')
|
||||
double? get purchasePrice => throw _privateConstructorUsedError;
|
||||
String? get remark => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'is_active')
|
||||
bool? get isActive => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this UpdateLicenseRequest to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of UpdateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$UpdateLicenseRequestCopyWith<UpdateLicenseRequest> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UpdateLicenseRequestCopyWith<$Res> {
|
||||
factory $UpdateLicenseRequestCopyWith(UpdateLicenseRequest value,
|
||||
$Res Function(UpdateLicenseRequest) then) =
|
||||
_$UpdateLicenseRequestCopyWithImpl<$Res, UpdateLicenseRequest>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: 'license_key') String? licenseKey,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
String? vendor,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
@JsonKey(name: 'user_count') int? userCount,
|
||||
@JsonKey(name: 'purchase_date') DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') double? purchasePrice,
|
||||
String? remark,
|
||||
@JsonKey(name: 'is_active') bool? isActive});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UpdateLicenseRequestCopyWithImpl<$Res,
|
||||
$Val extends UpdateLicenseRequest>
|
||||
implements $UpdateLicenseRequestCopyWith<$Res> {
|
||||
_$UpdateLicenseRequestCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of UpdateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? licenseKey = freezed,
|
||||
Object? productName = freezed,
|
||||
Object? vendor = freezed,
|
||||
Object? licenseType = freezed,
|
||||
Object? userCount = freezed,
|
||||
Object? purchaseDate = freezed,
|
||||
Object? expiryDate = freezed,
|
||||
Object? purchasePrice = freezed,
|
||||
Object? remark = freezed,
|
||||
Object? isActive = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
licenseKey: freezed == licenseKey
|
||||
? _value.licenseKey
|
||||
: licenseKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
productName: freezed == productName
|
||||
? _value.productName
|
||||
: productName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
vendor: freezed == vendor
|
||||
? _value.vendor
|
||||
: vendor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
licenseType: freezed == licenseType
|
||||
? _value.licenseType
|
||||
: licenseType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
userCount: freezed == userCount
|
||||
? _value.userCount
|
||||
: userCount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
purchaseDate: freezed == purchaseDate
|
||||
? _value.purchaseDate
|
||||
: purchaseDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
expiryDate: freezed == expiryDate
|
||||
? _value.expiryDate
|
||||
: expiryDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
purchasePrice: freezed == purchasePrice
|
||||
? _value.purchasePrice
|
||||
: purchasePrice // ignore: cast_nullable_to_non_nullable
|
||||
as double?,
|
||||
remark: freezed == remark
|
||||
? _value.remark
|
||||
: remark // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isActive: freezed == isActive
|
||||
? _value.isActive
|
||||
: isActive // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UpdateLicenseRequestImplCopyWith<$Res>
|
||||
implements $UpdateLicenseRequestCopyWith<$Res> {
|
||||
factory _$$UpdateLicenseRequestImplCopyWith(_$UpdateLicenseRequestImpl value,
|
||||
$Res Function(_$UpdateLicenseRequestImpl) then) =
|
||||
__$$UpdateLicenseRequestImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: 'license_key') String? licenseKey,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
String? vendor,
|
||||
@JsonKey(name: 'license_type') String? licenseType,
|
||||
@JsonKey(name: 'user_count') int? userCount,
|
||||
@JsonKey(name: 'purchase_date') DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') double? purchasePrice,
|
||||
String? remark,
|
||||
@JsonKey(name: 'is_active') bool? isActive});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UpdateLicenseRequestImplCopyWithImpl<$Res>
|
||||
extends _$UpdateLicenseRequestCopyWithImpl<$Res, _$UpdateLicenseRequestImpl>
|
||||
implements _$$UpdateLicenseRequestImplCopyWith<$Res> {
|
||||
__$$UpdateLicenseRequestImplCopyWithImpl(_$UpdateLicenseRequestImpl _value,
|
||||
$Res Function(_$UpdateLicenseRequestImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of UpdateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? licenseKey = freezed,
|
||||
Object? productName = freezed,
|
||||
Object? vendor = freezed,
|
||||
Object? licenseType = freezed,
|
||||
Object? userCount = freezed,
|
||||
Object? purchaseDate = freezed,
|
||||
Object? expiryDate = freezed,
|
||||
Object? purchasePrice = freezed,
|
||||
Object? remark = freezed,
|
||||
Object? isActive = freezed,
|
||||
}) {
|
||||
return _then(_$UpdateLicenseRequestImpl(
|
||||
licenseKey: freezed == licenseKey
|
||||
? _value.licenseKey
|
||||
: licenseKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
productName: freezed == productName
|
||||
? _value.productName
|
||||
: productName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
vendor: freezed == vendor
|
||||
? _value.vendor
|
||||
: vendor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
licenseType: freezed == licenseType
|
||||
? _value.licenseType
|
||||
: licenseType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
userCount: freezed == userCount
|
||||
? _value.userCount
|
||||
: userCount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
purchaseDate: freezed == purchaseDate
|
||||
? _value.purchaseDate
|
||||
: purchaseDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
expiryDate: freezed == expiryDate
|
||||
? _value.expiryDate
|
||||
: expiryDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
purchasePrice: freezed == purchasePrice
|
||||
? _value.purchasePrice
|
||||
: purchasePrice // ignore: cast_nullable_to_non_nullable
|
||||
as double?,
|
||||
remark: freezed == remark
|
||||
? _value.remark
|
||||
: remark // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isActive: freezed == isActive
|
||||
? _value.isActive
|
||||
: isActive // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$UpdateLicenseRequestImpl implements _UpdateLicenseRequest {
|
||||
const _$UpdateLicenseRequestImpl(
|
||||
{@JsonKey(name: 'license_key') this.licenseKey,
|
||||
@JsonKey(name: 'product_name') this.productName,
|
||||
this.vendor,
|
||||
@JsonKey(name: 'license_type') this.licenseType,
|
||||
@JsonKey(name: 'user_count') this.userCount,
|
||||
@JsonKey(name: 'purchase_date') this.purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') this.expiryDate,
|
||||
@JsonKey(name: 'purchase_price') this.purchasePrice,
|
||||
this.remark,
|
||||
@JsonKey(name: 'is_active') this.isActive});
|
||||
|
||||
factory _$UpdateLicenseRequestImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$UpdateLicenseRequestImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'license_key')
|
||||
final String? licenseKey;
|
||||
@override
|
||||
@JsonKey(name: 'product_name')
|
||||
final String? productName;
|
||||
@override
|
||||
final String? vendor;
|
||||
@override
|
||||
@JsonKey(name: 'license_type')
|
||||
final String? licenseType;
|
||||
@override
|
||||
@JsonKey(name: 'user_count')
|
||||
final int? userCount;
|
||||
@override
|
||||
@JsonKey(name: 'purchase_date')
|
||||
final DateTime? purchaseDate;
|
||||
@override
|
||||
@JsonKey(name: 'expiry_date')
|
||||
final DateTime? expiryDate;
|
||||
@override
|
||||
@JsonKey(name: 'purchase_price')
|
||||
final double? purchasePrice;
|
||||
@override
|
||||
final String? remark;
|
||||
@override
|
||||
@JsonKey(name: 'is_active')
|
||||
final bool? isActive;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateLicenseRequest(licenseKey: $licenseKey, productName: $productName, vendor: $vendor, licenseType: $licenseType, userCount: $userCount, purchaseDate: $purchaseDate, expiryDate: $expiryDate, purchasePrice: $purchasePrice, remark: $remark, isActive: $isActive)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UpdateLicenseRequestImpl &&
|
||||
(identical(other.licenseKey, licenseKey) ||
|
||||
other.licenseKey == licenseKey) &&
|
||||
(identical(other.productName, productName) ||
|
||||
other.productName == productName) &&
|
||||
(identical(other.vendor, vendor) || other.vendor == vendor) &&
|
||||
(identical(other.licenseType, licenseType) ||
|
||||
other.licenseType == licenseType) &&
|
||||
(identical(other.userCount, userCount) ||
|
||||
other.userCount == userCount) &&
|
||||
(identical(other.purchaseDate, purchaseDate) ||
|
||||
other.purchaseDate == purchaseDate) &&
|
||||
(identical(other.expiryDate, expiryDate) ||
|
||||
other.expiryDate == expiryDate) &&
|
||||
(identical(other.purchasePrice, purchasePrice) ||
|
||||
other.purchasePrice == purchasePrice) &&
|
||||
(identical(other.remark, remark) || other.remark == remark) &&
|
||||
(identical(other.isActive, isActive) ||
|
||||
other.isActive == isActive));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
licenseKey,
|
||||
productName,
|
||||
vendor,
|
||||
licenseType,
|
||||
userCount,
|
||||
purchaseDate,
|
||||
expiryDate,
|
||||
purchasePrice,
|
||||
remark,
|
||||
isActive);
|
||||
|
||||
/// Create a copy of UpdateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UpdateLicenseRequestImplCopyWith<_$UpdateLicenseRequestImpl>
|
||||
get copyWith =>
|
||||
__$$UpdateLicenseRequestImplCopyWithImpl<_$UpdateLicenseRequestImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$UpdateLicenseRequestImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UpdateLicenseRequest implements UpdateLicenseRequest {
|
||||
const factory _UpdateLicenseRequest(
|
||||
{@JsonKey(name: 'license_key') final String? licenseKey,
|
||||
@JsonKey(name: 'product_name') final String? productName,
|
||||
final String? vendor,
|
||||
@JsonKey(name: 'license_type') final String? licenseType,
|
||||
@JsonKey(name: 'user_count') final int? userCount,
|
||||
@JsonKey(name: 'purchase_date') final DateTime? purchaseDate,
|
||||
@JsonKey(name: 'expiry_date') final DateTime? expiryDate,
|
||||
@JsonKey(name: 'purchase_price') final double? purchasePrice,
|
||||
final String? remark,
|
||||
@JsonKey(name: 'is_active') final bool? isActive}) =
|
||||
_$UpdateLicenseRequestImpl;
|
||||
|
||||
factory _UpdateLicenseRequest.fromJson(Map<String, dynamic> json) =
|
||||
_$UpdateLicenseRequestImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'license_key')
|
||||
String? get licenseKey;
|
||||
@override
|
||||
@JsonKey(name: 'product_name')
|
||||
String? get productName;
|
||||
@override
|
||||
String? get vendor;
|
||||
@override
|
||||
@JsonKey(name: 'license_type')
|
||||
String? get licenseType;
|
||||
@override
|
||||
@JsonKey(name: 'user_count')
|
||||
int? get userCount;
|
||||
@override
|
||||
@JsonKey(name: 'purchase_date')
|
||||
DateTime? get purchaseDate;
|
||||
@override
|
||||
@JsonKey(name: 'expiry_date')
|
||||
DateTime? get expiryDate;
|
||||
@override
|
||||
@JsonKey(name: 'purchase_price')
|
||||
double? get purchasePrice;
|
||||
@override
|
||||
String? get remark;
|
||||
@override
|
||||
@JsonKey(name: 'is_active')
|
||||
bool? get isActive;
|
||||
|
||||
/// Create a copy of UpdateLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$UpdateLicenseRequestImplCopyWith<_$UpdateLicenseRequestImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
AssignLicenseRequest _$AssignLicenseRequestFromJson(Map<String, dynamic> json) {
|
||||
return _AssignLicenseRequest.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AssignLicenseRequest {
|
||||
@JsonKey(name: 'user_id')
|
||||
int get userId => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AssignLicenseRequest to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AssignLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AssignLicenseRequestCopyWith<AssignLicenseRequest> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AssignLicenseRequestCopyWith<$Res> {
|
||||
factory $AssignLicenseRequestCopyWith(AssignLicenseRequest value,
|
||||
$Res Function(AssignLicenseRequest) then) =
|
||||
_$AssignLicenseRequestCopyWithImpl<$Res, AssignLicenseRequest>;
|
||||
@useResult
|
||||
$Res call({@JsonKey(name: 'user_id') int userId});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AssignLicenseRequestCopyWithImpl<$Res,
|
||||
$Val extends AssignLicenseRequest>
|
||||
implements $AssignLicenseRequestCopyWith<$Res> {
|
||||
_$AssignLicenseRequestCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AssignLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? userId = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
userId: null == userId
|
||||
? _value.userId
|
||||
: userId // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AssignLicenseRequestImplCopyWith<$Res>
|
||||
implements $AssignLicenseRequestCopyWith<$Res> {
|
||||
factory _$$AssignLicenseRequestImplCopyWith(_$AssignLicenseRequestImpl value,
|
||||
$Res Function(_$AssignLicenseRequestImpl) then) =
|
||||
__$$AssignLicenseRequestImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({@JsonKey(name: 'user_id') int userId});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AssignLicenseRequestImplCopyWithImpl<$Res>
|
||||
extends _$AssignLicenseRequestCopyWithImpl<$Res, _$AssignLicenseRequestImpl>
|
||||
implements _$$AssignLicenseRequestImplCopyWith<$Res> {
|
||||
__$$AssignLicenseRequestImplCopyWithImpl(_$AssignLicenseRequestImpl _value,
|
||||
$Res Function(_$AssignLicenseRequestImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AssignLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? userId = null,
|
||||
}) {
|
||||
return _then(_$AssignLicenseRequestImpl(
|
||||
userId: null == userId
|
||||
? _value.userId
|
||||
: userId // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AssignLicenseRequestImpl implements _AssignLicenseRequest {
|
||||
const _$AssignLicenseRequestImpl(
|
||||
{@JsonKey(name: 'user_id') required this.userId});
|
||||
|
||||
factory _$AssignLicenseRequestImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AssignLicenseRequestImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'user_id')
|
||||
final int userId;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AssignLicenseRequest(userId: $userId)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AssignLicenseRequestImpl &&
|
||||
(identical(other.userId, userId) || other.userId == userId));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, userId);
|
||||
|
||||
/// Create a copy of AssignLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AssignLicenseRequestImplCopyWith<_$AssignLicenseRequestImpl>
|
||||
get copyWith =>
|
||||
__$$AssignLicenseRequestImplCopyWithImpl<_$AssignLicenseRequestImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AssignLicenseRequestImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AssignLicenseRequest implements AssignLicenseRequest {
|
||||
const factory _AssignLicenseRequest(
|
||||
{@JsonKey(name: 'user_id') required final int userId}) =
|
||||
_$AssignLicenseRequestImpl;
|
||||
|
||||
factory _AssignLicenseRequest.fromJson(Map<String, dynamic> json) =
|
||||
_$AssignLicenseRequestImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'user_id')
|
||||
int get userId;
|
||||
|
||||
/// Create a copy of AssignLicenseRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AssignLicenseRequestImplCopyWith<_$AssignLicenseRequestImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
89
lib/data/models/license/license_request_dto.g.dart
Normal file
89
lib/data/models/license/license_request_dto.g.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'license_request_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$CreateLicenseRequestImpl _$$CreateLicenseRequestImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$CreateLicenseRequestImpl(
|
||||
licenseKey: json['license_key'] as String,
|
||||
productName: json['product_name'] as String?,
|
||||
vendor: json['vendor'] as String?,
|
||||
licenseType: json['license_type'] as String?,
|
||||
userCount: (json['user_count'] as num?)?.toInt(),
|
||||
purchaseDate: json['purchase_date'] == null
|
||||
? null
|
||||
: DateTime.parse(json['purchase_date'] as String),
|
||||
expiryDate: json['expiry_date'] == null
|
||||
? null
|
||||
: DateTime.parse(json['expiry_date'] as String),
|
||||
purchasePrice: (json['purchase_price'] as num?)?.toDouble(),
|
||||
companyId: (json['company_id'] as num?)?.toInt(),
|
||||
branchId: (json['branch_id'] as num?)?.toInt(),
|
||||
remark: json['remark'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CreateLicenseRequestImplToJson(
|
||||
_$CreateLicenseRequestImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'license_key': instance.licenseKey,
|
||||
'product_name': instance.productName,
|
||||
'vendor': instance.vendor,
|
||||
'license_type': instance.licenseType,
|
||||
'user_count': instance.userCount,
|
||||
'purchase_date': instance.purchaseDate?.toIso8601String(),
|
||||
'expiry_date': instance.expiryDate?.toIso8601String(),
|
||||
'purchase_price': instance.purchasePrice,
|
||||
'company_id': instance.companyId,
|
||||
'branch_id': instance.branchId,
|
||||
'remark': instance.remark,
|
||||
};
|
||||
|
||||
_$UpdateLicenseRequestImpl _$$UpdateLicenseRequestImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$UpdateLicenseRequestImpl(
|
||||
licenseKey: json['license_key'] as String?,
|
||||
productName: json['product_name'] as String?,
|
||||
vendor: json['vendor'] as String?,
|
||||
licenseType: json['license_type'] as String?,
|
||||
userCount: (json['user_count'] as num?)?.toInt(),
|
||||
purchaseDate: json['purchase_date'] == null
|
||||
? null
|
||||
: DateTime.parse(json['purchase_date'] as String),
|
||||
expiryDate: json['expiry_date'] == null
|
||||
? null
|
||||
: DateTime.parse(json['expiry_date'] as String),
|
||||
purchasePrice: (json['purchase_price'] as num?)?.toDouble(),
|
||||
remark: json['remark'] as String?,
|
||||
isActive: json['is_active'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UpdateLicenseRequestImplToJson(
|
||||
_$UpdateLicenseRequestImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'license_key': instance.licenseKey,
|
||||
'product_name': instance.productName,
|
||||
'vendor': instance.vendor,
|
||||
'license_type': instance.licenseType,
|
||||
'user_count': instance.userCount,
|
||||
'purchase_date': instance.purchaseDate?.toIso8601String(),
|
||||
'expiry_date': instance.expiryDate?.toIso8601String(),
|
||||
'purchase_price': instance.purchasePrice,
|
||||
'remark': instance.remark,
|
||||
'is_active': instance.isActive,
|
||||
};
|
||||
|
||||
_$AssignLicenseRequestImpl _$$AssignLicenseRequestImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$AssignLicenseRequestImpl(
|
||||
userId: (json['user_id'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AssignLicenseRequestImplToJson(
|
||||
_$AssignLicenseRequestImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'user_id': instance.userId,
|
||||
};
|
||||
132
lib/data/models/warehouse/warehouse_dto.dart
Normal file
132
lib/data/models/warehouse/warehouse_dto.dart
Normal file
@@ -0,0 +1,132 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'warehouse_dto.freezed.dart';
|
||||
part 'warehouse_dto.g.dart';
|
||||
|
||||
/// 창고 위치 생성 요청 DTO
|
||||
@freezed
|
||||
class CreateWarehouseLocationRequest with _$CreateWarehouseLocationRequest {
|
||||
const factory CreateWarehouseLocationRequest({
|
||||
required String name,
|
||||
String? address,
|
||||
String? city,
|
||||
String? state,
|
||||
@JsonKey(name: 'postal_code') String? postalCode,
|
||||
String? country,
|
||||
int? capacity,
|
||||
@JsonKey(name: 'manager_id') int? managerId,
|
||||
}) = _CreateWarehouseLocationRequest;
|
||||
|
||||
factory CreateWarehouseLocationRequest.fromJson(Map<String, dynamic> json) =>
|
||||
_$CreateWarehouseLocationRequestFromJson(json);
|
||||
}
|
||||
|
||||
/// 창고 위치 수정 요청 DTO
|
||||
@freezed
|
||||
class UpdateWarehouseLocationRequest with _$UpdateWarehouseLocationRequest {
|
||||
const factory UpdateWarehouseLocationRequest({
|
||||
String? name,
|
||||
String? address,
|
||||
String? city,
|
||||
String? state,
|
||||
@JsonKey(name: 'postal_code') String? postalCode,
|
||||
String? country,
|
||||
int? capacity,
|
||||
@JsonKey(name: 'manager_id') int? managerId,
|
||||
@JsonKey(name: 'is_active') bool? isActive,
|
||||
}) = _UpdateWarehouseLocationRequest;
|
||||
|
||||
factory UpdateWarehouseLocationRequest.fromJson(Map<String, dynamic> json) =>
|
||||
_$UpdateWarehouseLocationRequestFromJson(json);
|
||||
}
|
||||
|
||||
/// 창고 위치 응답 DTO
|
||||
@freezed
|
||||
class WarehouseLocationDto with _$WarehouseLocationDto {
|
||||
const factory WarehouseLocationDto({
|
||||
required int id,
|
||||
required String name,
|
||||
String? address,
|
||||
String? city,
|
||||
String? state,
|
||||
@JsonKey(name: 'postal_code') String? postalCode,
|
||||
String? country,
|
||||
int? capacity,
|
||||
@JsonKey(name: 'manager_id') int? managerId,
|
||||
@JsonKey(name: 'manager_name') String? managerName,
|
||||
@JsonKey(name: 'is_active') required bool isActive,
|
||||
@JsonKey(name: 'created_at') required DateTime createdAt,
|
||||
@JsonKey(name: 'updated_at') required DateTime updatedAt,
|
||||
// 추가 정보
|
||||
@JsonKey(name: 'current_stock') int? currentStock,
|
||||
@JsonKey(name: 'available_capacity') int? availableCapacity,
|
||||
}) = _WarehouseLocationDto;
|
||||
|
||||
factory WarehouseLocationDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$WarehouseLocationDtoFromJson(json);
|
||||
}
|
||||
|
||||
/// 창고 위치 목록 응답 DTO
|
||||
@freezed
|
||||
class WarehouseLocationListDto with _$WarehouseLocationListDto {
|
||||
const factory WarehouseLocationListDto({
|
||||
required List<WarehouseLocationDto> items,
|
||||
required int total,
|
||||
required int page,
|
||||
@JsonKey(name: 'per_page') required int perPage,
|
||||
@JsonKey(name: 'total_pages') required int totalPages,
|
||||
}) = _WarehouseLocationListDto;
|
||||
|
||||
factory WarehouseLocationListDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$WarehouseLocationListDtoFromJson(json);
|
||||
}
|
||||
|
||||
/// 창고 용량 정보 DTO
|
||||
@freezed
|
||||
class WarehouseCapacityInfo with _$WarehouseCapacityInfo {
|
||||
const factory WarehouseCapacityInfo({
|
||||
@JsonKey(name: 'warehouse_id') required int warehouseId,
|
||||
@JsonKey(name: 'total_capacity') required int totalCapacity,
|
||||
@JsonKey(name: 'used_capacity') required int usedCapacity,
|
||||
@JsonKey(name: 'available_capacity') required int availableCapacity,
|
||||
@JsonKey(name: 'usage_percentage') required double usagePercentage,
|
||||
@JsonKey(name: 'equipment_count') required int equipmentCount,
|
||||
}) = _WarehouseCapacityInfo;
|
||||
|
||||
factory WarehouseCapacityInfo.fromJson(Map<String, dynamic> json) =>
|
||||
_$WarehouseCapacityInfoFromJson(json);
|
||||
}
|
||||
|
||||
/// 창고별 장비 목록 DTO
|
||||
@freezed
|
||||
class WarehouseEquipmentDto with _$WarehouseEquipmentDto {
|
||||
const factory WarehouseEquipmentDto({
|
||||
required int id,
|
||||
@JsonKey(name: 'equipment_number') required String equipmentNumber,
|
||||
String? manufacturer,
|
||||
@JsonKey(name: 'equipment_name') String? equipmentName,
|
||||
@JsonKey(name: 'serial_number') String? serialNumber,
|
||||
required int quantity,
|
||||
String? status,
|
||||
@JsonKey(name: 'warehouse_location_id') required int warehouseLocationId,
|
||||
@JsonKey(name: 'stored_at') required DateTime storedAt,
|
||||
}) = _WarehouseEquipmentDto;
|
||||
|
||||
factory WarehouseEquipmentDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$WarehouseEquipmentDtoFromJson(json);
|
||||
}
|
||||
|
||||
/// 창고별 장비 목록 응답 DTO
|
||||
@freezed
|
||||
class WarehouseEquipmentListDto with _$WarehouseEquipmentListDto {
|
||||
const factory WarehouseEquipmentListDto({
|
||||
required List<WarehouseEquipmentDto> items,
|
||||
required int total,
|
||||
required int page,
|
||||
@JsonKey(name: 'per_page') required int perPage,
|
||||
@JsonKey(name: 'total_pages') required int totalPages,
|
||||
}) = _WarehouseEquipmentListDto;
|
||||
|
||||
factory WarehouseEquipmentListDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$WarehouseEquipmentListDtoFromJson(json);
|
||||
}
|
||||
2316
lib/data/models/warehouse/warehouse_dto.freezed.dart
Normal file
2316
lib/data/models/warehouse/warehouse_dto.freezed.dart
Normal file
File diff suppressed because it is too large
Load Diff
195
lib/data/models/warehouse/warehouse_dto.g.dart
Normal file
195
lib/data/models/warehouse/warehouse_dto.g.dart
Normal file
@@ -0,0 +1,195 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'warehouse_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$CreateWarehouseLocationRequestImpl
|
||||
_$$CreateWarehouseLocationRequestImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CreateWarehouseLocationRequestImpl(
|
||||
name: json['name'] as String,
|
||||
address: json['address'] as String?,
|
||||
city: json['city'] as String?,
|
||||
state: json['state'] as String?,
|
||||
postalCode: json['postal_code'] as String?,
|
||||
country: json['country'] as String?,
|
||||
capacity: (json['capacity'] as num?)?.toInt(),
|
||||
managerId: (json['manager_id'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CreateWarehouseLocationRequestImplToJson(
|
||||
_$CreateWarehouseLocationRequestImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
'address': instance.address,
|
||||
'city': instance.city,
|
||||
'state': instance.state,
|
||||
'postal_code': instance.postalCode,
|
||||
'country': instance.country,
|
||||
'capacity': instance.capacity,
|
||||
'manager_id': instance.managerId,
|
||||
};
|
||||
|
||||
_$UpdateWarehouseLocationRequestImpl
|
||||
_$$UpdateWarehouseLocationRequestImplFromJson(Map<String, dynamic> json) =>
|
||||
_$UpdateWarehouseLocationRequestImpl(
|
||||
name: json['name'] as String?,
|
||||
address: json['address'] as String?,
|
||||
city: json['city'] as String?,
|
||||
state: json['state'] as String?,
|
||||
postalCode: json['postal_code'] as String?,
|
||||
country: json['country'] as String?,
|
||||
capacity: (json['capacity'] as num?)?.toInt(),
|
||||
managerId: (json['manager_id'] as num?)?.toInt(),
|
||||
isActive: json['is_active'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UpdateWarehouseLocationRequestImplToJson(
|
||||
_$UpdateWarehouseLocationRequestImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
'address': instance.address,
|
||||
'city': instance.city,
|
||||
'state': instance.state,
|
||||
'postal_code': instance.postalCode,
|
||||
'country': instance.country,
|
||||
'capacity': instance.capacity,
|
||||
'manager_id': instance.managerId,
|
||||
'is_active': instance.isActive,
|
||||
};
|
||||
|
||||
_$WarehouseLocationDtoImpl _$$WarehouseLocationDtoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$WarehouseLocationDtoImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
address: json['address'] as String?,
|
||||
city: json['city'] as String?,
|
||||
state: json['state'] as String?,
|
||||
postalCode: json['postal_code'] as String?,
|
||||
country: json['country'] as String?,
|
||||
capacity: (json['capacity'] as num?)?.toInt(),
|
||||
managerId: (json['manager_id'] as num?)?.toInt(),
|
||||
managerName: json['manager_name'] as String?,
|
||||
isActive: json['is_active'] as bool,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
currentStock: (json['current_stock'] as num?)?.toInt(),
|
||||
availableCapacity: (json['available_capacity'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$WarehouseLocationDtoImplToJson(
|
||||
_$WarehouseLocationDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'address': instance.address,
|
||||
'city': instance.city,
|
||||
'state': instance.state,
|
||||
'postal_code': instance.postalCode,
|
||||
'country': instance.country,
|
||||
'capacity': instance.capacity,
|
||||
'manager_id': instance.managerId,
|
||||
'manager_name': instance.managerName,
|
||||
'is_active': instance.isActive,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'current_stock': instance.currentStock,
|
||||
'available_capacity': instance.availableCapacity,
|
||||
};
|
||||
|
||||
_$WarehouseLocationListDtoImpl _$$WarehouseLocationListDtoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$WarehouseLocationListDtoImpl(
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => WarehouseLocationDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
total: (json['total'] as num).toInt(),
|
||||
page: (json['page'] as num).toInt(),
|
||||
perPage: (json['per_page'] as num).toInt(),
|
||||
totalPages: (json['total_pages'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$WarehouseLocationListDtoImplToJson(
|
||||
_$WarehouseLocationListDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'items': instance.items,
|
||||
'total': instance.total,
|
||||
'page': instance.page,
|
||||
'per_page': instance.perPage,
|
||||
'total_pages': instance.totalPages,
|
||||
};
|
||||
|
||||
_$WarehouseCapacityInfoImpl _$$WarehouseCapacityInfoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$WarehouseCapacityInfoImpl(
|
||||
warehouseId: (json['warehouse_id'] as num).toInt(),
|
||||
totalCapacity: (json['total_capacity'] as num).toInt(),
|
||||
usedCapacity: (json['used_capacity'] as num).toInt(),
|
||||
availableCapacity: (json['available_capacity'] as num).toInt(),
|
||||
usagePercentage: (json['usage_percentage'] as num).toDouble(),
|
||||
equipmentCount: (json['equipment_count'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$WarehouseCapacityInfoImplToJson(
|
||||
_$WarehouseCapacityInfoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'warehouse_id': instance.warehouseId,
|
||||
'total_capacity': instance.totalCapacity,
|
||||
'used_capacity': instance.usedCapacity,
|
||||
'available_capacity': instance.availableCapacity,
|
||||
'usage_percentage': instance.usagePercentage,
|
||||
'equipment_count': instance.equipmentCount,
|
||||
};
|
||||
|
||||
_$WarehouseEquipmentDtoImpl _$$WarehouseEquipmentDtoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$WarehouseEquipmentDtoImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
equipmentNumber: json['equipment_number'] as String,
|
||||
manufacturer: json['manufacturer'] as String?,
|
||||
equipmentName: json['equipment_name'] as String?,
|
||||
serialNumber: json['serial_number'] as String?,
|
||||
quantity: (json['quantity'] as num).toInt(),
|
||||
status: json['status'] as String?,
|
||||
warehouseLocationId: (json['warehouse_location_id'] as num).toInt(),
|
||||
storedAt: DateTime.parse(json['stored_at'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$WarehouseEquipmentDtoImplToJson(
|
||||
_$WarehouseEquipmentDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'equipment_number': instance.equipmentNumber,
|
||||
'manufacturer': instance.manufacturer,
|
||||
'equipment_name': instance.equipmentName,
|
||||
'serial_number': instance.serialNumber,
|
||||
'quantity': instance.quantity,
|
||||
'status': instance.status,
|
||||
'warehouse_location_id': instance.warehouseLocationId,
|
||||
'stored_at': instance.storedAt.toIso8601String(),
|
||||
};
|
||||
|
||||
_$WarehouseEquipmentListDtoImpl _$$WarehouseEquipmentListDtoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$WarehouseEquipmentListDtoImpl(
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => WarehouseEquipmentDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
total: (json['total'] as num).toInt(),
|
||||
page: (json['page'] as num).toInt(),
|
||||
perPage: (json['per_page'] as num).toInt(),
|
||||
totalPages: (json['total_pages'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$WarehouseEquipmentListDtoImplToJson(
|
||||
_$WarehouseEquipmentListDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'items': instance.items,
|
||||
'total': instance.total,
|
||||
'page': instance.page,
|
||||
'per_page': instance.perPage,
|
||||
'total_pages': instance.totalPages,
|
||||
};
|
||||
@@ -8,11 +8,15 @@ import '../data/datasources/remote/dashboard_remote_datasource.dart';
|
||||
import '../data/datasources/remote/equipment_remote_datasource.dart';
|
||||
import '../data/datasources/remote/company_remote_datasource.dart';
|
||||
import '../data/datasources/remote/user_remote_datasource.dart';
|
||||
import '../data/datasources/remote/license_remote_datasource.dart';
|
||||
import '../data/datasources/remote/warehouse_remote_datasource.dart';
|
||||
import '../services/auth_service.dart';
|
||||
import '../services/dashboard_service.dart';
|
||||
import '../services/equipment_service.dart';
|
||||
import '../services/company_service.dart';
|
||||
import '../services/user_service.dart';
|
||||
import '../services/license_service.dart';
|
||||
import '../services/warehouse_service.dart';
|
||||
|
||||
/// GetIt 인스턴스
|
||||
final getIt = GetIt.instance;
|
||||
@@ -45,6 +49,12 @@ Future<void> setupDependencies() async {
|
||||
getIt.registerLazySingleton<UserRemoteDataSource>(
|
||||
() => UserRemoteDataSource(),
|
||||
);
|
||||
getIt.registerLazySingleton<LicenseRemoteDataSource>(
|
||||
() => LicenseRemoteDataSourceImpl(apiClient: getIt()),
|
||||
);
|
||||
getIt.registerLazySingleton<WarehouseRemoteDataSource>(
|
||||
() => WarehouseRemoteDataSourceImpl(apiClient: getIt()),
|
||||
);
|
||||
|
||||
// 서비스
|
||||
getIt.registerLazySingleton<AuthService>(
|
||||
@@ -62,6 +72,12 @@ Future<void> setupDependencies() async {
|
||||
getIt.registerLazySingleton<UserService>(
|
||||
() => UserService(),
|
||||
);
|
||||
getIt.registerLazySingleton<LicenseService>(
|
||||
() => LicenseService(),
|
||||
);
|
||||
getIt.registerLazySingleton<WarehouseService>(
|
||||
() => WarehouseService(),
|
||||
);
|
||||
|
||||
// 리포지토리
|
||||
// TODO: Repositories will be registered here
|
||||
|
||||
@@ -1,782 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/models/equipment_unified_model.dart';
|
||||
import 'package:superport/models/company_model.dart';
|
||||
import 'package:superport/models/address_model.dart';
|
||||
import 'package:superport/services/equipment_service.dart';
|
||||
import 'package:superport/services/mock_data_service.dart';
|
||||
import 'package:superport/core/errors/failures.dart';
|
||||
|
||||
// 장비 출고 폼의 상태 및 비즈니스 로직을 담당하는 컨트롤러
|
||||
class EquipmentOutFormController extends ChangeNotifier {
|
||||
final MockDataService dataService;
|
||||
final EquipmentService _equipmentService = GetIt.instance<EquipmentService>();
|
||||
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
final TextEditingController remarkController = TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
String? _error;
|
||||
bool _isSaving = false;
|
||||
bool _useApi = true; // Feature flag
|
||||
String? _errorMessage;
|
||||
|
||||
// Getters
|
||||
bool get isLoading => _isLoading;
|
||||
String? get error => _error;
|
||||
bool get isSaving => _isSaving;
|
||||
String? get errorMessage => _errorMessage;
|
||||
|
||||
// 상태 변수
|
||||
bool isEditMode = false;
|
||||
String manufacturer = '';
|
||||
String name = '';
|
||||
String category = '';
|
||||
String subCategory = '';
|
||||
String subSubCategory = '';
|
||||
String serialNumber = '';
|
||||
String barcode = '';
|
||||
int quantity = 1;
|
||||
DateTime _outDate = DateTime.now();
|
||||
DateTime get outDate => _outDate;
|
||||
set outDate(DateTime value) {
|
||||
_outDate = value;
|
||||
notifyListeners();
|
||||
}
|
||||
bool hasSerialNumber = false;
|
||||
DateTime? inDate;
|
||||
String returnType = '재입고';
|
||||
DateTime _returnDate = DateTime.now();
|
||||
DateTime get returnDate => _returnDate;
|
||||
set returnDate(DateTime value) {
|
||||
_returnDate = value;
|
||||
notifyListeners();
|
||||
}
|
||||
bool hasManagers = false;
|
||||
|
||||
// 출고 유형(출고/대여/폐기) 상태 변수 추가
|
||||
String _outType = '출고'; // 기본값은 '출고'
|
||||
String get outType => _outType;
|
||||
set outType(String value) {
|
||||
_outType = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 기존 필드 - 호환성을 위해 유지
|
||||
String? _selectedCompany;
|
||||
String? get selectedCompany =>
|
||||
selectedCompanies.isNotEmpty ? selectedCompanies[0] : null;
|
||||
set selectedCompany(String? value) {
|
||||
if (selectedCompanies.isEmpty) {
|
||||
selectedCompanies.add(value);
|
||||
} else {
|
||||
selectedCompanies[0] = value;
|
||||
}
|
||||
_selectedCompany = value;
|
||||
}
|
||||
|
||||
String? _selectedManager;
|
||||
String? get selectedManager =>
|
||||
selectedManagersPerCompany.isNotEmpty
|
||||
? selectedManagersPerCompany[0]
|
||||
: null;
|
||||
set selectedManager(String? value) {
|
||||
if (selectedManagersPerCompany.isEmpty) {
|
||||
selectedManagersPerCompany.add(value);
|
||||
} else {
|
||||
selectedManagersPerCompany[0] = value;
|
||||
}
|
||||
_selectedManager = value;
|
||||
}
|
||||
|
||||
String? selectedLicense;
|
||||
List<String> companies = [];
|
||||
// 회사 및 지점 관련 데이터
|
||||
List<CompanyBranchInfo> companiesWithBranches = [];
|
||||
List<String> managers = [];
|
||||
List<String> filteredManagers = [];
|
||||
List<String> licenses = [];
|
||||
|
||||
// 출고 유형별 상태 코드 매핑
|
||||
static const Map<String, String> outTypeStatusMap = {
|
||||
'출고': 'O', // Out
|
||||
'대여': 'R', // Rent
|
||||
'폐기': 'D', // Disposal
|
||||
};
|
||||
|
||||
// 출고 회사 목록 관리
|
||||
List<String?> selectedCompanies = [null]; // 첫 번째 드롭다운을 위한 초기값
|
||||
List<List<String>> availableCompaniesPerDropdown =
|
||||
[]; // 각 드롭다운마다 사용 가능한 회사 목록
|
||||
List<String?> selectedManagersPerCompany = [null]; // 각 드롭다운 회사별 선택된 담당자
|
||||
List<List<String>> filteredManagersPerCompany = []; // 각 드롭다운 회사별 필터링된 담당자 목록
|
||||
List<bool> hasManagersPerCompany = [false]; // 각 회사별 담당자 유무
|
||||
|
||||
// 입력 데이터
|
||||
Equipment? selectedEquipment;
|
||||
int? selectedEquipmentInId;
|
||||
int? equipmentOutId;
|
||||
List<Map<String, dynamic>>? _selectedEquipments;
|
||||
|
||||
EquipmentOutFormController({required this.dataService});
|
||||
|
||||
// 선택된 장비 정보 설정 (디버그용)
|
||||
set selectedEquipments(List<Map<String, dynamic>>? equipments) {
|
||||
debugPrint('설정된 장비 목록: ${equipments?.length ?? 0}개');
|
||||
if (equipments != null) {
|
||||
for (var i = 0; i < equipments.length; i++) {
|
||||
final equipment = equipments[i]['equipment'] as Equipment;
|
||||
debugPrint('장비 $i: ${equipment.manufacturer} ${equipment.name}');
|
||||
}
|
||||
}
|
||||
_selectedEquipments = equipments;
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>>? get selectedEquipments => _selectedEquipments;
|
||||
|
||||
// 드롭다운 데이터 로드
|
||||
void loadDropdownData() {
|
||||
final allCompanies = dataService.getAllCompanies();
|
||||
|
||||
// 회사와 지점 통합 목록 생성
|
||||
companiesWithBranches = [];
|
||||
companies = [];
|
||||
|
||||
for (var company in allCompanies) {
|
||||
// 회사 자체 정보 추가
|
||||
final companyType =
|
||||
company.companyTypes.isNotEmpty
|
||||
? companyTypeToString(company.companyTypes.first)
|
||||
: '-';
|
||||
final companyInfo = CompanyBranchInfo(
|
||||
id: company.id,
|
||||
name: "${company.name} (${companyType})",
|
||||
originalName: company.name,
|
||||
isMainCompany: true,
|
||||
companyId: company.id,
|
||||
branchId: null,
|
||||
);
|
||||
companiesWithBranches.add(companyInfo);
|
||||
companies.add(companyInfo.name);
|
||||
|
||||
// 지점 정보 추가
|
||||
if (company.branches != null && company.branches!.isNotEmpty) {
|
||||
for (var branch in company.branches!) {
|
||||
final branchInfo = CompanyBranchInfo(
|
||||
id: branch.id,
|
||||
name: "${company.name} ${branch.name}",
|
||||
displayName: branch.name,
|
||||
originalName: branch.name,
|
||||
isMainCompany: false,
|
||||
companyId: company.id,
|
||||
branchId: branch.id,
|
||||
parentCompanyName: company.name,
|
||||
);
|
||||
companiesWithBranches.add(branchInfo);
|
||||
companies.add(branchInfo.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 나머지 데이터 로드
|
||||
final allUsers = dataService.getAllUsers();
|
||||
managers = allUsers.map((user) => user.name).toList();
|
||||
filteredManagers = managers;
|
||||
final allLicenses = dataService.getAllLicenses();
|
||||
licenses = allLicenses.map((license) => license.name).toList();
|
||||
if (companies.isEmpty) companies.add('기타');
|
||||
if (managers.isEmpty) managers.add('기타');
|
||||
if (licenses.isEmpty) licenses.add('기타');
|
||||
updateManagersState();
|
||||
|
||||
// 출고 회사 드롭다운 초기화
|
||||
availableCompaniesPerDropdown = [List.from(companies)];
|
||||
filteredManagersPerCompany = [List.from(managers)];
|
||||
hasManagersPerCompany = [hasManagers];
|
||||
|
||||
// 디버그 정보 출력
|
||||
debugPrint('드롭다운 데이터 로드 완료');
|
||||
debugPrint('장비 목록: ${_selectedEquipments?.length ?? 0}개');
|
||||
debugPrint('회사 및 지점 목록: ${companiesWithBranches.length}개');
|
||||
|
||||
// 수정 모드인 경우 기존 선택값 동기화
|
||||
if (isEditMode && equipmentOutId != null) {
|
||||
final equipmentOut = dataService.getEquipmentOutById(equipmentOutId!);
|
||||
if (equipmentOut != null && equipmentOut.company != null) {
|
||||
String companyName = '';
|
||||
|
||||
// 회사 이름 찾기
|
||||
for (String company in companies) {
|
||||
if (company.startsWith(equipmentOut.company!)) {
|
||||
companyName = company;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (companyName.isNotEmpty) {
|
||||
selectedCompanies[0] = companyName;
|
||||
filterManagersByCompanyAtIndex(companyName, 0);
|
||||
|
||||
// 기존 담당자 설정
|
||||
if (equipmentOut.manager != null) {
|
||||
selectedManagersPerCompany[0] = equipmentOut.manager;
|
||||
}
|
||||
}
|
||||
|
||||
// 라이센스 설정
|
||||
if (equipmentOut.license != null) {
|
||||
selectedLicense = equipmentOut.license;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 회사에 따라 담당자 목록 필터링
|
||||
void filterManagersByCompany(String? companyName) {
|
||||
if (companyName == null || companyName.isEmpty) {
|
||||
filteredManagers = managers;
|
||||
} else {
|
||||
// 회사 또는 지점 이름에서 CompanyBranchInfo 찾기
|
||||
CompanyBranchInfo? companyInfo = _findCompanyInfoByDisplayName(
|
||||
companyName,
|
||||
);
|
||||
|
||||
if (companyInfo != null && companyInfo.companyId != null) {
|
||||
int companyId = companyInfo.companyId!;
|
||||
final companyUsers =
|
||||
dataService
|
||||
.getAllUsers()
|
||||
.where((user) => user.companyId == companyId)
|
||||
.toList();
|
||||
|
||||
if (companyUsers.isNotEmpty) {
|
||||
filteredManagers = companyUsers.map((user) => user.name).toList();
|
||||
} else {
|
||||
filteredManagers = ['없음'];
|
||||
}
|
||||
} else {
|
||||
filteredManagers = ['없음'];
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedManager != null &&
|
||||
!filteredManagers.contains(selectedManager)) {
|
||||
selectedManager =
|
||||
filteredManagers.isNotEmpty ? filteredManagers[0] : null;
|
||||
}
|
||||
updateManagersState();
|
||||
|
||||
// 첫 번째 회사에 대한 담당자 목록과 동기화
|
||||
if (filteredManagersPerCompany.isNotEmpty) {
|
||||
filteredManagersPerCompany[0] = List.from(filteredManagers);
|
||||
hasManagersPerCompany[0] = hasManagers;
|
||||
if (selectedManagersPerCompany.isNotEmpty) {
|
||||
selectedManagersPerCompany[0] = selectedManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 특정 인덱스의 회사에 따라 담당자 목록 필터링
|
||||
void filterManagersByCompanyAtIndex(String? companyName, int index) {
|
||||
if (companyName == null || companyName.isEmpty) {
|
||||
filteredManagersPerCompany[index] = managers;
|
||||
} else {
|
||||
// 회사 또는 지점 이름에서 CompanyBranchInfo 찾기
|
||||
CompanyBranchInfo? companyInfo = _findCompanyInfoByDisplayName(
|
||||
companyName,
|
||||
);
|
||||
|
||||
if (companyInfo != null && companyInfo.companyId != null) {
|
||||
int companyId = companyInfo.companyId!;
|
||||
final companyUsers =
|
||||
dataService
|
||||
.getAllUsers()
|
||||
.where((user) => user.companyId == companyId)
|
||||
.toList();
|
||||
|
||||
if (companyUsers.isNotEmpty) {
|
||||
filteredManagersPerCompany[index] =
|
||||
companyUsers.map((user) => user.name).toList();
|
||||
} else {
|
||||
filteredManagersPerCompany[index] = ['없음'];
|
||||
}
|
||||
} else {
|
||||
filteredManagersPerCompany[index] = ['없음'];
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedManagersPerCompany[index] != null &&
|
||||
!filteredManagersPerCompany[index].contains(
|
||||
selectedManagersPerCompany[index],
|
||||
)) {
|
||||
selectedManagersPerCompany[index] =
|
||||
filteredManagersPerCompany[index].isNotEmpty
|
||||
? filteredManagersPerCompany[index][0]
|
||||
: null;
|
||||
}
|
||||
updateManagersStateAtIndex(index);
|
||||
|
||||
// 첫 번째 회사인 경우 기존 필드와 동기화
|
||||
if (index == 0) {
|
||||
filteredManagers = List.from(filteredManagersPerCompany[0]);
|
||||
hasManagers = hasManagersPerCompany[0];
|
||||
_selectedManager = selectedManagersPerCompany[0];
|
||||
}
|
||||
}
|
||||
|
||||
// 담당자 있는지 상태 업데이트
|
||||
void updateManagersState() {
|
||||
hasManagers =
|
||||
filteredManagers.isNotEmpty &&
|
||||
!(filteredManagers.length == 1 && filteredManagers[0] == '없음');
|
||||
}
|
||||
|
||||
// 특정 인덱스의 담당자 상태 업데이트
|
||||
void updateManagersStateAtIndex(int index) {
|
||||
hasManagersPerCompany[index] =
|
||||
filteredManagersPerCompany[index].isNotEmpty &&
|
||||
!(filteredManagersPerCompany[index].length == 1 &&
|
||||
filteredManagersPerCompany[index][0] == '없음');
|
||||
}
|
||||
|
||||
// 출고 회사 추가
|
||||
void addCompany() {
|
||||
// 이미 선택된 회사 제외한 리스트 생성
|
||||
List<String> availableCompanies = List.from(companies);
|
||||
for (String? company in selectedCompanies) {
|
||||
if (company != null) {
|
||||
availableCompanies.remove(company);
|
||||
}
|
||||
}
|
||||
|
||||
// 새 드롭다운 추가
|
||||
selectedCompanies.add(null);
|
||||
availableCompaniesPerDropdown.add(availableCompanies);
|
||||
selectedManagersPerCompany.add(null);
|
||||
filteredManagersPerCompany.add(List.from(managers));
|
||||
hasManagersPerCompany.add(false);
|
||||
}
|
||||
|
||||
// 가능한 회사 목록 업데이트
|
||||
void updateAvailableCompanies() {
|
||||
// 각 드롭다운에 대해 사용 가능한 회사 목록 업데이트
|
||||
for (int i = 0; i < selectedCompanies.length; i++) {
|
||||
List<String> availableCompanies = List.from(companies);
|
||||
|
||||
// 이미 선택된 회사 제외
|
||||
for (int j = 0; j < selectedCompanies.length; j++) {
|
||||
if (i != j && selectedCompanies[j] != null) {
|
||||
availableCompanies.remove(selectedCompanies[j]);
|
||||
}
|
||||
}
|
||||
|
||||
availableCompaniesPerDropdown[i] = availableCompanies;
|
||||
}
|
||||
}
|
||||
|
||||
// 선택 장비로 초기화
|
||||
void initializeWithSelectedEquipment(Equipment equipment) {
|
||||
manufacturer = equipment.manufacturer;
|
||||
name = equipment.name;
|
||||
category = equipment.category;
|
||||
subCategory = equipment.subCategory;
|
||||
subSubCategory = equipment.subSubCategory;
|
||||
serialNumber = equipment.serialNumber ?? '';
|
||||
barcode = equipment.barcode ?? '';
|
||||
quantity = equipment.quantity;
|
||||
hasSerialNumber = serialNumber.isNotEmpty;
|
||||
inDate = equipment.inDate;
|
||||
remarkController.text = equipment.remark ?? '';
|
||||
}
|
||||
|
||||
// 회사/지점 표시 이름을 통해 CompanyBranchInfo 객체 찾기
|
||||
CompanyBranchInfo? _findCompanyInfoByDisplayName(String displayName) {
|
||||
for (var info in companiesWithBranches) {
|
||||
if (info.name == displayName) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 출고 정보 저장 (UI에서 호출)
|
||||
Future<void> saveEquipmentOut(Function(String) onSuccess, Function(String) onError) async {
|
||||
if (formKey.currentState?.validate() != true) {
|
||||
onError('폼 유효성 검사 실패');
|
||||
return;
|
||||
}
|
||||
formKey.currentState?.save();
|
||||
|
||||
_isSaving = true;
|
||||
_error = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
|
||||
// 선택된 회사가 없는지 확인
|
||||
bool hasAnySelectedCompany = selectedCompanies.any(
|
||||
(company) => company != null,
|
||||
);
|
||||
if (!hasAnySelectedCompany) {
|
||||
onError('최소 하나의 출고 회사를 선택해주세요');
|
||||
return;
|
||||
}
|
||||
|
||||
// 기존 방식으로 첫 번째 회사 정보 처리
|
||||
String? companyName;
|
||||
if (selectedCompanies.isNotEmpty && selectedCompanies[0] != null) {
|
||||
CompanyBranchInfo? companyInfo = _findCompanyInfoByDisplayName(
|
||||
selectedCompanies[0]!,
|
||||
);
|
||||
if (companyInfo != null) {
|
||||
companyName =
|
||||
companyInfo.isMainCompany
|
||||
? companyInfo
|
||||
.originalName // 본사인 경우 회사 원래 이름
|
||||
: "${companyInfo.originalName} (${companyInfo.branchId})"; // 지점인 경우 지점 정보 포함
|
||||
} else {
|
||||
companyName = selectedCompanies[0]!.replaceAll(
|
||||
RegExp(r' \(.*\)\$'),
|
||||
'',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
onError('최소 하나의 출고 회사를 선택해주세요');
|
||||
return;
|
||||
}
|
||||
|
||||
if (_useApi) {
|
||||
// API 호출 방식
|
||||
if (isEditMode && equipmentOutId != null) {
|
||||
// TODO: 출고 정보 업데이트 API 호출
|
||||
throw UnimplementedError('Equipment out update API not implemented yet');
|
||||
} else {
|
||||
// 장비 출고 처리
|
||||
if (selectedEquipments != null && selectedEquipments!.isNotEmpty) {
|
||||
List<String> successfulOuts = [];
|
||||
List<String> failedOuts = [];
|
||||
|
||||
for (var equipmentData in selectedEquipments!) {
|
||||
final equipment = equipmentData['equipment'] as Equipment;
|
||||
if (equipment.id != null) {
|
||||
// 회사 ID 가져오기 - 현재는 목 데이터에서 찾기
|
||||
CompanyBranchInfo? companyInfo = _findCompanyInfoByDisplayName(
|
||||
selectedCompanies[0]!,
|
||||
);
|
||||
|
||||
int? companyId = companyInfo?.companyId;
|
||||
int? branchId = companyInfo?.branchId;
|
||||
|
||||
if (companyId == null) {
|
||||
// 목 데이터에서 회사 ID 찾기
|
||||
final company = dataService.getAllCompanies().firstWhere(
|
||||
(c) => c.name == companyName,
|
||||
orElse: () => Company(
|
||||
id: 1, // 기본값 설정
|
||||
name: companyName ?? '기타',
|
||||
businessNumber: '',
|
||||
address: '',
|
||||
phone: '',
|
||||
companyTypes: [],
|
||||
),
|
||||
);
|
||||
companyId = company.id;
|
||||
}
|
||||
|
||||
if (companyId != null) {
|
||||
try {
|
||||
await _equipmentService.equipmentOut(
|
||||
equipmentId: equipment.id!,
|
||||
quantity: equipment.quantity,
|
||||
companyId: companyId,
|
||||
branchId: branchId,
|
||||
notes: '${remarkController.text.trim()}${outType != '출고' ? ' (${outType})' : ''}',
|
||||
);
|
||||
successfulOuts.add('${equipment.manufacturer} ${equipment.name}');
|
||||
} catch (e) {
|
||||
failedOuts.add('${equipment.manufacturer} ${equipment.name}: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 결과 메시지 생성
|
||||
if (failedOuts.isEmpty) {
|
||||
onSuccess('${successfulOuts.length}개 장비 출고 완료');
|
||||
} else if (successfulOuts.isEmpty) {
|
||||
onError('모든 장비 출고 실패:\n${failedOuts.join('\n')}');
|
||||
} else {
|
||||
onSuccess('${successfulOuts.length}개 성공, ${failedOuts.length}개 실패\n실패: ${failedOuts.join(', ')}');
|
||||
}
|
||||
} else {
|
||||
onError('출고할 장비가 선택되지 않았습니다');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Mock 데이터 사용
|
||||
if (isEditMode && equipmentOutId != null) {
|
||||
final equipmentOut = dataService.getEquipmentOutById(equipmentOutId!);
|
||||
if (equipmentOut != null) {
|
||||
final updatedEquipmentOut = EquipmentOut(
|
||||
id: equipmentOut.id,
|
||||
equipment: equipmentOut.equipment,
|
||||
outDate: equipmentOut.outDate,
|
||||
status: returnType == '재입고' ? 'I' : 'R',
|
||||
company: companyName,
|
||||
manager: equipmentOut.manager,
|
||||
license: equipmentOut.license,
|
||||
returnDate: returnDate,
|
||||
returnType: returnType,
|
||||
remark: remarkController.text.trim(),
|
||||
);
|
||||
dataService.updateEquipmentOut(updatedEquipmentOut);
|
||||
onSuccess('장비 출고 상태 변경 완료');
|
||||
} else {
|
||||
onError('출고 정보를 찾을 수 없습니다');
|
||||
}
|
||||
} else {
|
||||
if (selectedEquipments != null && selectedEquipments!.isNotEmpty) {
|
||||
// 여러 회사에 각각 출고 처리
|
||||
List<String> successCompanies = [];
|
||||
|
||||
// 선택된 모든 회사에 대해 출고 처리
|
||||
for (int i = 0; i < selectedCompanies.length; i++) {
|
||||
if (selectedCompanies[i] == null) continue;
|
||||
|
||||
CompanyBranchInfo? companyInfo = _findCompanyInfoByDisplayName(
|
||||
selectedCompanies[i]!,
|
||||
);
|
||||
String curCompanyName;
|
||||
|
||||
if (companyInfo != null) {
|
||||
curCompanyName =
|
||||
companyInfo.isMainCompany
|
||||
? companyInfo
|
||||
.originalName // 본사인 경우 회사 원래 이름
|
||||
: "${companyInfo.originalName} (${companyInfo.branchId})"; // 지점인 경우 지점 정보 포함
|
||||
} else {
|
||||
curCompanyName = selectedCompanies[i]!.replaceAll(
|
||||
RegExp(r' \(.*\)\$'),
|
||||
'',
|
||||
);
|
||||
}
|
||||
|
||||
String? curManager = selectedManagersPerCompany[i];
|
||||
|
||||
if (curManager == null || curManager == '없음') {
|
||||
// 담당자 없는 회사는 건너뛰기
|
||||
continue;
|
||||
}
|
||||
|
||||
// 해당 회사에 모든 장비 출고 처리
|
||||
for (final equipmentData in selectedEquipments!) {
|
||||
final equipment = equipmentData['equipment'] as Equipment;
|
||||
final equipmentInId = equipmentData['equipmentInId'] as int;
|
||||
final newEquipmentOut = EquipmentOut(
|
||||
equipment: equipment,
|
||||
outDate: outDate,
|
||||
company: curCompanyName,
|
||||
manager: curManager,
|
||||
license: selectedLicense,
|
||||
remark: remarkController.text.trim(),
|
||||
);
|
||||
dataService.changeEquipmentStatus(equipmentInId, newEquipmentOut);
|
||||
}
|
||||
|
||||
successCompanies.add(companyInfo?.name ?? curCompanyName);
|
||||
}
|
||||
|
||||
if (successCompanies.isEmpty) {
|
||||
onError('모든 회사에 담당자가 없어 출고 처리할 수 없습니다');
|
||||
} else {
|
||||
onSuccess('${successCompanies.join(", ")} 회사로 다중 장비 출고 처리 완료');
|
||||
}
|
||||
} else if (selectedEquipmentInId != null) {
|
||||
final equipment = Equipment(
|
||||
manufacturer: manufacturer,
|
||||
name: name,
|
||||
category: category,
|
||||
subCategory: subCategory,
|
||||
subSubCategory: subSubCategory,
|
||||
serialNumber: (hasSerialNumber) ? serialNumber : null,
|
||||
barcode: barcode.isNotEmpty ? barcode : null,
|
||||
quantity: quantity,
|
||||
inDate: inDate,
|
||||
remark: remarkController.text.trim(),
|
||||
);
|
||||
|
||||
// 선택된 모든 회사에 대해 출고 처리
|
||||
List<String> successCompanies = [];
|
||||
|
||||
for (int i = 0; i < selectedCompanies.length; i++) {
|
||||
if (selectedCompanies[i] == null) continue;
|
||||
|
||||
CompanyBranchInfo? companyInfo = _findCompanyInfoByDisplayName(
|
||||
selectedCompanies[i]!,
|
||||
);
|
||||
String curCompanyName;
|
||||
|
||||
if (companyInfo != null) {
|
||||
curCompanyName =
|
||||
companyInfo.isMainCompany
|
||||
? companyInfo
|
||||
.originalName // 본사인 경우 회사 원래 이름
|
||||
: "${companyInfo.originalName} (${companyInfo.branchId})"; // 지점인 경우 지점 정보 포함
|
||||
} else {
|
||||
curCompanyName = selectedCompanies[i]!.replaceAll(
|
||||
RegExp(r' \(.*\)\$'),
|
||||
'',
|
||||
);
|
||||
}
|
||||
|
||||
String? curManager = selectedManagersPerCompany[i];
|
||||
|
||||
if (curManager == null || curManager == '없음') {
|
||||
// 담당자 없는 회사는 건너뛰기
|
||||
continue;
|
||||
}
|
||||
|
||||
final newEquipmentOut = EquipmentOut(
|
||||
equipment: equipment,
|
||||
outDate: outDate,
|
||||
company: curCompanyName,
|
||||
manager: curManager,
|
||||
license: selectedLicense,
|
||||
remark: remarkController.text.trim(),
|
||||
);
|
||||
dataService.changeEquipmentStatus(
|
||||
selectedEquipmentInId!,
|
||||
newEquipmentOut,
|
||||
);
|
||||
|
||||
successCompanies.add(companyInfo?.name ?? curCompanyName);
|
||||
break; // 한 장비는 한 회사에만 출고
|
||||
}
|
||||
|
||||
if (successCompanies.isEmpty) {
|
||||
onError('모든 회사에 담당자가 없어 출고 처리할 수 없습니다');
|
||||
} else {
|
||||
onSuccess('${successCompanies.join(", ")} 회사로 장비 출고 처리 완료');
|
||||
}
|
||||
} else {
|
||||
final equipment = Equipment(
|
||||
manufacturer: manufacturer,
|
||||
name: name,
|
||||
category: category,
|
||||
subCategory: subCategory,
|
||||
subSubCategory: subSubCategory,
|
||||
serialNumber: null,
|
||||
barcode: null,
|
||||
quantity: 1,
|
||||
inDate: inDate,
|
||||
remark: remarkController.text.trim(),
|
||||
);
|
||||
|
||||
// 선택된 모든 회사에 대해 출고 처리
|
||||
List<String> successCompanies = [];
|
||||
|
||||
for (int i = 0; i < selectedCompanies.length; i++) {
|
||||
if (selectedCompanies[i] == null) continue;
|
||||
|
||||
CompanyBranchInfo? companyInfo = _findCompanyInfoByDisplayName(
|
||||
selectedCompanies[i]!,
|
||||
);
|
||||
String curCompanyName;
|
||||
|
||||
if (companyInfo != null) {
|
||||
curCompanyName =
|
||||
companyInfo.isMainCompany
|
||||
? companyInfo
|
||||
.originalName // 본사인 경우 회사 원래 이름
|
||||
: "${companyInfo.originalName} (${companyInfo.branchId})"; // 지점인 경우 지점 정보 포함
|
||||
} else {
|
||||
curCompanyName = selectedCompanies[i]!.replaceAll(
|
||||
RegExp(r' \(.*\)\$'),
|
||||
'',
|
||||
);
|
||||
}
|
||||
|
||||
String? curManager = selectedManagersPerCompany[i];
|
||||
|
||||
if (curManager == null || curManager == '없음') {
|
||||
// 담당자 없는 회사는 건너뛰기
|
||||
continue;
|
||||
}
|
||||
|
||||
final newEquipmentOut = EquipmentOut(
|
||||
equipment: equipment,
|
||||
outDate: outDate,
|
||||
company: curCompanyName,
|
||||
manager: curManager,
|
||||
license: selectedLicense,
|
||||
remark: remarkController.text.trim(),
|
||||
);
|
||||
dataService.addEquipmentOut(newEquipmentOut);
|
||||
|
||||
successCompanies.add(companyInfo?.name ?? curCompanyName);
|
||||
}
|
||||
|
||||
if (successCompanies.isEmpty) {
|
||||
onError('모든 회사에 담당자가 없어 출고 처리할 수 없습니다');
|
||||
} else {
|
||||
onSuccess('${successCompanies.join(", ")} 회사로 새 출고 장비 추가 완료');
|
||||
}
|
||||
}
|
||||
} on Failure catch (e) {
|
||||
_error = e.message;
|
||||
onError(e.message);
|
||||
} catch (e) {
|
||||
_error = 'An unexpected error occurred: $e';
|
||||
onError(_error!);
|
||||
} finally {
|
||||
_isSaving = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 날짜 포맷 유틸리티
|
||||
String formatDate(DateTime date) {
|
||||
return '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
// 에러 처리
|
||||
void clearError() {
|
||||
_error = null;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// API 사용 여부 토글 (테스트용)
|
||||
void toggleApiUsage() {
|
||||
_useApi = !_useApi;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
remarkController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// 회사 및 지점 정보를 저장하는 클래스
|
||||
class CompanyBranchInfo {
|
||||
final int? id;
|
||||
final String name; // 표시용 이름 (회사명 + 지점명 또는 회사명 (유형))
|
||||
final String originalName; // 원래 이름 (회사 본사명 또는 지점명)
|
||||
final String? displayName; // UI에 표시할 이름 (주로 지점명)
|
||||
final bool isMainCompany; // 본사인지 지점인지 구분
|
||||
final int? companyId; // 회사 ID
|
||||
final int? branchId; // 지점 ID
|
||||
final String? parentCompanyName; // 부모 회사명 (지점인 경우)
|
||||
|
||||
CompanyBranchInfo({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.originalName,
|
||||
this.displayName,
|
||||
required this.isMainCompany,
|
||||
required this.companyId,
|
||||
required this.branchId,
|
||||
this.parentCompanyName,
|
||||
});
|
||||
}
|
||||
@@ -1,57 +1,186 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/models/license_model.dart';
|
||||
import 'package:superport/services/license_service.dart';
|
||||
import 'package:superport/services/mock_data_service.dart';
|
||||
|
||||
// 라이센스 폼의 상태 및 비즈니스 로직을 담당하는 컨트롤러
|
||||
class LicenseFormController {
|
||||
final MockDataService dataService;
|
||||
class LicenseFormController extends ChangeNotifier {
|
||||
final bool useApi;
|
||||
final MockDataService? mockDataService;
|
||||
late final LicenseService _licenseService;
|
||||
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
|
||||
bool isEditMode = false;
|
||||
int? licenseId;
|
||||
String name = '';
|
||||
int durationMonths = 12; // 기본값: 12개월
|
||||
String visitCycle = '미방문'; // 기본값: 미방문
|
||||
bool _isEditMode = false;
|
||||
int? _licenseId;
|
||||
License? _originalLicense;
|
||||
bool _isLoading = false;
|
||||
String? _error;
|
||||
bool _isSaving = false;
|
||||
|
||||
LicenseFormController({required this.dataService, this.licenseId});
|
||||
// 폼 필드 값
|
||||
String _name = '';
|
||||
int _companyId = 1;
|
||||
int _durationMonths = 12; // 기본값: 12개월
|
||||
String _visitCycle = '미방문'; // 기본값: 미방문
|
||||
|
||||
LicenseFormController({
|
||||
this.useApi = true,
|
||||
this.mockDataService,
|
||||
int? licenseId,
|
||||
}) {
|
||||
if (useApi && GetIt.instance.isRegistered<LicenseService>()) {
|
||||
_licenseService = GetIt.instance<LicenseService>();
|
||||
}
|
||||
|
||||
if (licenseId != null) {
|
||||
_licenseId = licenseId;
|
||||
_isEditMode = true;
|
||||
loadLicense();
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
bool get isEditMode => _isEditMode;
|
||||
int? get licenseId => _licenseId;
|
||||
License? get originalLicense => _originalLicense;
|
||||
bool get isLoading => _isLoading;
|
||||
String? get error => _error;
|
||||
bool get isSaving => _isSaving;
|
||||
String get name => _name;
|
||||
int get companyId => _companyId;
|
||||
int get durationMonths => _durationMonths;
|
||||
String get visitCycle => _visitCycle;
|
||||
|
||||
// Setters
|
||||
void setName(String value) {
|
||||
_name = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setCompanyId(int value) {
|
||||
_companyId = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setDurationMonths(int value) {
|
||||
_durationMonths = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setVisitCycle(String value) {
|
||||
_visitCycle = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 라이센스 정보 로드 (수정 모드)
|
||||
void loadLicense() {
|
||||
if (licenseId == null) return;
|
||||
final license = dataService.getLicenseById(licenseId!);
|
||||
if (license != null) {
|
||||
name = license.name;
|
||||
durationMonths = license.durationMonths;
|
||||
visitCycle = license.visitCycle;
|
||||
Future<void> loadLicense() async {
|
||||
if (_licenseId == null) return;
|
||||
|
||||
_isLoading = true;
|
||||
_error = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<LicenseService>()) {
|
||||
_originalLicense = await _licenseService.getLicenseById(_licenseId!);
|
||||
} else {
|
||||
_originalLicense = mockDataService?.getLicenseById(_licenseId!);
|
||||
}
|
||||
|
||||
if (_originalLicense != null) {
|
||||
_name = _originalLicense!.name;
|
||||
_companyId = _originalLicense!.companyId;
|
||||
_durationMonths = _originalLicense!.durationMonths;
|
||||
_visitCycle = _originalLicense!.visitCycle;
|
||||
}
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 라이센스 저장 (UI에서 호출)
|
||||
void saveLicense(Function() onSuccess) {
|
||||
if (formKey.currentState?.validate() != true) return;
|
||||
// 라이센스 저장
|
||||
Future<bool> saveLicense() async {
|
||||
if (formKey.currentState?.validate() != true) return false;
|
||||
|
||||
formKey.currentState?.save();
|
||||
if (isEditMode && licenseId != null) {
|
||||
final license = dataService.getLicenseById(licenseId!);
|
||||
if (license != null) {
|
||||
final updatedLicense = License(
|
||||
id: license.id,
|
||||
companyId: license.companyId,
|
||||
name: name,
|
||||
durationMonths: durationMonths,
|
||||
visitCycle: visitCycle,
|
||||
);
|
||||
dataService.updateLicense(updatedLicense);
|
||||
}
|
||||
} else {
|
||||
// 라이센스 추가 시 임시 회사 ID 사용 또는 나중에 설정하도록 변경
|
||||
final newLicense = License(
|
||||
companyId: 1, // 기본값 또는 필요에 따라 수정
|
||||
name: name,
|
||||
durationMonths: durationMonths,
|
||||
visitCycle: visitCycle,
|
||||
|
||||
_isSaving = true;
|
||||
_error = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final license = License(
|
||||
id: _isEditMode ? _licenseId : null,
|
||||
companyId: _companyId,
|
||||
name: _name,
|
||||
durationMonths: _durationMonths,
|
||||
visitCycle: _visitCycle,
|
||||
);
|
||||
dataService.addLicense(newLicense);
|
||||
|
||||
if (useApi && GetIt.instance.isRegistered<LicenseService>()) {
|
||||
if (_isEditMode) {
|
||||
await _licenseService.updateLicense(license);
|
||||
} else {
|
||||
await _licenseService.createLicense(license);
|
||||
}
|
||||
} else {
|
||||
if (_isEditMode) {
|
||||
mockDataService?.updateLicense(license);
|
||||
} else {
|
||||
mockDataService?.addLicense(license);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
notifyListeners();
|
||||
return false;
|
||||
} finally {
|
||||
_isSaving = false;
|
||||
notifyListeners();
|
||||
}
|
||||
onSuccess();
|
||||
}
|
||||
|
||||
// 폼 초기화
|
||||
void resetForm() {
|
||||
_name = '';
|
||||
_companyId = 1;
|
||||
_durationMonths = 12;
|
||||
_visitCycle = '미방문';
|
||||
_error = null;
|
||||
formKey.currentState?.reset();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 유효성 검사
|
||||
String? validateName(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '라이선스명을 입력해주세요';
|
||||
}
|
||||
if (value.length < 2) {
|
||||
return '라이선스명은 2자 이상이어야 합니다';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? validateDuration(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '계약 기간을 입력해주세요';
|
||||
}
|
||||
final duration = int.tryParse(value);
|
||||
if (duration == null || duration < 1) {
|
||||
return '유효한 계약 기간을 입력해주세요';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,227 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/models/license_model.dart';
|
||||
import 'package:superport/services/license_service.dart';
|
||||
import 'package:superport/services/mock_data_service.dart';
|
||||
|
||||
// 라이센스 목록 화면의 상태 및 비즈니스 로직을 담당하는 컨트롤러
|
||||
class LicenseListController {
|
||||
final MockDataService dataService;
|
||||
List<License> licenses = [];
|
||||
class LicenseListController extends ChangeNotifier {
|
||||
final bool useApi;
|
||||
final MockDataService? mockDataService;
|
||||
late final LicenseService _licenseService;
|
||||
|
||||
List<License> _licenses = [];
|
||||
List<License> _filteredLicenses = [];
|
||||
bool _isLoading = false;
|
||||
String? _error;
|
||||
String _searchQuery = '';
|
||||
int _currentPage = 1;
|
||||
final int _pageSize = 20;
|
||||
bool _hasMore = true;
|
||||
int _total = 0;
|
||||
|
||||
LicenseListController({required this.dataService});
|
||||
// 필터 옵션
|
||||
int? _selectedCompanyId;
|
||||
bool? _isActive;
|
||||
String? _licenseType;
|
||||
|
||||
LicenseListController({this.useApi = true, this.mockDataService}) {
|
||||
if (useApi && GetIt.instance.isRegistered<LicenseService>()) {
|
||||
_licenseService = GetIt.instance<LicenseService>();
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
List<License> get licenses => _filteredLicenses;
|
||||
bool get isLoading => _isLoading;
|
||||
String? get error => _error;
|
||||
String get searchQuery => _searchQuery;
|
||||
int get currentPage => _currentPage;
|
||||
bool get hasMore => _hasMore;
|
||||
int get total => _total;
|
||||
int? get selectedCompanyId => _selectedCompanyId;
|
||||
bool? get isActive => _isActive;
|
||||
String? get licenseType => _licenseType;
|
||||
|
||||
// 데이터 로드
|
||||
void loadData() {
|
||||
licenses = dataService.getAllLicenses();
|
||||
Future<void> loadData({bool isInitialLoad = true}) async {
|
||||
if (_isLoading) return;
|
||||
|
||||
_isLoading = true;
|
||||
_error = null;
|
||||
|
||||
if (isInitialLoad) {
|
||||
_currentPage = 1;
|
||||
_licenses.clear();
|
||||
_hasMore = true;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<LicenseService>()) {
|
||||
// API 사용
|
||||
final fetchedLicenses = await _licenseService.getLicenses(
|
||||
page: _currentPage,
|
||||
perPage: _pageSize,
|
||||
isActive: _isActive,
|
||||
companyId: _selectedCompanyId,
|
||||
licenseType: _licenseType,
|
||||
);
|
||||
|
||||
if (isInitialLoad) {
|
||||
_licenses = fetchedLicenses;
|
||||
} else {
|
||||
_licenses.addAll(fetchedLicenses);
|
||||
}
|
||||
|
||||
_hasMore = fetchedLicenses.length >= _pageSize;
|
||||
|
||||
// 전체 개수 조회
|
||||
_total = await _licenseService.getTotalLicenses(
|
||||
isActive: _isActive,
|
||||
companyId: _selectedCompanyId,
|
||||
licenseType: _licenseType,
|
||||
);
|
||||
} else {
|
||||
// Mock 데이터 사용
|
||||
final allLicenses = mockDataService?.getAllLicenses() ?? [];
|
||||
|
||||
// 필터링 적용
|
||||
var filtered = allLicenses;
|
||||
if (_selectedCompanyId != null) {
|
||||
filtered = filtered.where((l) => l.companyId == _selectedCompanyId).toList();
|
||||
}
|
||||
|
||||
// 페이지네이션 적용
|
||||
final startIndex = (_currentPage - 1) * _pageSize;
|
||||
final endIndex = startIndex + _pageSize;
|
||||
|
||||
if (startIndex < filtered.length) {
|
||||
final pageLicenses = filtered.sublist(
|
||||
startIndex,
|
||||
endIndex > filtered.length ? filtered.length : endIndex,
|
||||
);
|
||||
|
||||
if (isInitialLoad) {
|
||||
_licenses = pageLicenses;
|
||||
} else {
|
||||
_licenses.addAll(pageLicenses);
|
||||
}
|
||||
|
||||
_hasMore = endIndex < filtered.length;
|
||||
} else {
|
||||
_hasMore = false;
|
||||
}
|
||||
|
||||
_total = filtered.length;
|
||||
}
|
||||
|
||||
_applySearchFilter();
|
||||
|
||||
if (!isInitialLoad) {
|
||||
_currentPage++;
|
||||
}
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 다음 페이지 로드
|
||||
Future<void> loadNextPage() async {
|
||||
if (!_hasMore || _isLoading) return;
|
||||
_currentPage++;
|
||||
await loadData(isInitialLoad: false);
|
||||
}
|
||||
|
||||
// 검색
|
||||
void search(String query) {
|
||||
_searchQuery = query;
|
||||
_applySearchFilter();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 검색 필터 적용
|
||||
void _applySearchFilter() {
|
||||
if (_searchQuery.isEmpty) {
|
||||
_filteredLicenses = List.from(_licenses);
|
||||
} else {
|
||||
_filteredLicenses = _licenses.where((license) {
|
||||
return license.name.toLowerCase().contains(_searchQuery.toLowerCase());
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
// 필터 설정
|
||||
void setFilters({
|
||||
int? companyId,
|
||||
bool? isActive,
|
||||
String? licenseType,
|
||||
}) {
|
||||
_selectedCompanyId = companyId;
|
||||
_isActive = isActive;
|
||||
_licenseType = licenseType;
|
||||
loadData();
|
||||
}
|
||||
|
||||
// 필터 초기화
|
||||
void clearFilters() {
|
||||
_selectedCompanyId = null;
|
||||
_isActive = null;
|
||||
_licenseType = null;
|
||||
_searchQuery = '';
|
||||
loadData();
|
||||
}
|
||||
|
||||
// 라이센스 삭제
|
||||
void deleteLicense(int id) {
|
||||
dataService.deleteLicense(id);
|
||||
loadData();
|
||||
Future<void> deleteLicense(int id) async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<LicenseService>()) {
|
||||
await _licenseService.deleteLicense(id);
|
||||
} else {
|
||||
mockDataService?.deleteLicense(id);
|
||||
}
|
||||
|
||||
// 목록에서 제거
|
||||
_licenses.removeWhere((l) => l.id == id);
|
||||
_applySearchFilter();
|
||||
_total--;
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 새로고침
|
||||
Future<void> refresh() async {
|
||||
await loadData();
|
||||
}
|
||||
|
||||
// 만료 예정 라이선스 조회
|
||||
Future<List<License>> getExpiringLicenses({int days = 30}) async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<LicenseService>()) {
|
||||
return await _licenseService.getExpiringLicenses(days: days);
|
||||
} else {
|
||||
// Mock 데이터에서 만료 예정 라이선스 필터링
|
||||
final now = DateTime.now();
|
||||
final allLicenses = mockDataService?.getAllLicenses() ?? [];
|
||||
|
||||
return allLicenses.where((license) {
|
||||
// Mock 데이터는 만료일이 없으므로 임의로 계산
|
||||
final expiryDate = now.add(Duration(days: license.durationMonths * 30));
|
||||
final daysUntilExpiry = expiryDate.difference(now).inDays;
|
||||
return daysUntilExpiry > 0 && daysUntilExpiry <= days;
|
||||
}).toList();
|
||||
}
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
notifyListeners();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/models/warehouse_location_model.dart';
|
||||
import 'package:superport/models/address_model.dart';
|
||||
import 'package:superport/services/warehouse_service.dart';
|
||||
import 'package:superport/services/mock_data_service.dart';
|
||||
|
||||
/// 입고지 폼 상태 및 저장/수정 로직을 담당하는 컨트롤러
|
||||
class WarehouseLocationFormController {
|
||||
class WarehouseLocationFormController extends ChangeNotifier {
|
||||
final bool useApi;
|
||||
final MockDataService? mockDataService;
|
||||
late final WarehouseService _warehouseService;
|
||||
|
||||
/// 폼 키
|
||||
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
|
||||
@@ -15,74 +21,157 @@ class WarehouseLocationFormController {
|
||||
final TextEditingController remarkController = TextEditingController();
|
||||
|
||||
/// 주소 정보
|
||||
Address address = const Address();
|
||||
Address _address = const Address();
|
||||
|
||||
/// 저장 중 여부
|
||||
bool isSaving = false;
|
||||
bool _isSaving = false;
|
||||
|
||||
/// 수정 모드 여부
|
||||
bool isEditMode = false;
|
||||
bool _isEditMode = false;
|
||||
|
||||
/// 입고지 id (수정 모드)
|
||||
int? id;
|
||||
int? _id;
|
||||
|
||||
/// 로딩 상태
|
||||
bool _isLoading = false;
|
||||
|
||||
/// 에러 메시지
|
||||
String? _error;
|
||||
|
||||
/// 원본 창고 위치 (수정 모드)
|
||||
WarehouseLocation? _originalLocation;
|
||||
|
||||
WarehouseLocationFormController({
|
||||
this.useApi = true,
|
||||
this.mockDataService,
|
||||
int? locationId,
|
||||
}) {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
_warehouseService = GetIt.instance<WarehouseService>();
|
||||
}
|
||||
|
||||
if (locationId != null) {
|
||||
initialize(locationId);
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
Address get address => _address;
|
||||
bool get isSaving => _isSaving;
|
||||
bool get isEditMode => _isEditMode;
|
||||
int? get id => _id;
|
||||
bool get isLoading => _isLoading;
|
||||
String? get error => _error;
|
||||
WarehouseLocation? get originalLocation => _originalLocation;
|
||||
|
||||
/// 기존 데이터 세팅 (수정 모드)
|
||||
void initialize(int? locationId) {
|
||||
id = locationId;
|
||||
if (id != null) {
|
||||
final location = MockDataService().getWarehouseLocationById(id!);
|
||||
if (location != null) {
|
||||
isEditMode = true;
|
||||
nameController.text = location.name;
|
||||
address = location.address;
|
||||
remarkController.text = location.remark ?? '';
|
||||
Future<void> initialize(int locationId) async {
|
||||
_id = locationId;
|
||||
_isEditMode = true;
|
||||
_isLoading = true;
|
||||
_error = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
_originalLocation = await _warehouseService.getWarehouseLocationById(locationId);
|
||||
} else {
|
||||
_originalLocation = mockDataService?.getWarehouseLocationById(locationId);
|
||||
}
|
||||
|
||||
if (_originalLocation != null) {
|
||||
nameController.text = _originalLocation!.name;
|
||||
_address = _originalLocation!.address;
|
||||
remarkController.text = _originalLocation!.remark ?? '';
|
||||
}
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 주소 변경 처리
|
||||
void updateAddress(Address newAddress) {
|
||||
address = newAddress;
|
||||
_address = newAddress;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 저장 처리 (추가/수정)
|
||||
Future<bool> save(BuildContext context) async {
|
||||
Future<bool> save() async {
|
||||
if (!formKey.currentState!.validate()) return false;
|
||||
isSaving = true;
|
||||
if (isEditMode) {
|
||||
// 수정
|
||||
MockDataService().updateWarehouseLocation(
|
||||
WarehouseLocation(
|
||||
id: id!,
|
||||
name: nameController.text.trim(),
|
||||
address: address,
|
||||
remark: remarkController.text.trim(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 추가
|
||||
MockDataService().addWarehouseLocation(
|
||||
WarehouseLocation(
|
||||
id: 0,
|
||||
name: nameController.text.trim(),
|
||||
address: address,
|
||||
remark: remarkController.text.trim(),
|
||||
),
|
||||
|
||||
_isSaving = true;
|
||||
_error = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final location = WarehouseLocation(
|
||||
id: _isEditMode ? _id! : 0,
|
||||
name: nameController.text.trim(),
|
||||
address: _address,
|
||||
remark: remarkController.text.trim().isEmpty ? null : remarkController.text.trim(),
|
||||
);
|
||||
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
if (_isEditMode) {
|
||||
await _warehouseService.updateWarehouseLocation(location);
|
||||
} else {
|
||||
await _warehouseService.createWarehouseLocation(location);
|
||||
}
|
||||
} else {
|
||||
if (_isEditMode) {
|
||||
mockDataService?.updateWarehouseLocation(location);
|
||||
} else {
|
||||
mockDataService?.addWarehouseLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
notifyListeners();
|
||||
return false;
|
||||
} finally {
|
||||
_isSaving = false;
|
||||
notifyListeners();
|
||||
}
|
||||
isSaving = false;
|
||||
Navigator.pop(context, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// 취소 처리
|
||||
void cancel(BuildContext context) {
|
||||
Navigator.pop(context, false);
|
||||
/// 폼 초기화
|
||||
void resetForm() {
|
||||
nameController.clear();
|
||||
remarkController.clear();
|
||||
_address = const Address();
|
||||
_error = null;
|
||||
formKey.currentState?.reset();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 유효성 검사
|
||||
String? validateName(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '입고지명을 입력해주세요';
|
||||
}
|
||||
if (value.length < 2) {
|
||||
return '입고지명은 2자 이상이어야 합니다';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? validateAddress() {
|
||||
if (_address.isEmpty) {
|
||||
return '주소를 입력해주세요';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// 컨트롤러 해제
|
||||
@override
|
||||
void dispose() {
|
||||
nameController.dispose();
|
||||
remarkController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,246 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/models/warehouse_location_model.dart';
|
||||
import 'package:superport/services/warehouse_service.dart';
|
||||
import 'package:superport/services/mock_data_service.dart';
|
||||
|
||||
/// 입고지 리스트 상태 및 CRUD만 담당하는 컨트롤러 클래스 (SRP 적용)
|
||||
/// UI, 네비게이션, 다이얼로그 등은 포함하지 않음
|
||||
/// 향후 서비스/리포지토리 DI 구조로 확장 가능
|
||||
class WarehouseLocationListController {
|
||||
/// 입고지 데이터 서비스 (mock)
|
||||
final MockDataService _dataService = MockDataService();
|
||||
class WarehouseLocationListController extends ChangeNotifier {
|
||||
final bool useApi;
|
||||
final MockDataService? mockDataService;
|
||||
late final WarehouseService _warehouseService;
|
||||
|
||||
List<WarehouseLocation> _warehouseLocations = [];
|
||||
List<WarehouseLocation> _filteredLocations = [];
|
||||
bool _isLoading = false;
|
||||
String? _error;
|
||||
String _searchQuery = '';
|
||||
int _currentPage = 1;
|
||||
final int _pageSize = 20;
|
||||
bool _hasMore = true;
|
||||
int _total = 0;
|
||||
|
||||
/// 전체 입고지 목록
|
||||
List<WarehouseLocation> warehouseLocations = [];
|
||||
// 필터 옵션
|
||||
bool? _isActive;
|
||||
|
||||
WarehouseLocationListController({this.useApi = true, this.mockDataService}) {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
_warehouseService = GetIt.instance<WarehouseService>();
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
List<WarehouseLocation> get warehouseLocations => _filteredLocations;
|
||||
bool get isLoading => _isLoading;
|
||||
String? get error => _error;
|
||||
String get searchQuery => _searchQuery;
|
||||
int get currentPage => _currentPage;
|
||||
bool get hasMore => _hasMore;
|
||||
int get total => _total;
|
||||
bool? get isActive => _isActive;
|
||||
|
||||
/// 데이터 로드
|
||||
void loadWarehouseLocations() {
|
||||
warehouseLocations = _dataService.getAllWarehouseLocations();
|
||||
Future<void> loadWarehouseLocations({bool isInitialLoad = true}) async {
|
||||
if (_isLoading) return;
|
||||
|
||||
_isLoading = true;
|
||||
_error = null;
|
||||
|
||||
if (isInitialLoad) {
|
||||
_currentPage = 1;
|
||||
_warehouseLocations.clear();
|
||||
_hasMore = true;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
// API 사용
|
||||
final fetchedLocations = await _warehouseService.getWarehouseLocations(
|
||||
page: _currentPage,
|
||||
perPage: _pageSize,
|
||||
isActive: _isActive,
|
||||
);
|
||||
|
||||
if (isInitialLoad) {
|
||||
_warehouseLocations = fetchedLocations;
|
||||
} else {
|
||||
_warehouseLocations.addAll(fetchedLocations);
|
||||
}
|
||||
|
||||
_hasMore = fetchedLocations.length >= _pageSize;
|
||||
|
||||
// 전체 개수 조회
|
||||
_total = await _warehouseService.getTotalWarehouseLocations(
|
||||
isActive: _isActive,
|
||||
);
|
||||
} else {
|
||||
// Mock 데이터 사용
|
||||
final allLocations = mockDataService?.getAllWarehouseLocations() ?? [];
|
||||
|
||||
// 필터링 적용
|
||||
var filtered = allLocations;
|
||||
if (_isActive != null) {
|
||||
// Mock 데이터에는 isActive 필드가 없으므로 모두 활성으로 처리
|
||||
filtered = _isActive! ? allLocations : [];
|
||||
}
|
||||
|
||||
// 페이지네이션 적용
|
||||
final startIndex = (_currentPage - 1) * _pageSize;
|
||||
final endIndex = startIndex + _pageSize;
|
||||
|
||||
if (startIndex < filtered.length) {
|
||||
final pageLocations = filtered.sublist(
|
||||
startIndex,
|
||||
endIndex > filtered.length ? filtered.length : endIndex,
|
||||
);
|
||||
|
||||
if (isInitialLoad) {
|
||||
_warehouseLocations = pageLocations;
|
||||
} else {
|
||||
_warehouseLocations.addAll(pageLocations);
|
||||
}
|
||||
|
||||
_hasMore = endIndex < filtered.length;
|
||||
} else {
|
||||
_hasMore = false;
|
||||
}
|
||||
|
||||
_total = filtered.length;
|
||||
}
|
||||
|
||||
_applySearchFilter();
|
||||
|
||||
if (!isInitialLoad) {
|
||||
_currentPage++;
|
||||
}
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 다음 페이지 로드
|
||||
Future<void> loadNextPage() async {
|
||||
if (!_hasMore || _isLoading) return;
|
||||
_currentPage++;
|
||||
await loadWarehouseLocations(isInitialLoad: false);
|
||||
}
|
||||
|
||||
// 검색
|
||||
void search(String query) {
|
||||
_searchQuery = query;
|
||||
_applySearchFilter();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 검색 필터 적용
|
||||
void _applySearchFilter() {
|
||||
if (_searchQuery.isEmpty) {
|
||||
_filteredLocations = List.from(_warehouseLocations);
|
||||
} else {
|
||||
_filteredLocations = _warehouseLocations.where((location) {
|
||||
return location.name.toLowerCase().contains(_searchQuery.toLowerCase()) ||
|
||||
location.address.toString().toLowerCase().contains(_searchQuery.toLowerCase());
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
// 필터 설정
|
||||
void setFilters({bool? isActive}) {
|
||||
_isActive = isActive;
|
||||
loadWarehouseLocations();
|
||||
}
|
||||
|
||||
// 필터 초기화
|
||||
void clearFilters() {
|
||||
_isActive = null;
|
||||
_searchQuery = '';
|
||||
loadWarehouseLocations();
|
||||
}
|
||||
|
||||
/// 입고지 추가
|
||||
void addWarehouseLocation(WarehouseLocation location) {
|
||||
_dataService.addWarehouseLocation(location);
|
||||
loadWarehouseLocations();
|
||||
Future<void> addWarehouseLocation(WarehouseLocation location) async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
await _warehouseService.createWarehouseLocation(location);
|
||||
} else {
|
||||
mockDataService?.addWarehouseLocation(location);
|
||||
}
|
||||
|
||||
// 목록 새로고침
|
||||
await loadWarehouseLocations();
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 입고지 수정
|
||||
void updateWarehouseLocation(WarehouseLocation location) {
|
||||
_dataService.updateWarehouseLocation(location);
|
||||
loadWarehouseLocations();
|
||||
Future<void> updateWarehouseLocation(WarehouseLocation location) async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
await _warehouseService.updateWarehouseLocation(location);
|
||||
} else {
|
||||
mockDataService?.updateWarehouseLocation(location);
|
||||
}
|
||||
|
||||
// 목록에서 업데이트
|
||||
final index = _warehouseLocations.indexWhere((l) => l.id == location.id);
|
||||
if (index != -1) {
|
||||
_warehouseLocations[index] = location;
|
||||
_applySearchFilter();
|
||||
notifyListeners();
|
||||
}
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 입고지 삭제
|
||||
void deleteWarehouseLocation(int id) {
|
||||
_dataService.deleteWarehouseLocation(id);
|
||||
loadWarehouseLocations();
|
||||
Future<void> deleteWarehouseLocation(int id) async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
await _warehouseService.deleteWarehouseLocation(id);
|
||||
} else {
|
||||
mockDataService?.deleteWarehouseLocation(id);
|
||||
}
|
||||
|
||||
// 목록에서 제거
|
||||
_warehouseLocations.removeWhere((l) => l.id == id);
|
||||
_applySearchFilter();
|
||||
_total--;
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 새로고침
|
||||
Future<void> refresh() async {
|
||||
await loadWarehouseLocations();
|
||||
}
|
||||
|
||||
// 사용 중인 창고 위치 조회
|
||||
Future<List<WarehouseLocation>> getInUseWarehouseLocations() async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
return await _warehouseService.getInUseWarehouseLocations();
|
||||
} else {
|
||||
// Mock 데이터에서는 모든 창고가 사용 중으로 간주
|
||||
return mockDataService?.getAllWarehouseLocations() ?? [];
|
||||
}
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
notifyListeners();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
224
lib/services/license_service.dart
Normal file
224
lib/services/license_service.dart
Normal file
@@ -0,0 +1,224 @@
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:superport/core/errors/exceptions.dart';
|
||||
import 'package:superport/core/errors/failures.dart';
|
||||
import 'package:superport/data/datasources/remote/license_remote_datasource.dart';
|
||||
import 'package:superport/data/models/license/license_dto.dart';
|
||||
import 'package:superport/data/models/license/license_request_dto.dart';
|
||||
import 'package:superport/models/license_model.dart';
|
||||
|
||||
@lazySingleton
|
||||
class LicenseService {
|
||||
final LicenseRemoteDataSource _remoteDataSource = GetIt.instance<LicenseRemoteDataSource>();
|
||||
|
||||
// 라이선스 목록 조회
|
||||
Future<List<License>> getLicenses({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
bool? isActive,
|
||||
int? companyId,
|
||||
int? assignedUserId,
|
||||
String? licenseType,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _remoteDataSource.getLicenses(
|
||||
page: page,
|
||||
perPage: perPage,
|
||||
isActive: isActive,
|
||||
companyId: companyId,
|
||||
assignedUserId: assignedUserId,
|
||||
licenseType: licenseType,
|
||||
);
|
||||
|
||||
return response.items.map((dto) => _convertDtoToLicense(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 목록을 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 라이선스 상세 조회
|
||||
Future<License> getLicenseById(int id) async {
|
||||
try {
|
||||
final dto = await _remoteDataSource.getLicenseById(id);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 정보를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 라이선스 생성
|
||||
Future<License> createLicense(License license) async {
|
||||
try {
|
||||
// Flutter 모델의 visitCycle과 durationMonths를 API 필드에 매핑
|
||||
// visitCycle은 remark에 저장하고, durationMonths는 날짜 계산에 사용
|
||||
final now = DateTime.now();
|
||||
final expiryDate = now.add(Duration(days: license.durationMonths * 30));
|
||||
|
||||
final request = CreateLicenseRequest(
|
||||
licenseKey: license.name, // name을 licenseKey로 매핑
|
||||
productName: '유지보수 계약', // 기본값 설정
|
||||
licenseType: 'maintenance', // 유지보수 타입으로 고정
|
||||
companyId: license.companyId,
|
||||
purchaseDate: now,
|
||||
expiryDate: expiryDate,
|
||||
remark: '방문주기: ${license.visitCycle}', // visitCycle을 remark에 저장
|
||||
);
|
||||
|
||||
final dto = await _remoteDataSource.createLicense(request);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 생성에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 라이선스 수정
|
||||
Future<License> updateLicense(License license) async {
|
||||
try {
|
||||
if (license.id == null) {
|
||||
throw Failure(message: '라이선스 ID가 없습니다');
|
||||
}
|
||||
|
||||
// 기존 라이선스 정보를 먼저 조회
|
||||
final existingDto = await _remoteDataSource.getLicenseById(license.id!);
|
||||
|
||||
// 만료일 계산 (durationMonths가 변경된 경우)
|
||||
DateTime? newExpiryDate;
|
||||
if (existingDto.purchaseDate != null) {
|
||||
newExpiryDate = existingDto.purchaseDate!.add(Duration(days: license.durationMonths * 30));
|
||||
}
|
||||
|
||||
final request = UpdateLicenseRequest(
|
||||
licenseKey: license.name,
|
||||
expiryDate: newExpiryDate,
|
||||
remark: '방문주기: ${license.visitCycle}',
|
||||
);
|
||||
|
||||
final dto = await _remoteDataSource.updateLicense(license.id!, request);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 수정에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 라이선스 삭제
|
||||
Future<void> deleteLicense(int id) async {
|
||||
try {
|
||||
await _remoteDataSource.deleteLicense(id);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 삭제에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 라이선스 할당
|
||||
Future<License> assignLicense(int licenseId, int userId) async {
|
||||
try {
|
||||
final request = AssignLicenseRequest(userId: userId);
|
||||
final dto = await _remoteDataSource.assignLicense(licenseId, request);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 할당에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 라이선스 할당 해제
|
||||
Future<License> unassignLicense(int licenseId) async {
|
||||
try {
|
||||
final dto = await _remoteDataSource.unassignLicense(licenseId);
|
||||
return _convertDtoToLicense(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '라이선스 할당 해제에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 만료 예정 라이선스 조회
|
||||
Future<List<License>> getExpiringLicenses({
|
||||
int days = 30,
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _remoteDataSource.getExpiringLicenses(
|
||||
days: days,
|
||||
page: page,
|
||||
perPage: perPage,
|
||||
);
|
||||
|
||||
return response.items.map((dto) => _convertExpiringDtoToLicense(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '만료 예정 라이선스를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// DTO를 Flutter 모델로 변환
|
||||
License _convertDtoToLicense(LicenseDto dto) {
|
||||
// remark에서 방문주기 추출
|
||||
String visitCycle = '미방문'; // 기본값
|
||||
if (dto.remark != null && dto.remark!.contains('방문주기:')) {
|
||||
visitCycle = dto.remark!.split('방문주기:').last.trim();
|
||||
}
|
||||
|
||||
// 기간 계산 (purchaseDate와 expiryDate 차이)
|
||||
int durationMonths = 12; // 기본값
|
||||
if (dto.purchaseDate != null && dto.expiryDate != null) {
|
||||
final difference = dto.expiryDate!.difference(dto.purchaseDate!);
|
||||
durationMonths = (difference.inDays / 30).round();
|
||||
}
|
||||
|
||||
return License(
|
||||
id: dto.id,
|
||||
companyId: dto.companyId ?? 0,
|
||||
name: dto.licenseKey,
|
||||
durationMonths: durationMonths,
|
||||
visitCycle: visitCycle,
|
||||
);
|
||||
}
|
||||
|
||||
// 만료 예정 DTO를 Flutter 모델로 변환
|
||||
License _convertExpiringDtoToLicense(ExpiringLicenseDto dto) {
|
||||
return License(
|
||||
id: dto.id,
|
||||
companyId: 0, // ExpiringLicenseDto에는 companyId가 없으므로 기본값 사용
|
||||
name: dto.licenseKey,
|
||||
durationMonths: 12, // 기본값
|
||||
visitCycle: '미방문', // 기본값
|
||||
);
|
||||
}
|
||||
|
||||
// 페이지네이션 정보
|
||||
Future<int> getTotalLicenses({
|
||||
bool? isActive,
|
||||
int? companyId,
|
||||
int? assignedUserId,
|
||||
String? licenseType,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _remoteDataSource.getLicenses(
|
||||
page: 1,
|
||||
perPage: 1,
|
||||
isActive: isActive,
|
||||
companyId: companyId,
|
||||
assignedUserId: assignedUserId,
|
||||
licenseType: licenseType,
|
||||
);
|
||||
return response.total;
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
191
lib/services/warehouse_service.dart
Normal file
191
lib/services/warehouse_service.dart
Normal file
@@ -0,0 +1,191 @@
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:superport/core/errors/exceptions.dart';
|
||||
import 'package:superport/core/errors/failures.dart';
|
||||
import 'package:superport/data/datasources/remote/warehouse_remote_datasource.dart';
|
||||
import 'package:superport/data/models/warehouse/warehouse_dto.dart';
|
||||
import 'package:superport/models/address_model.dart';
|
||||
import 'package:superport/models/warehouse_location_model.dart';
|
||||
|
||||
@lazySingleton
|
||||
class WarehouseService {
|
||||
final WarehouseRemoteDataSource _remoteDataSource = GetIt.instance<WarehouseRemoteDataSource>();
|
||||
|
||||
// 창고 위치 목록 조회
|
||||
Future<List<WarehouseLocation>> getWarehouseLocations({
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
bool? isActive,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _remoteDataSource.getWarehouseLocations(
|
||||
page: page,
|
||||
perPage: perPage,
|
||||
isActive: isActive,
|
||||
);
|
||||
|
||||
return response.items.map((dto) => _convertDtoToWarehouseLocation(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 목록을 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 창고 위치 상세 조회
|
||||
Future<WarehouseLocation> getWarehouseLocationById(int id) async {
|
||||
try {
|
||||
final dto = await _remoteDataSource.getWarehouseLocationById(id);
|
||||
return _convertDtoToWarehouseLocation(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 정보를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 창고 위치 생성
|
||||
Future<WarehouseLocation> createWarehouseLocation(WarehouseLocation location) async {
|
||||
try {
|
||||
final request = CreateWarehouseLocationRequest(
|
||||
name: location.name,
|
||||
address: location.address.detailAddress,
|
||||
city: location.address.region,
|
||||
postalCode: location.address.zipCode,
|
||||
country: 'KR', // 기본값
|
||||
);
|
||||
|
||||
final dto = await _remoteDataSource.createWarehouseLocation(request);
|
||||
return _convertDtoToWarehouseLocation(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 생성에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 창고 위치 수정
|
||||
Future<WarehouseLocation> updateWarehouseLocation(WarehouseLocation location) async {
|
||||
try {
|
||||
final request = UpdateWarehouseLocationRequest(
|
||||
name: location.name,
|
||||
address: location.address.detailAddress,
|
||||
city: location.address.region,
|
||||
postalCode: location.address.zipCode,
|
||||
);
|
||||
|
||||
final dto = await _remoteDataSource.updateWarehouseLocation(location.id, request);
|
||||
return _convertDtoToWarehouseLocation(dto);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 수정에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 창고 위치 삭제
|
||||
Future<void> deleteWarehouseLocation(int id) async {
|
||||
try {
|
||||
await _remoteDataSource.deleteWarehouseLocation(id);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 위치 삭제에 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 창고별 장비 목록 조회
|
||||
Future<List<Map<String, dynamic>>> getWarehouseEquipment(
|
||||
int warehouseId, {
|
||||
int page = 1,
|
||||
int perPage = 20,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _remoteDataSource.getWarehouseEquipment(
|
||||
warehouseId,
|
||||
page: page,
|
||||
perPage: perPage,
|
||||
);
|
||||
|
||||
return response.items.map((dto) => {
|
||||
'id': dto.id,
|
||||
'equipmentNumber': dto.equipmentNumber,
|
||||
'manufacturer': dto.manufacturer,
|
||||
'equipmentName': dto.equipmentName,
|
||||
'serialNumber': dto.serialNumber,
|
||||
'quantity': dto.quantity,
|
||||
'status': dto.status,
|
||||
'storedAt': dto.storedAt,
|
||||
}).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 장비 목록을 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 창고 용량 정보 조회
|
||||
Future<WarehouseCapacityInfo> getWarehouseCapacity(int id) async {
|
||||
try {
|
||||
return await _remoteDataSource.getWarehouseCapacity(id);
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '창고 용량 정보를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 사용 중인 창고 위치 목록 조회
|
||||
Future<List<WarehouseLocation>> getInUseWarehouseLocations() async {
|
||||
try {
|
||||
final dtos = await _remoteDataSource.getInUseWarehouseLocations();
|
||||
return dtos.map((dto) => _convertDtoToWarehouseLocation(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
throw Failure(message: e.message);
|
||||
} catch (e) {
|
||||
throw Failure(message: '사용 중인 창고 위치를 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// DTO를 Flutter 모델로 변환
|
||||
WarehouseLocation _convertDtoToWarehouseLocation(WarehouseLocationDto dto) {
|
||||
// 주소 조합
|
||||
final addressParts = <String>[];
|
||||
if (dto.address != null && dto.address!.isNotEmpty) {
|
||||
addressParts.add(dto.address!);
|
||||
}
|
||||
if (dto.city != null && dto.city!.isNotEmpty) {
|
||||
addressParts.add(dto.city!);
|
||||
}
|
||||
if (dto.state != null && dto.state!.isNotEmpty) {
|
||||
addressParts.add(dto.state!);
|
||||
}
|
||||
|
||||
final address = Address(
|
||||
zipCode: dto.postalCode ?? '',
|
||||
region: dto.city ?? '',
|
||||
detailAddress: addressParts.join(' '),
|
||||
);
|
||||
|
||||
return WarehouseLocation(
|
||||
id: dto.id,
|
||||
name: dto.name,
|
||||
address: address,
|
||||
remark: dto.managerName != null ? '담당자: ${dto.managerName}' : null,
|
||||
);
|
||||
}
|
||||
|
||||
// 페이지네이션 정보
|
||||
Future<int> getTotalWarehouseLocations({bool? isActive}) async {
|
||||
try {
|
||||
final response = await _remoteDataSource.getWarehouseLocations(
|
||||
page: 1,
|
||||
perPage: 1,
|
||||
isActive: isActive,
|
||||
);
|
||||
return response.total;
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user