Files
jiu/client/lib/models/user.dart
T
wangjia a44b536c39 feat: 用户管理对接真实 API
后端: 新增 /api/v1/users CRUD + 重置密码接口
前端: user model/repository/provider + 设置页用户 tab 改为真实数据,
      支持新增、编辑、启停、重置密码

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 08:45:37 +08:00

43 lines
1.0 KiB
Dart

class AppUser {
final int id;
final String username;
final String? realName;
final String? phone;
final String role; // admin | operator | readonly
final bool isActive;
final String? createdAt;
const AppUser({
required this.id,
required this.username,
this.realName,
this.phone,
required this.role,
required this.isActive,
this.createdAt,
});
String get roleLabel {
switch (role) {
case 'admin':
return '管理员';
case 'operator':
return '操作员';
case 'readonly':
return '只读';
default:
return role;
}
}
factory AppUser.fromJson(Map<String, dynamic> json) => AppUser(
id: (json['id'] as num).toInt(),
username: json['username'] as String,
realName: json['real_name'] as String?,
phone: json['phone'] as String?,
role: json['role'] as String? ?? 'operator',
isActive: json['is_active'] as bool? ?? true,
createdAt: json['created_at'] as String?,
);
}