v2.5.1更新

This commit is contained in:
2026-05-29 20:16:25 +08:00
parent fe58ee1d23
commit b2c36cab2c
22 changed files with 347 additions and 166 deletions

View File

@@ -224,7 +224,8 @@ class ConductModel:
related_type: str = None,
reason_prefix: str = None,
page: int = 1,
page_size: int = 20
page_size: int = 20,
is_revoked: int = None
) -> Dict[str, Any]:
"""获取分组后的操行分记录(同批次合并)"""
if start_date == "":
@@ -236,9 +237,15 @@ class ConductModel:
if reason_prefix == "":
reason_prefix = None
conditions = ["cr.is_revoked = 0"]
conditions = ["1=1"]
params = []
if is_revoked is not None:
conditions.append("cr.is_revoked = %s")
params.append(1 if is_revoked else 0)
else:
conditions.append("cr.is_revoked = 0")
if student_id:
conditions.append("cr.student_id = %s")
params.append(student_id)
@@ -258,7 +265,7 @@ class ConductModel:
where_clause = " AND ".join(conditions)
count_sql = f"""
SELECT COUNT(DISTINCT CONCAT(cr.points_change, '|', cr.reason, '|', cr.recorder_id, '|', DATE_FORMAT(cr.created_at, '%%Y-%%m-%%d %%H:%%i'))) as total
SELECT COUNT(DISTINCT CONCAT(cr.points_change, '|', cr.reason, '|', cr.recorder_id, '|', DATE_FORMAT(cr.created_at, '%%Y-%%m-%%d %%H:%%i:%%s'))) as total
FROM conduct_records cr
WHERE {where_clause}
"""
@@ -270,11 +277,12 @@ class ConductModel:
cr.recorder_name,
DATE_FORMAT(MIN(cr.created_at), '%%Y-%%m-%%d %%H:%%i:%%s') as created_at,
GROUP_CONCAT(s.name ORDER BY s.student_id SEPARATOR ', ') as student_names,
COUNT(*) as student_count
COUNT(*) as student_count,
MAX(cr.is_revoked) as all_revoked
FROM conduct_records cr
JOIN students s ON cr.student_id = s.student_id
WHERE {where_clause}
GROUP BY cr.points_change, cr.reason, cr.recorder_id, DATE_FORMAT(cr.created_at, '%%Y-%%m-%%d %%H:%%i')
GROUP BY cr.points_change, cr.reason, cr.recorder_id, DATE_FORMAT(cr.created_at, '%%Y-%%m-%%d %%H:%%i:%%s')
ORDER BY MIN(cr.created_at) DESC
LIMIT %s OFFSET %s
"""