feat(conduct): add restore revoked record functionality and update history view
This commit is contained in:
@@ -82,7 +82,8 @@ class ConductModel:
|
||||
offset: int = 0,
|
||||
start_date: str = None,
|
||||
end_date: str = None,
|
||||
student_id: int = None
|
||||
student_id: int = None,
|
||||
include_revoked: bool = True
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""获取所有记录(班主任/班长专用)"""
|
||||
# 空字符串转为None
|
||||
@@ -96,8 +97,10 @@ class ConductModel:
|
||||
FROM conduct_records cr
|
||||
JOIN students s ON cr.student_id = s.student_id
|
||||
JOIN users u ON cr.recorder_id = u.user_id
|
||||
WHERE cr.is_revoked = 0
|
||||
WHERE 1=1
|
||||
"""
|
||||
if not include_revoked:
|
||||
sql += " AND cr.is_revoked = 0"
|
||||
params = []
|
||||
|
||||
if student_id:
|
||||
@@ -210,6 +213,21 @@ class ConductModel:
|
||||
logger.error(f"撤销记录失败: {e}")
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
async def restore_record(record_id: int, restorer_id: int) -> bool:
|
||||
"""反撤销(恢复)已撤销的记录"""
|
||||
try:
|
||||
sql = """
|
||||
UPDATE conduct_records
|
||||
SET is_revoked = 0, revoked_by = NULL, revoked_at = NULL
|
||||
WHERE record_id = %s AND is_revoked = 1
|
||||
"""
|
||||
result = await execute_update(sql, (record_id,))
|
||||
return result > 0
|
||||
except Exception as e:
|
||||
logger.error(f"恢复记录失败: {e}")
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
async def batch_create_records(records_data: List[Dict]) -> List[Dict]:
|
||||
"""批量创建操行分记录"""
|
||||
|
||||
Reference in New Issue
Block a user