v2.6更新

This commit is contained in:
2026-05-29 21:07:27 +08:00
parent b2c36cab2c
commit 69adb30fa0
12 changed files with 117 additions and 29 deletions

View File

@@ -152,6 +152,7 @@ class ConductModel:
params.extend([limit, offset])
return await execute_query(sql, tuple(params))
@staticmethod
@staticmethod
async def get_all_records(
limit: int = 100,
@@ -162,7 +163,8 @@ class ConductModel:
include_revoked: bool = True,
related_type: str = None,
reason_prefix: str = None,
is_revoked: int = None
is_revoked: int = None,
reason_search: str = None
) -> List[Dict[str, Any]]:
"""获取所有记录(班主任/班长专用)"""
# 空字符串转为None
@@ -174,6 +176,8 @@ class ConductModel:
related_type = None
if reason_prefix == "":
reason_prefix = None
if reason_search == "":
reason_search = None
sql = """
SELECT cr.*, s.name as student_name, s.student_no, u.real_name as recorder_name,
ru.real_name as revoker_name
@@ -207,6 +211,10 @@ class ConductModel:
sql += " AND cr.reason LIKE %s"
params.append(f"{reason_prefix}%")
if reason_search:
sql += " AND cr.reason LIKE %s"
params.append(f"%{reason_search}%")
if is_revoked is not None:
sql += " AND cr.is_revoked = %s"
params.append(1 if is_revoked else 0)
@@ -215,7 +223,7 @@ class ConductModel:
params.extend([limit, offset])
return await execute_query(sql, tuple(params))
@staticmethod
async def get_grouped_records(
student_id: int = None,
@@ -225,7 +233,8 @@ class ConductModel:
reason_prefix: str = None,
page: int = 1,
page_size: int = 20,
is_revoked: int = None
is_revoked: int = None,
reason_search: str = None
) -> Dict[str, Any]:
"""获取分组后的操行分记录(同批次合并)"""
if start_date == "":
@@ -236,6 +245,8 @@ class ConductModel:
related_type = None
if reason_prefix == "":
reason_prefix = None
if reason_search == "":
reason_search = None
conditions = ["1=1"]
params = []
@@ -261,6 +272,9 @@ class ConductModel:
if reason_prefix:
conditions.append("cr.reason LIKE %s")
params.append(f"{reason_prefix}%")
if reason_search:
conditions.append("cr.reason LIKE %s")
params.append(f"%{reason_search}%")
where_clause = " AND ".join(conditions)