v2.0.1更新
This commit is contained in:
@@ -42,7 +42,6 @@ class HomeworkModel:
|
||||
"""
|
||||
return await execute_query(sql, tuple(subject_ids))
|
||||
|
||||
@staticmethod
|
||||
@staticmethod
|
||||
async def get_student_homework(student_id: int) -> List[Dict[str, Any]]:
|
||||
sql = """
|
||||
|
||||
@@ -126,6 +126,18 @@ class SemesterModel:
|
||||
"""
|
||||
return await execute_query(sql, (semester_id, start_date, end_date))
|
||||
|
||||
@staticmethod
|
||||
async def count_records_by_semester(semester_id: int) -> Dict[str, int]:
|
||||
"""统计学期关联的记录数"""
|
||||
conduct_sql = "SELECT COUNT(*) as cnt FROM conduct_records WHERE semester_id = %s"
|
||||
attendance_sql = "SELECT COUNT(*) as cnt FROM attendance_records WHERE semester_id = %s"
|
||||
conduct_result = await execute_one(conduct_sql, (semester_id,))
|
||||
attendance_result = await execute_one(attendance_sql, (semester_id,))
|
||||
return {
|
||||
"conduct_count": conduct_result['cnt'] if conduct_result else 0,
|
||||
"attendance_count": attendance_result['cnt'] if attendance_result else 0
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
async def get_homework_stats_by_date_range(start_date: str, end_date: str) -> List[Dict]:
|
||||
"""通过作业截止日期范围查询所有学生的作业提交统计"""
|
||||
|
||||
@@ -69,6 +69,13 @@ class SubjectModel:
|
||||
result = await execute_update(sql, tuple(params))
|
||||
return result > 0
|
||||
|
||||
@staticmethod
|
||||
async def has_related_data(subject_id: int) -> bool:
|
||||
"""检查科目是否有关联数据(assignments表)"""
|
||||
sql = "SELECT COUNT(*) as cnt FROM assignments WHERE subject_id = %s"
|
||||
result = await execute_one(sql, (subject_id,))
|
||||
return result['cnt'] > 0
|
||||
|
||||
@staticmethod
|
||||
async def delete(subject_id: int) -> bool:
|
||||
sql = "UPDATE subjects SET is_active = 0 WHERE subject_id = %s"
|
||||
|
||||
Reference in New Issue
Block a user