class User { final int? id; final int companyId; final int? branchId; // 지점 ID final String name; final String role; // 관리등급: S(관리자), M(멤버) final String? position; // 직급 final String? email; // 이메일 final List> phoneNumbers; // 전화번호 목록 (유형과 번호) final String? username; // 사용자명 (API 연동용) final bool isActive; // 활성화 상태 final DateTime? createdAt; // 생성일 final DateTime? updatedAt; // 수정일 User({ this.id, required this.companyId, this.branchId, required this.name, required this.role, this.position, this.email, this.phoneNumbers = const [], this.username, this.isActive = true, this.createdAt, this.updatedAt, }); Map toJson() { return { 'id': id, 'companyId': companyId, 'branchId': branchId, 'name': name, 'role': role, 'position': position, 'email': email, 'phoneNumbers': phoneNumbers, 'username': username, 'isActive': isActive, 'createdAt': createdAt?.toIso8601String(), 'updatedAt': updatedAt?.toIso8601String(), }; } factory User.fromJson(Map json) { return User( id: json['id'], companyId: json['companyId'], branchId: json['branchId'], name: json['name'], role: json['role'], position: json['position'], email: json['email'], phoneNumbers: json['phoneNumbers'] != null ? List>.from(json['phoneNumbers']) : [], username: json['username'], isActive: json['isActive'] ?? true, createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null, updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt']) : null, ); } User copyWith({ int? id, int? companyId, int? branchId, String? name, String? role, String? position, String? email, List>? phoneNumbers, String? username, bool? isActive, DateTime? createdAt, DateTime? updatedAt, }) { return User( id: id ?? this.id, companyId: companyId ?? this.companyId, branchId: branchId ?? this.branchId, name: name ?? this.name, role: role ?? this.role, position: position ?? this.position, email: email ?? this.email, phoneNumbers: phoneNumbers ?? this.phoneNumbers, username: username ?? this.username, isActive: isActive ?? this.isActive, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, ); } }