주석화 진행상황 정리하고 핵심 모듈에 한글 주석 추가
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:superport_v2/core/common/utils/json_utils.dart';
|
||||
|
||||
import '../../domain/entities/warehouse.dart';
|
||||
|
||||
/// 창고(Warehouse) API 응답을 표현하는 DTO.
|
||||
class WarehouseDto {
|
||||
WarehouseDto({
|
||||
this.id,
|
||||
@@ -28,6 +29,7 @@ class WarehouseDto {
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
/// JSON에서 창고 정보를 파싱한다.
|
||||
factory WarehouseDto.fromJson(Map<String, dynamic> json) {
|
||||
return WarehouseDto(
|
||||
id: json['id'] as int?,
|
||||
@@ -47,6 +49,7 @@ class WarehouseDto {
|
||||
);
|
||||
}
|
||||
|
||||
/// DTO를 JSON 맵으로 직렬화한다.
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
@@ -62,6 +65,7 @@ class WarehouseDto {
|
||||
};
|
||||
}
|
||||
|
||||
/// DTO를 도메인 [Warehouse] 엔티티로 변환한다.
|
||||
Warehouse toEntity() => Warehouse(
|
||||
id: id,
|
||||
warehouseCode: warehouseCode,
|
||||
@@ -75,6 +79,7 @@ class WarehouseDto {
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
|
||||
/// 페이징 응답을 [PaginatedResult]로 변환한다.
|
||||
static PaginatedResult<Warehouse> parsePaginated(Map<String, dynamic>? json) {
|
||||
final rawItems = JsonUtils.extractList(json, keys: const ['items']);
|
||||
final items = rawItems
|
||||
@@ -90,6 +95,7 @@ class WarehouseDto {
|
||||
}
|
||||
}
|
||||
|
||||
/// 창고 주소에 대한 우편번호 정보를 담는 DTO.
|
||||
class WarehouseZipcodeDto {
|
||||
WarehouseZipcodeDto({
|
||||
required this.zipcode,
|
||||
@@ -103,6 +109,7 @@ class WarehouseZipcodeDto {
|
||||
final String? sigungu;
|
||||
final String? roadName;
|
||||
|
||||
/// JSON에서 우편번호 정보를 파싱한다.
|
||||
factory WarehouseZipcodeDto.fromJson(Map<String, dynamic> json) {
|
||||
return WarehouseZipcodeDto(
|
||||
zipcode: json['zipcode'] as String,
|
||||
@@ -112,6 +119,7 @@ class WarehouseZipcodeDto {
|
||||
);
|
||||
}
|
||||
|
||||
/// DTO를 JSON 맵으로 직렬화한다.
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'zipcode': zipcode,
|
||||
@@ -121,6 +129,7 @@ class WarehouseZipcodeDto {
|
||||
};
|
||||
}
|
||||
|
||||
/// DTO를 [WarehouseZipcode] 엔티티로 변환한다.
|
||||
WarehouseZipcode toEntity() => WarehouseZipcode(
|
||||
zipcode: zipcode,
|
||||
sido: sido,
|
||||
@@ -129,6 +138,7 @@ class WarehouseZipcodeDto {
|
||||
);
|
||||
}
|
||||
|
||||
/// 문자열/DateTime 값을 파싱해 [DateTime]으로 변환한다.
|
||||
DateTime? _parseDate(Object? value) {
|
||||
if (value == null) return null;
|
||||
if (value is DateTime) return value;
|
||||
@@ -136,6 +146,7 @@ DateTime? _parseDate(Object? value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// 창고 입력 모델을 API 요청 바디로 변환한다.
|
||||
Map<String, dynamic> warehouseInputToJson(WarehouseInput input) {
|
||||
final map = input.toPayload();
|
||||
map.removeWhere((key, value) => value == null);
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../domain/entities/warehouse.dart';
|
||||
import '../../domain/repositories/warehouse_repository.dart';
|
||||
import '../dtos/warehouse_dto.dart';
|
||||
|
||||
/// 창고(Warehouse) 마스터 API를 호출하는 원격 저장소.
|
||||
class WarehouseRepositoryRemote implements WarehouseRepository {
|
||||
WarehouseRepositoryRemote({required ApiClient apiClient}) : _api = apiClient;
|
||||
|
||||
@@ -13,6 +14,7 @@ class WarehouseRepositoryRemote implements WarehouseRepository {
|
||||
|
||||
static const _basePath = '/warehouses';
|
||||
|
||||
/// 창고 목록을 조회한다.
|
||||
@override
|
||||
Future<PaginatedResult<Warehouse>> list({
|
||||
int page = 1,
|
||||
@@ -33,6 +35,7 @@ class WarehouseRepositoryRemote implements WarehouseRepository {
|
||||
return WarehouseDto.parsePaginated(response.data ?? const {});
|
||||
}
|
||||
|
||||
/// 창고를 생성한다.
|
||||
@override
|
||||
Future<Warehouse> create(WarehouseInput input) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
@@ -44,6 +47,7 @@ class WarehouseRepositoryRemote implements WarehouseRepository {
|
||||
return WarehouseDto.fromJson(data).toEntity();
|
||||
}
|
||||
|
||||
/// 창고 정보를 수정한다.
|
||||
@override
|
||||
Future<Warehouse> update(int id, WarehouseInput input) async {
|
||||
final response = await _api.patch<Map<String, dynamic>>(
|
||||
@@ -55,11 +59,13 @@ class WarehouseRepositoryRemote implements WarehouseRepository {
|
||||
return WarehouseDto.fromJson(data).toEntity();
|
||||
}
|
||||
|
||||
/// 창고를 삭제한다.
|
||||
@override
|
||||
Future<void> delete(int id) async {
|
||||
await _api.delete<void>('$_basePath/$id');
|
||||
}
|
||||
|
||||
/// 삭제된 창고를 복구한다.
|
||||
@override
|
||||
Future<Warehouse> restore(int id) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
|
||||
Reference in New Issue
Block a user