주석화 진행상황 정리하고 핵심 모듈에 한글 주석 추가
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:superport_v2/core/common/utils/json_utils.dart';
|
||||
|
||||
import '../../domain/entities/user.dart';
|
||||
|
||||
/// 사용자(User) API 응답을 표현하는 DTO.
|
||||
class UserDto {
|
||||
UserDto({
|
||||
this.id,
|
||||
@@ -30,6 +31,7 @@ class UserDto {
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
/// JSON에서 사용자 정보를 파싱한다.
|
||||
factory UserDto.fromJson(Map<String, dynamic> json) {
|
||||
return UserDto(
|
||||
id: json['id'] as int?,
|
||||
@@ -48,6 +50,7 @@ class UserDto {
|
||||
);
|
||||
}
|
||||
|
||||
/// DTO를 도메인 [UserAccount] 엔티티로 변환한다.
|
||||
UserAccount toEntity() => UserAccount(
|
||||
id: id,
|
||||
employeeNo: employeeNo,
|
||||
@@ -62,6 +65,7 @@ class UserDto {
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
|
||||
/// 페이징 응답을 [PaginatedResult]로 변환한다.
|
||||
static PaginatedResult<UserAccount> parsePaginated(
|
||||
Map<String, dynamic>? json,
|
||||
) {
|
||||
@@ -79,12 +83,14 @@ class UserDto {
|
||||
}
|
||||
}
|
||||
|
||||
/// 사용자에 연결된 그룹 정보를 담는 DTO.
|
||||
class UserGroupDto {
|
||||
UserGroupDto({required this.id, required this.groupName});
|
||||
|
||||
final int id;
|
||||
final String groupName;
|
||||
|
||||
/// JSON에서 그룹 정보를 파싱한다.
|
||||
factory UserGroupDto.fromJson(Map<String, dynamic> json) {
|
||||
return UserGroupDto(
|
||||
id: json['id'] as int,
|
||||
@@ -92,9 +98,11 @@ class UserGroupDto {
|
||||
);
|
||||
}
|
||||
|
||||
/// DTO를 [UserGroup] 엔티티로 변환한다.
|
||||
UserGroup toEntity() => UserGroup(id: id, groupName: groupName);
|
||||
}
|
||||
|
||||
/// 문자열/DateTime을 파싱해 [DateTime]으로 변환한다.
|
||||
DateTime? _parseDate(Object? value) {
|
||||
if (value == null) return null;
|
||||
if (value is DateTime) return value;
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../domain/entities/user.dart';
|
||||
import '../../domain/repositories/user_repository.dart';
|
||||
import '../dtos/user_dto.dart';
|
||||
|
||||
/// 사용자 마스터 API를 호출하는 원격 저장소.
|
||||
class UserRepositoryRemote implements UserRepository {
|
||||
UserRepositoryRemote({required ApiClient apiClient}) : _api = apiClient;
|
||||
|
||||
@@ -13,6 +14,7 @@ class UserRepositoryRemote implements UserRepository {
|
||||
|
||||
static const _basePath = '/employees';
|
||||
|
||||
/// 사용자 목록을 조회한다.
|
||||
@override
|
||||
Future<PaginatedResult<UserAccount>> list({
|
||||
int page = 1,
|
||||
@@ -36,6 +38,7 @@ class UserRepositoryRemote implements UserRepository {
|
||||
return UserDto.parsePaginated(response.data ?? const {});
|
||||
}
|
||||
|
||||
/// 사용자를 생성한다.
|
||||
@override
|
||||
Future<UserAccount> create(UserInput input) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
@@ -47,6 +50,7 @@ class UserRepositoryRemote implements UserRepository {
|
||||
return UserDto.fromJson(data).toEntity();
|
||||
}
|
||||
|
||||
/// 사용자 정보를 수정한다.
|
||||
@override
|
||||
Future<UserAccount> update(int id, UserInput input) async {
|
||||
final response = await _api.patch<Map<String, dynamic>>(
|
||||
@@ -58,11 +62,13 @@ class UserRepositoryRemote implements UserRepository {
|
||||
return UserDto.fromJson(data).toEntity();
|
||||
}
|
||||
|
||||
/// 사용자를 삭제한다.
|
||||
@override
|
||||
Future<void> delete(int id) async {
|
||||
await _api.delete<void>('$_basePath/$id');
|
||||
}
|
||||
|
||||
/// 삭제된 사용자를 복구한다.
|
||||
@override
|
||||
Future<UserAccount> restore(int id) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
|
||||
Reference in New Issue
Block a user