Files
jiu/client/lib/models/user.dart
T
wangjia 86738c903e feat: 新增 superadmin 角色和数据清空功能
后端:
- User.Role enum 增加 superadmin,启动时 ALTER TABLE 兼容已有 DB
- 新增 SuperAdminOnly() 中间件
- 新增 POST /api/v1/admin/clear-data 接口(按表名白名单删除,多租户隔离)

前端:
- AppUser/AuthUser 支持 role 字段持久化与传递
- 数据导入 Tab 末尾增加「危险操作 — 数据清空」区块(仅 superadmin 可见)
- 支持多选:入库单/出库单/库存管理/商品详情/往来单位
- 红色警告框 + 二次确认弹窗(需手动输入"确认清空")

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 01:07:56 +08:00

45 lines
1.1 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 'superadmin':
return '超级管理员';
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?,
);
}