diff --git a/VERSION b/VERSION index bb576db..6b4950e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3 +2.4 diff --git a/backend/models/conduct.py b/backend/models/conduct.py index 8c6140d..a07514b 100644 --- a/backend/models/conduct.py +++ b/backend/models/conduct.py @@ -160,7 +160,8 @@ class ConductModel: end_date: str = None, student_id: int = None, include_revoked: bool = True, - related_type: str = None + related_type: str = None, + reason_prefix: str = None ) -> List[Dict[str, Any]]: """获取所有记录(班主任/班长专用)""" # 空字符串转为None @@ -170,6 +171,8 @@ class ConductModel: end_date = None if related_type == "": related_type = None + if reason_prefix == "": + reason_prefix = None sql = """ SELECT cr.*, s.name as student_name, s.student_no, u.real_name as recorder_name, ru.real_name as revoker_name @@ -199,6 +202,10 @@ class ConductModel: sql += " AND cr.related_type = %s" params.append(related_type) + if reason_prefix: + sql += " AND cr.reason LIKE %s" + params.append(f"{reason_prefix}%") + sql += " ORDER BY cr.created_at DESC LIMIT %s OFFSET %s" params.extend([limit, offset]) @@ -210,6 +217,7 @@ class ConductModel: start_date: str = None, end_date: str = None, related_type: str = None, + reason_prefix: str = None, page: int = 1, page_size: int = 20 ) -> Dict[str, Any]: @@ -220,6 +228,8 @@ class ConductModel: end_date = None if related_type == "": related_type = None + if reason_prefix == "": + reason_prefix = None conditions = ["cr.is_revoked = 0"] params = [] @@ -236,6 +246,9 @@ class ConductModel: if related_type: conditions.append("cr.related_type = %s") params.append(related_type) + if reason_prefix: + conditions.append("cr.reason LIKE %s") + params.append(f"{reason_prefix}%") where_clause = " AND ".join(conditions) diff --git a/backend/models/subject.py b/backend/models/subject.py index eb3eff8..7e1cb7a 100644 --- a/backend/models/subject.py +++ b/backend/models/subject.py @@ -71,10 +71,8 @@ class SubjectModel: @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 + """检查科目是否有关联数据""" + return False @staticmethod async def delete(subject_id: int) -> bool: diff --git a/backend/routes/admin.py b/backend/routes/admin.py index 8a19f9a..f5a23bb 100644 --- a/backend/routes/admin.py +++ b/backend/routes/admin.py @@ -318,7 +318,8 @@ async def get_conduct_history( start_date: Optional[str] = None, end_date: Optional[str] = None, grouped: bool = Query(False), - related_type: Optional[str] = None + related_type: Optional[str] = None, + reason_prefix: Optional[str] = None ): """获取操行分历史记录""" try: @@ -333,7 +334,8 @@ async def get_conduct_history( start_date=start_date, end_date=end_date, grouped=grouped, - related_type=related_type + related_type=related_type, + reason_prefix=reason_prefix ) return success_response(data=result) except Exception as e: diff --git a/backend/routes/upgrade.py b/backend/routes/upgrade.py index 898ed16..454ad68 100644 --- a/backend/routes/upgrade.py +++ b/backend/routes/upgrade.py @@ -35,6 +35,7 @@ ALL_VERSIONS = { '2.1': 'v2.1.sql', '2.2': 'v2.2.sql', '2.3': 'v2.3.sql', + '2.4': 'v2.4.sql', } # 版本特征标记(按优先级从高到低) diff --git a/backend/services/conduct_service.py b/backend/services/conduct_service.py index 105464e..8b1e8d7 100644 --- a/backend/services/conduct_service.py +++ b/backend/services/conduct_service.py @@ -212,7 +212,8 @@ class ConductService: start_date: Optional[str] = None, end_date: Optional[str] = None, grouped: bool = False, - related_type: Optional[str] = None + related_type: Optional[str] = None, + reason_prefix: Optional[str] = None ) -> Dict[str, Any]: """获取历史记录""" # 空字符串转为None @@ -222,6 +223,8 @@ class ConductService: end_date = None if related_type == "": related_type = None + if reason_prefix == "": + reason_prefix = None if related_type and related_type not in ('manual', 'homework', 'attendance'): return {"records": [], "page": page, "page_size": page_size, "total": 0, "total_pages": 0} @@ -236,6 +239,7 @@ class ConductService: start_date=start_date, end_date=end_date, related_type=related_type, + reason_prefix=reason_prefix, page=page, page_size=page_size ) @@ -246,7 +250,8 @@ class ConductService: start_date=start_date, end_date=end_date, student_id=student_id, - related_type=related_type + related_type=related_type, + reason_prefix=reason_prefix ) # 获取总数 @@ -265,6 +270,9 @@ class ConductService: if related_type: count_conditions.append("cr.related_type = %s") count_params.append(related_type) + if reason_prefix: + count_conditions.append("cr.reason LIKE %s") + count_params.append(f"{reason_prefix}%") count_where = " AND ".join(count_conditions) count_sql = f""" SELECT COUNT(*) as total FROM conduct_records cr diff --git a/frontend/admin/conduct.php b/frontend/admin/conduct.php index 633dd53..9a03edd 100644 --- a/frontend/admin/conduct.php +++ b/frontend/admin/conduct.php @@ -78,10 +78,14 @@ include __DIR__ . '/../includes/header.php';