fix: 修复数据库初始化

pull/7/head
梁浩 5 months ago
parent ae261a6dc9
commit e587b29b2f

@ -230,7 +230,7 @@ def get_system_stats():
'total': total_tasks,
'completed': completed_tasks,
'processing': processing_tasks,
'failed': failed_tasks
'failed': failed_tasks,
'waiting': waiting_tasks
},
'images': {

@ -15,9 +15,9 @@ def init_database():
# 初始化角色数据
roles = [
{'role_id': 0, 'role_code': 'admin', 'name': '管理员', 'max_concurrent_tasks': 15, 'description': '系统管理员,拥有最高权限'},
{'role_id': 1, 'role_code': 'vip', 'name': 'VIP用户', 'max_concurrent_tasks': 10, 'description': '付费用户,享有较高的资源使用权限'},
{'role_id': 2, 'role_code': 'normal', 'name': '普通用户', 'max_concurrent_tasks': 5, 'description': '免费用户,享有基本的资源使用权限'}
{'role_id': 1, 'role_code': 'admin', 'name': '管理员', 'max_concurrent_tasks': 15, 'description': '系统管理员,拥有最高权限'},
{'role_id': 2, 'role_code': 'vip', 'name': 'VIP用户', 'max_concurrent_tasks': 10, 'description': '付费用户,享有较高的资源使用权限'},
{'role_id': 3, 'role_code': 'normal', 'name': '普通用户', 'max_concurrent_tasks': 5, 'description': '免费用户,享有基本的资源使用权限'}
]
for role_data in roles:
existing = Role.query.filter_by(role_id=role_data['role_id']).first()
@ -108,9 +108,9 @@ def init_database():
# 创建默认测试用户(三种角色各一个)
test_users = [
{'username': 'admin_test', 'email': 'admin@test.com', 'password': 'admin123', 'role_id': 0},
{'username': 'vip_test', 'email': 'vip@test.com', 'password': 'vip123', 'role_id': 1},
{'username': 'normal_test', 'email': 'normal@test.com', 'password': 'normal123', 'role_id': 2}
{'username': 'admin_test', 'email': 'admin@test.com', 'password': 'admin123', 'role_id': 1},
{'username': 'vip_test', 'email': 'vip@test.com', 'password': 'vip123', 'role_id': 2},
{'username': 'normal_test', 'email': 'normal@test.com', 'password': 'normal123', 'role_id': 3}
]
for user_data in test_users:

Loading…
Cancel
Save