v2.5更新
This commit is contained in:
@@ -161,7 +161,8 @@ class ConductModel:
|
||||
student_id: int = None,
|
||||
include_revoked: bool = True,
|
||||
related_type: str = None,
|
||||
reason_prefix: str = None
|
||||
reason_prefix: str = None,
|
||||
is_revoked: int = None
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""获取所有记录(班主任/班长专用)"""
|
||||
# 空字符串转为None
|
||||
@@ -206,6 +207,10 @@ class ConductModel:
|
||||
sql += " AND cr.reason LIKE %s"
|
||||
params.append(f"{reason_prefix}%")
|
||||
|
||||
if is_revoked is not None:
|
||||
sql += " AND cr.is_revoked = %s"
|
||||
params.append(1 if is_revoked else 0)
|
||||
|
||||
sql += " ORDER BY cr.created_at DESC LIMIT %s OFFSET %s"
|
||||
params.extend([limit, offset])
|
||||
|
||||
|
||||
@@ -76,6 +76,12 @@ class SubjectModel:
|
||||
|
||||
@staticmethod
|
||||
async def delete(subject_id: int) -> bool:
|
||||
"""软删除科目(设置 is_active = 0),如果已禁用也返回成功"""
|
||||
subject = await SubjectModel.get_by_id(subject_id)
|
||||
if not subject:
|
||||
return False
|
||||
if subject.get("is_active") == 0:
|
||||
return True # 已禁用,视为成功
|
||||
sql = "UPDATE subjects SET is_active = 0 WHERE subject_id = %s"
|
||||
result = await execute_update(sql, (subject_id,))
|
||||
return result > 0
|
||||
|
||||
Reference in New Issue
Block a user