feat(user): 사용자 자기정보 편집과 관리자 재설정 플로우를 연동
- lib/widgets/app_shell.dart에서 내 정보 다이얼로그를 추가하고 UserRepository.updateMe·비밀번호 변경 로직을 연결 - lib/features/masters/user/* 모듈에 phone·forcePasswordChange·passwordUpdatedAt 필드를 반영하고 reset-password/update-me API를 사용 - lib/core/validation/password_rules.dart을 신설해 비밀번호 정책 검증을 공통화하고 신규 위젯·테스트에서 재사용 - doc/stock_approval_system_api_v4.md 등 문서를 users 스펙 개편 내용으로 갱신하고 user_management_plan.md를 추가 - test/widgets/app_shell_test.dart 등에서 자기정보 수정·비밀번호 재설정 시나리오를 검증하고 기존 테스트를 보강
This commit is contained in:
@@ -15,6 +15,8 @@ class UserDto {
|
||||
this.isActive = true,
|
||||
this.isDeleted = false,
|
||||
this.note,
|
||||
this.forcePasswordChange = false,
|
||||
this.passwordUpdatedAt,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
@@ -28,6 +30,8 @@ class UserDto {
|
||||
final bool isActive;
|
||||
final bool isDeleted;
|
||||
final String? note;
|
||||
final bool forcePasswordChange;
|
||||
final DateTime? passwordUpdatedAt;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
@@ -35,16 +39,22 @@ class UserDto {
|
||||
factory UserDto.fromJson(Map<String, dynamic> json) {
|
||||
return UserDto(
|
||||
id: json['id'] as int?,
|
||||
employeeNo: json['employee_no'] as String,
|
||||
employeeName: json['employee_name'] as String,
|
||||
employeeNo:
|
||||
json['employee_id'] as String? ??
|
||||
json['employee_no'] as String? ??
|
||||
'-',
|
||||
employeeName:
|
||||
json['name'] as String? ?? json['employee_name'] as String? ?? '-',
|
||||
email: json['email'] as String?,
|
||||
mobileNo: json['mobile_no'] as String?,
|
||||
mobileNo: json['phone'] as String? ?? json['mobile_no'] as String?,
|
||||
group: json['group'] is Map<String, dynamic>
|
||||
? UserGroupDto.fromJson(json['group'] as Map<String, dynamic>)
|
||||
: null,
|
||||
isActive: (json['is_active'] as bool?) ?? true,
|
||||
isDeleted: (json['is_deleted'] as bool?) ?? false,
|
||||
note: json['note'] as String?,
|
||||
forcePasswordChange: (json['force_password_change'] as bool?) ?? false,
|
||||
passwordUpdatedAt: _parseDate(json['password_updated_at']),
|
||||
createdAt: _parseDate(json['created_at']),
|
||||
updatedAt: _parseDate(json['updated_at']),
|
||||
);
|
||||
@@ -61,6 +71,8 @@ class UserDto {
|
||||
isActive: isActive,
|
||||
isDeleted: isDeleted,
|
||||
note: note,
|
||||
forcePasswordChange: forcePasswordChange,
|
||||
passwordUpdatedAt: passwordUpdatedAt,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ class UserRepositoryRemote implements UserRepository {
|
||||
|
||||
final ApiClient _api;
|
||||
|
||||
static const _basePath = '${ApiRoutes.apiV1}/employees';
|
||||
static const _basePath = '${ApiRoutes.apiV1}/users';
|
||||
|
||||
/// 사용자 목록을 조회한다.
|
||||
@override
|
||||
@@ -31,7 +31,7 @@ class UserRepositoryRemote implements UserRepository {
|
||||
'page_size': pageSize,
|
||||
if (query != null && query.isNotEmpty) 'q': query,
|
||||
if (groupId != null) 'group_id': groupId,
|
||||
if (isActive != null) 'active': isActive,
|
||||
if (isActive != null) 'is_active': isActive,
|
||||
'include': 'group',
|
||||
},
|
||||
options: Options(responseType: ResponseType.json),
|
||||
@@ -62,6 +62,27 @@ class UserRepositoryRemote implements UserRepository {
|
||||
return UserDto.fromJson(_api.unwrapAsMap(response)).toEntity();
|
||||
}
|
||||
|
||||
/// 로그인한 사용자의 정보를 수정한다.
|
||||
@override
|
||||
Future<UserAccount> updateMe(UserProfileUpdateInput input) async {
|
||||
final response = await _api.patch<Map<String, dynamic>>(
|
||||
'$_basePath/me',
|
||||
data: input.toPayload(),
|
||||
options: Options(responseType: ResponseType.json),
|
||||
);
|
||||
return UserDto.fromJson(_api.unwrapAsMap(response)).toEntity();
|
||||
}
|
||||
|
||||
/// 관리자가 특정 사용자의 비밀번호를 재설정한다.
|
||||
@override
|
||||
Future<UserAccount> resetPassword(int id) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
'$_basePath/$id/reset-password',
|
||||
options: Options(responseType: ResponseType.json),
|
||||
);
|
||||
return UserDto.fromJson(_api.unwrapAsMap(response)).toEntity();
|
||||
}
|
||||
|
||||
/// 사용자를 삭제한다.
|
||||
@override
|
||||
Future<void> delete(int id) async {
|
||||
|
||||
Reference in New Issue
Block a user