주석화 진행상황 정리하고 핵심 모듈에 한글 주석 추가
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:superport_v2/core/common/utils/json_utils.dart';
|
||||
|
||||
import '../../domain/entities/menu.dart';
|
||||
|
||||
/// 메뉴(Menu) API 응답을 표현하는 DTO.
|
||||
class MenuDto {
|
||||
MenuDto({
|
||||
this.id,
|
||||
@@ -30,6 +31,7 @@ class MenuDto {
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
/// JSON에서 메뉴 정보를 파싱한다.
|
||||
factory MenuDto.fromJson(Map<String, dynamic> json) {
|
||||
return MenuDto(
|
||||
id: json['id'] as int?,
|
||||
@@ -50,6 +52,7 @@ class MenuDto {
|
||||
);
|
||||
}
|
||||
|
||||
/// DTO를 도메인 [MenuItem]으로 변환한다.
|
||||
MenuItem toEntity() => MenuItem(
|
||||
id: id,
|
||||
menuCode: menuCode,
|
||||
@@ -64,6 +67,7 @@ class MenuDto {
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
|
||||
/// 페이징 응답을 [PaginatedResult]로 변환한다.
|
||||
static PaginatedResult<MenuItem> parsePaginated(Map<String, dynamic>? json) {
|
||||
final rawItems = JsonUtils.extractList(json, keys: const ['items']);
|
||||
final items = rawItems
|
||||
@@ -79,12 +83,14 @@ class MenuDto {
|
||||
}
|
||||
}
|
||||
|
||||
/// 하위 메뉴 요약 정보를 담는 DTO.
|
||||
class MenuSummaryDto {
|
||||
MenuSummaryDto({required this.id, required this.menuName});
|
||||
|
||||
final int id;
|
||||
final String menuName;
|
||||
|
||||
/// JSON에서 요약 정보를 파싱한다.
|
||||
factory MenuSummaryDto.fromJson(Map<String, dynamic> json) {
|
||||
return MenuSummaryDto(
|
||||
id: json['id'] as int,
|
||||
@@ -92,9 +98,11 @@ class MenuSummaryDto {
|
||||
);
|
||||
}
|
||||
|
||||
/// DTO를 [MenuSummary] 엔티티로 변환한다.
|
||||
MenuSummary toEntity() => MenuSummary(id: id, menuName: menuName);
|
||||
}
|
||||
|
||||
/// 문자열/DateTime을 파싱해 [DateTime]으로 변환한다.
|
||||
DateTime? _parseDate(Object? value) {
|
||||
if (value == null) return null;
|
||||
if (value is DateTime) return value;
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../domain/entities/menu.dart';
|
||||
import '../../domain/repositories/menu_repository.dart';
|
||||
import '../dtos/menu_dto.dart';
|
||||
|
||||
/// 메뉴 마스터 API를 호출하는 원격 저장소.
|
||||
class MenuRepositoryRemote implements MenuRepository {
|
||||
MenuRepositoryRemote({required ApiClient apiClient}) : _api = apiClient;
|
||||
|
||||
@@ -13,6 +14,7 @@ class MenuRepositoryRemote implements MenuRepository {
|
||||
|
||||
static const _basePath = '/menus';
|
||||
|
||||
/// 메뉴 목록을 조회한다.
|
||||
@override
|
||||
Future<PaginatedResult<MenuItem>> list({
|
||||
int page = 1,
|
||||
@@ -38,6 +40,7 @@ class MenuRepositoryRemote implements MenuRepository {
|
||||
return MenuDto.parsePaginated(response.data ?? const {});
|
||||
}
|
||||
|
||||
/// 새 메뉴를 생성한다.
|
||||
@override
|
||||
Future<MenuItem> create(MenuInput input) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
@@ -49,6 +52,7 @@ class MenuRepositoryRemote implements MenuRepository {
|
||||
return MenuDto.fromJson(data).toEntity();
|
||||
}
|
||||
|
||||
/// 메뉴 정보를 수정한다.
|
||||
@override
|
||||
Future<MenuItem> update(int id, MenuInput input) async {
|
||||
final response = await _api.patch<Map<String, dynamic>>(
|
||||
@@ -60,11 +64,13 @@ class MenuRepositoryRemote implements MenuRepository {
|
||||
return MenuDto.fromJson(data).toEntity();
|
||||
}
|
||||
|
||||
/// 메뉴를 삭제한다.
|
||||
@override
|
||||
Future<void> delete(int id) async {
|
||||
await _api.delete<void>('$_basePath/$id');
|
||||
}
|
||||
|
||||
/// 삭제된 메뉴를 복구한다.
|
||||
@override
|
||||
Future<MenuItem> restore(int id) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
|
||||
Reference in New Issue
Block a user