v0.6测试

This commit is contained in:
2026-04-14 19:18:11 +08:00
parent fd3535f884
commit a60ba8352f
23 changed files with 157 additions and 40 deletions

View File

@@ -11,7 +11,7 @@
from typing import Optional, List, Dict, Any
from datetime import datetime
from utils.database import execute_one, execute_query, execute_insert, execute_update, call_procedure
from utils.database import execute_one, execute_query, execute_insert, execute_update
from utils.logger import get_logger
logger = get_logger(__name__)
@@ -123,8 +123,13 @@ class ConductModel:
async def revoke_record(record_id: int, revoker_id: int) -> bool:
"""撤销记录"""
try:
await call_procedure('revoke_conduct_record', (record_id, revoker_id))
return True
sql = """
UPDATE conduct_records
SET is_revoked = 1, revoked_by = %s, revoked_at = NOW()
WHERE record_id = %s AND is_revoked = 0
"""
result = await execute_update(sql, (revoker_id, record_id))
return result > 0
except Exception as e:
logger.error(f"撤销记录失败: {e}")
return False

View File

@@ -109,14 +109,16 @@ class StudentModel:
async def get_ranking(limit: int = 50) -> List[Dict[str, Any]]:
"""获取学生排行(单班级)"""
sql = """
SELECT student_id, student_no, name, total_points,
RANK() OVER (ORDER BY total_points DESC) as rank
FROM students
SELECT student_id, student_no, name, total_points
FROM students
WHERE status = 1
ORDER BY total_points DESC
LIMIT %s
"""
return await execute_query(sql, (limit,))
results = await execute_query(sql, (limit,))
for i, row in enumerate(results):
row['rank'] = i + 1
return results
@staticmethod
async def batch_create(students_data: List[Dict], initial_points: int = 60) -> List[Dict]: