feat: 增加学生信息管理功能,优化操行分历史记录展示并更新使用文档
This commit is contained in:
@@ -159,7 +159,8 @@ class ConductService:
|
||||
page: int = 1,
|
||||
page_size: int = 20,
|
||||
start_date: Optional[str] = None,
|
||||
end_date: Optional[str] = None
|
||||
end_date: Optional[str] = None,
|
||||
grouped: bool = False
|
||||
) -> Dict[str, Any]:
|
||||
"""获取历史记录"""
|
||||
# 空字符串转为None
|
||||
@@ -173,21 +174,43 @@ class ConductService:
|
||||
|
||||
# 班主任/班长/志愿委员可查看全班
|
||||
if role in ["班主任", "班长", "志愿委员"]:
|
||||
if grouped:
|
||||
return await ConductModel.get_grouped_records(
|
||||
student_id=student_id,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
page=page,
|
||||
page_size=page_size
|
||||
)
|
||||
|
||||
records = await ConductModel.get_all_records(
|
||||
limit=page_size,
|
||||
offset=offset,
|
||||
start_date=start_date,
|
||||
end_date=end_date
|
||||
end_date=end_date,
|
||||
student_id=student_id
|
||||
)
|
||||
|
||||
# 获取总数
|
||||
from utils.database import execute_one
|
||||
count_sql = """
|
||||
count_conditions = ["cr.is_revoked = 0"]
|
||||
count_params = []
|
||||
if student_id:
|
||||
count_conditions.append("cr.student_id = %s")
|
||||
count_params.append(student_id)
|
||||
if start_date:
|
||||
count_conditions.append("DATE(cr.created_at) >= %s")
|
||||
count_params.append(start_date)
|
||||
if end_date:
|
||||
count_conditions.append("DATE(cr.created_at) <= %s")
|
||||
count_params.append(end_date)
|
||||
count_where = " AND ".join(count_conditions)
|
||||
count_sql = f"""
|
||||
SELECT COUNT(*) as total FROM conduct_records cr
|
||||
JOIN students s ON cr.student_id = s.student_id
|
||||
WHERE cr.is_revoked = 0
|
||||
WHERE {count_where}
|
||||
"""
|
||||
total_result = await execute_one(count_sql)
|
||||
total_result = await execute_one(count_sql, tuple(count_params))
|
||||
total = total_result["total"] if total_result else 0
|
||||
|
||||
elif student_id:
|
||||
|
||||
Reference in New Issue
Block a user