class AppUser { final int id; final String username; final String? realName; final String? phone; final String role; // superadmin | admin | operator | readonly final bool isActive; final String? createdAt; final String? lastLoginAt; const AppUser({ required this.id, required this.username, this.realName, this.phone, required this.role, required this.isActive, this.createdAt, this.lastLoginAt, }); String get roleLabel { switch (role) { case 'superadmin': return '超级管理员'; case 'admin': return '管理员'; case 'operator': return '操作员'; case 'readonly': return '只读'; default: return role; } } factory AppUser.fromJson(Map 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?, lastLoginAt: json['last_login_at'] as String?, ); }