Files
water-management-system/mobile-app/lib/features/auth/models/user_model.dart
T

45 lines
924 B
Dart
Raw Normal View History

/// 用户模型
class UserModel {
final String id;
final String username;
final String name;
final String? avatar;
final String role;
final String? department;
final String? phone;
UserModel({
required this.id,
required this.username,
required this.name,
this.avatar,
required this.role,
this.department,
this.phone,
});
factory UserModel.fromJson(Map<String, dynamic> json) {
return UserModel(
id: json['id']?.toString() ?? '',
username: json['username'] ?? '',
name: json['name'] ?? '',
avatar: json['avatar'],
role: json['role'] ?? '',
department: json['department'],
phone: json['phone'],
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'username': username,
'name': name,
'avatar': avatar,
'role': role,
'department': department,
'phone': phone,
};
}
}