Files
superport_v2/lib/features/masters/user/domain/entities/user.dart
JiWoong Sul 14624c4165 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 등에서 자기정보 수정·비밀번호 재설정 시나리오를 검증하고 기존 테스트를 보강
2025-10-26 17:05:47 +09:00

140 lines
3.5 KiB
Dart

/// 사용자(User) 도메인 엔티티.
class UserAccount {
UserAccount({
this.id,
required this.employeeNo,
required this.employeeName,
this.email,
this.mobileNo,
this.group,
this.isActive = true,
this.isDeleted = false,
this.note,
this.forcePasswordChange = false,
this.passwordUpdatedAt,
this.createdAt,
this.updatedAt,
});
final int? id;
final String employeeNo;
final String employeeName;
final String? email;
final String? mobileNo;
final UserGroup? group;
final bool isActive;
final bool isDeleted;
final String? note;
final bool forcePasswordChange;
final DateTime? passwordUpdatedAt;
final DateTime? createdAt;
final DateTime? updatedAt;
/// 선택된 속성만 변경한 새 인스턴스를 반환한다.
UserAccount copyWith({
int? id,
String? employeeNo,
String? employeeName,
String? email,
String? mobileNo,
UserGroup? group,
bool? isActive,
bool? isDeleted,
String? note,
bool? forcePasswordChange,
DateTime? passwordUpdatedAt,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return UserAccount(
id: id ?? this.id,
employeeNo: employeeNo ?? this.employeeNo,
employeeName: employeeName ?? this.employeeName,
email: email ?? this.email,
mobileNo: mobileNo ?? this.mobileNo,
group: group ?? this.group,
isActive: isActive ?? this.isActive,
isDeleted: isDeleted ?? this.isDeleted,
note: note ?? this.note,
forcePasswordChange: forcePasswordChange ?? this.forcePasswordChange,
passwordUpdatedAt: passwordUpdatedAt ?? this.passwordUpdatedAt,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
);
}
}
/// 사용자에 연결된 그룹 정보.
class UserGroup {
UserGroup({required this.id, required this.groupName});
final int id;
final String groupName;
}
/// 사용자 생성/수정 입력 모델.
class UserInput {
UserInput({
required this.employeeNo,
required this.employeeName,
required this.groupId,
this.email,
this.mobileNo,
this.isActive = true,
this.forcePasswordChange,
this.password,
this.note,
});
final String employeeNo;
final String employeeName;
final int groupId;
final String? email;
final String? mobileNo;
final bool isActive;
final bool? forcePasswordChange;
final String? password;
final String? note;
/// API 요청 바디로 직렬화한다.
Map<String, dynamic> toPayload() {
return {
'employee_id': employeeNo,
'name': employeeName,
'group_id': groupId,
if (email != null) 'email': email,
if (mobileNo != null) 'phone': mobileNo,
'is_active': isActive,
if (forcePasswordChange != null)
'force_password_change': forcePasswordChange,
if (password != null) 'password': password,
if (note != null) 'note': note,
};
}
}
/// 자기 정보 수정 입력 모델.
class UserProfileUpdateInput {
const UserProfileUpdateInput({
this.email,
this.phone,
this.password,
this.currentPassword,
});
final String? email;
final String? phone;
final String? password;
final String? currentPassword;
/// 자기 정보 수정 요청 바디를 직렬화한다.
Map<String, dynamic> toPayload() {
return {
if (email != null) 'email': email,
if (phone != null) 'phone': phone,
if (password != null) 'password': password,
if (currentPassword != null) 'current_password': currentPassword,
};
}
}