feat: 实装AI改写结局功能 - 接入DeepSeek API - AI动态生成新结局名称 - 新增rewrite类型结局样式 - 修复请求超时问题

This commit is contained in:
2026-03-05 15:57:51 +08:00
parent 89b5a3b658
commit d47ccd7039
11 changed files with 513 additions and 15 deletions

40
server/init_db.py Normal file
View File

@@ -0,0 +1,40 @@
import asyncio
import aiomysql
async def init_db():
# 连接 MySQL
conn = await aiomysql.connect(
host='localhost',
port=3306,
user='root',
password='liang20020523',
db='ai_game',
charset='utf8mb4'
)
try:
async with conn.cursor() as cursor:
# 读取 SQL 文件
with open('sql/schema_v2.sql', 'r', encoding='utf-8') as f:
sql_content = f.read()
# 分割 SQL 语句(按分号分隔)
statements = [s.strip() for s in sql_content.split(';') if s.strip()]
# 执行每个语句
for stmt in statements:
if stmt and not stmt.startswith('--'):
try:
await cursor.execute(stmt)
print(f"✓ 执行成功")
except Exception as e:
print(f"✗ 执行失败:{e}")
await conn.commit()
print("\n数据库初始化完成!")
finally:
await conn.close()
if __name__ == '__main__':
asyncio.run(init_db())