주석화 진행상황 정리하고 핵심 모듈에 한글 주석 추가
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>>(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/// 창고(Warehouse) 도메인 엔티티.
|
||||
class Warehouse {
|
||||
Warehouse({
|
||||
this.id,
|
||||
@@ -23,6 +24,7 @@ class Warehouse {
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
/// 일부 속성만 변경한 새 인스턴스를 반환한다.
|
||||
Warehouse copyWith({
|
||||
int? id,
|
||||
String? warehouseCode,
|
||||
@@ -50,6 +52,7 @@ class Warehouse {
|
||||
}
|
||||
}
|
||||
|
||||
/// 창고 주소에 대한 우편번호/행정 정보.
|
||||
class WarehouseZipcode {
|
||||
WarehouseZipcode({
|
||||
required this.zipcode,
|
||||
@@ -64,6 +67,7 @@ class WarehouseZipcode {
|
||||
final String? roadName;
|
||||
}
|
||||
|
||||
/// 창고 생성/수정에 사용하는 입력 모델.
|
||||
class WarehouseInput {
|
||||
WarehouseInput({
|
||||
required this.warehouseCode,
|
||||
@@ -81,6 +85,7 @@ class WarehouseInput {
|
||||
final bool isActive;
|
||||
final String? note;
|
||||
|
||||
/// API 요청 바디로 직렬화한다.
|
||||
Map<String, dynamic> toPayload() {
|
||||
return {
|
||||
'warehouse_code': warehouseCode,
|
||||
|
||||
@@ -2,7 +2,9 @@ import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
|
||||
import '../entities/warehouse.dart';
|
||||
|
||||
/// 창고 데이터를 다루는 도메인 저장소 인터페이스.
|
||||
abstract class WarehouseRepository {
|
||||
/// 창고 목록을 조회한다.
|
||||
Future<PaginatedResult<Warehouse>> list({
|
||||
int page = 1,
|
||||
int pageSize = 20,
|
||||
@@ -10,11 +12,15 @@ abstract class WarehouseRepository {
|
||||
bool? isActive,
|
||||
});
|
||||
|
||||
/// 창고를 생성한다.
|
||||
Future<Warehouse> create(WarehouseInput input);
|
||||
|
||||
/// 창고 정보를 수정한다.
|
||||
Future<Warehouse> update(int id, WarehouseInput input);
|
||||
|
||||
/// 창고를 삭제한다.
|
||||
Future<void> delete(int id);
|
||||
|
||||
/// 삭제된 창고를 복구한다.
|
||||
Future<Warehouse> restore(int id);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import '../../domain/entities/warehouse.dart';
|
||||
import '../../domain/repositories/warehouse_repository.dart';
|
||||
|
||||
/// 창고 사용 여부 필터.
|
||||
enum WarehouseStatusFilter { all, activeOnly, inactiveOnly }
|
||||
|
||||
/// 창고 마스터 화면 상태를 관리하는 컨트롤러.
|
||||
class WarehouseController extends ChangeNotifier {
|
||||
static const int defaultPageSize = 20;
|
||||
|
||||
@@ -30,6 +32,7 @@ class WarehouseController extends ChangeNotifier {
|
||||
int get pageSize => _pageSize;
|
||||
String? get errorMessage => _errorMessage;
|
||||
|
||||
/// 창고 목록을 조회한다.
|
||||
Future<void> fetch({int page = 1}) async {
|
||||
_isLoading = true;
|
||||
_errorMessage = null;
|
||||
@@ -58,6 +61,7 @@ class WarehouseController extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 검색어를 변경한다.
|
||||
void updateQuery(String value) {
|
||||
if (_query == value) {
|
||||
return;
|
||||
@@ -66,6 +70,7 @@ class WarehouseController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 사용 여부 필터를 변경한다.
|
||||
void updateStatusFilter(WarehouseStatusFilter filter) {
|
||||
if (_statusFilter == filter) {
|
||||
return;
|
||||
@@ -74,6 +79,7 @@ class WarehouseController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 페이지 크기를 변경한다.
|
||||
void updatePageSize(int size) {
|
||||
if (size <= 0 || _pageSize == size) {
|
||||
return;
|
||||
@@ -82,6 +88,7 @@ class WarehouseController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 창고를 생성한다.
|
||||
Future<Warehouse?> create(WarehouseInput input) async {
|
||||
_setSubmitting(true);
|
||||
try {
|
||||
@@ -97,6 +104,7 @@ class WarehouseController extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 창고 정보를 수정한다.
|
||||
Future<Warehouse?> update(int id, WarehouseInput input) async {
|
||||
_setSubmitting(true);
|
||||
try {
|
||||
@@ -112,6 +120,7 @@ class WarehouseController extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 창고를 삭제한다.
|
||||
Future<bool> delete(int id) async {
|
||||
_setSubmitting(true);
|
||||
try {
|
||||
@@ -127,6 +136,7 @@ class WarehouseController extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 삭제된 창고를 복구한다.
|
||||
Future<Warehouse?> restore(int id) async {
|
||||
_setSubmitting(true);
|
||||
try {
|
||||
@@ -142,11 +152,13 @@ class WarehouseController extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 에러 메시지를 초기화한다.
|
||||
void clearError() {
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 제출 상태 플래그를 갱신하고 리스너에 알린다.
|
||||
void _setSubmitting(bool value) {
|
||||
_isSubmitting = value;
|
||||
notifyListeners();
|
||||
|
||||
@@ -17,6 +17,7 @@ import '../../domain/entities/warehouse.dart';
|
||||
import '../../domain/repositories/warehouse_repository.dart';
|
||||
import '../controllers/warehouse_controller.dart';
|
||||
|
||||
/// 창고 관리 페이지. 기능 플래그에 따라 사양/실제 화면을 전환한다.
|
||||
class WarehousePage extends StatelessWidget {
|
||||
const WarehousePage({super.key, required this.routeUri});
|
||||
|
||||
@@ -81,6 +82,7 @@ class WarehousePage extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 창고 기능이 활성화된 경우 사용하는 실제 화면 위젯.
|
||||
class _WarehouseEnabledPage extends StatefulWidget {
|
||||
const _WarehouseEnabledPage({required this.routeUri});
|
||||
|
||||
@@ -90,6 +92,7 @@ class _WarehouseEnabledPage extends StatefulWidget {
|
||||
State<_WarehouseEnabledPage> createState() => _WarehouseEnabledPageState();
|
||||
}
|
||||
|
||||
/// 창고 목록과 필터 상태를 관리하는 상태 클래스.
|
||||
class _WarehouseEnabledPageState extends State<_WarehouseEnabledPage> {
|
||||
late final WarehouseController _controller;
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
|
||||
Reference in New Issue
Block a user