forked from xiaohei/taiji-AI-PAD
173 lines
4.9 KiB
Python
173 lines
4.9 KiB
Python
"""
|
|
简化的账号检查脚本 - 不需要数据库连接
|
|
仅用于验证账号配置是否正确
|
|
"""
|
|
|
|
# 测试账号配置
|
|
test_accounts = [
|
|
{
|
|
"name": "超级管理员",
|
|
"email": "superadmin@test.com",
|
|
"password": "super123",
|
|
"role": "super_admin",
|
|
"balance": 10000.0,
|
|
"credit_limit": 50000.0,
|
|
},
|
|
{
|
|
"name": "平台管理员",
|
|
"email": "admin@test.com",
|
|
"password": "admin123",
|
|
"role": "admin",
|
|
"balance": 5000.0,
|
|
"credit_limit": 20000.0,
|
|
},
|
|
{
|
|
"name": "xiaohei",
|
|
"email": "xiaohei@test.com",
|
|
"password": "1233456",
|
|
"role": "admin",
|
|
"balance": 5000.0,
|
|
"credit_limit": 20000.0,
|
|
},
|
|
{
|
|
"name": "计费管理员",
|
|
"email": "billing@test.com",
|
|
"password": "billing123",
|
|
"role": "billing_admin",
|
|
"balance": 1000.0,
|
|
"credit_limit": 5000.0,
|
|
},
|
|
{
|
|
"name": "运营管理员",
|
|
"email": "operations@test.com",
|
|
"password": "ops123",
|
|
"role": "operations_admin",
|
|
"balance": 1000.0,
|
|
"credit_limit": 5000.0,
|
|
},
|
|
{
|
|
"name": "渠道管理员A",
|
|
"email": "channel-admin-a@test.com",
|
|
"password": "channel123",
|
|
"role": "channel_admin",
|
|
"balance": 3000.0,
|
|
"credit_limit": 10000.0,
|
|
},
|
|
{
|
|
"name": "渠道管理员B",
|
|
"email": "channel-admin-b@test.com",
|
|
"password": "channel123",
|
|
"role": "channel_admin",
|
|
"balance": 2000.0,
|
|
"credit_limit": 8000.0,
|
|
},
|
|
{
|
|
"name": "供应商管理员",
|
|
"email": "provider@test.com",
|
|
"password": "provider123",
|
|
"role": "provider_admin",
|
|
"balance": 1000.0,
|
|
"credit_limit": 5000.0,
|
|
},
|
|
{
|
|
"name": "测试用户1",
|
|
"email": "user1@test.com",
|
|
"password": "user123",
|
|
"role": "user",
|
|
"balance": 100.0,
|
|
"credit_limit": 500.0,
|
|
},
|
|
{
|
|
"name": "测试用户2",
|
|
"email": "user2@test.com",
|
|
"password": "user123",
|
|
"role": "user",
|
|
"balance": 500.0,
|
|
"credit_limit": 2000.0,
|
|
},
|
|
{
|
|
"name": "测试用户3",
|
|
"email": "user3@test.com",
|
|
"password": "user123",
|
|
"role": "user",
|
|
"balance": 50.0,
|
|
"credit_limit": 200.0,
|
|
},
|
|
]
|
|
|
|
def main():
|
|
print("=" * 80)
|
|
print("测试账号配置检查")
|
|
print("=" * 80)
|
|
|
|
# 检查xiaohei账号是否存在
|
|
xiaohei_found = False
|
|
for account in test_accounts:
|
|
if account["email"] == "xiaohei@test.com":
|
|
xiaohei_found = True
|
|
print("\n✅ xiaohei账号配置已找到!")
|
|
print("-" * 80)
|
|
print(f"用户名: {account['name']}")
|
|
print(f"邮箱: {account['email']}")
|
|
print(f"密码: {account['password']}")
|
|
print(f"角色: {account['role']}")
|
|
print(f"余额: ¥{account['balance']:,.2f}")
|
|
print(f"授信额度: ¥{account['credit_limit']:,.2f}")
|
|
print("-" * 80)
|
|
break
|
|
|
|
if not xiaohei_found:
|
|
print("\n❌ 错误: xiaohei账号未在配置中找到!")
|
|
return False
|
|
|
|
# 显示所有测试账号
|
|
print("\n所有测试账号列表:")
|
|
print("=" * 80)
|
|
print(f"{'序号':<5} {'用户名':<15} {'邮箱':<30} {'密码':<15} {'角色':<20}")
|
|
print("-" * 80)
|
|
|
|
for idx, account in enumerate(test_accounts, 1):
|
|
print(f"{idx:<5} {account['name']:<15} {account['email']:<30} {account['password']:<15} {account['role']:<20}")
|
|
|
|
print("=" * 80)
|
|
print(f"\n总计: {len(test_accounts)} 个测试账号")
|
|
|
|
# 角色统计
|
|
role_counts = {}
|
|
for account in test_accounts:
|
|
role = account['role']
|
|
role_counts[role] = role_counts.get(role, 0) + 1
|
|
|
|
print("\n角色分布:")
|
|
print("-" * 80)
|
|
for role, count in sorted(role_counts.items()):
|
|
print(f"{role:<25} : {count} 个账号")
|
|
|
|
# 生成登录测试命令
|
|
print("\n" + "=" * 80)
|
|
print("登录测试命令(xiaohei账号):")
|
|
print("=" * 80)
|
|
print("\ncurl -X POST http://localhost:8000/api/auth/login \\")
|
|
print(' -H "Content-Type: application/json" \\')
|
|
print(' -d \'{\n "email": "xiaohei@test.com",')
|
|
print(' "password": "1233456",')
|
|
print(' "role": "admin"\n }\'')
|
|
|
|
print("\n" + "=" * 80)
|
|
print("✅ 账号配置检查完成!")
|
|
print("=" * 80)
|
|
|
|
print("\n注意:")
|
|
print("- 以上配置已在 init_test_accounts.py 脚本中正确设置")
|
|
print("- 运行 init_test_accounts.py 脚本将创建这些账号到数据库")
|
|
print("- 需要先安装依赖: pip install -r requirements.txt")
|
|
print("- 需要确保数据库服务正在运行")
|
|
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
success = main()
|
|
exit(0 if success else 1)
|
|
|
|
|