第四版_完整
This commit is contained in:
+5
-4
@@ -1,6 +1,6 @@
|
||||
# dao/cls_mgmt_dao.py
|
||||
# 本文件封装对 ClsMgmt 表的所有数据库操作(增、删、改、查)
|
||||
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from model.cls_mgmt_model import ClsMgmt
|
||||
@@ -19,7 +19,7 @@ class ClsMgmtDAO:
|
||||
:param limit: 最大返回条数
|
||||
:return: 用户对象列表
|
||||
"""
|
||||
return db.query(ClsMgmt).offset(skip).limit(limit).all()
|
||||
return db.query(ClsMgmt).filter(ClsMgmt.is_deleted == 0).offset(skip).limit(limit).all()
|
||||
|
||||
# -> Optional[ClsMgmt]
|
||||
# @staticmethod
|
||||
@@ -36,7 +36,7 @@ class ClsMgmtDAO:
|
||||
根据主键 ID 获取单个班级
|
||||
:return: 班级对象或 None
|
||||
"""
|
||||
return db.query(ClsMgmt).filter(ClsMgmt.id == class_id).first()
|
||||
return db.query(ClsMgmt).filter(ClsMgmt.id == class_id,ClsMgmt.is_deleted == 0).first()
|
||||
|
||||
|
||||
|
||||
@@ -115,7 +115,8 @@ class ClsMgmtDAO:
|
||||
update_cls.lecturer_id=cls_data.lecturer_id
|
||||
db.commit()
|
||||
return update_cls
|
||||
return f"班级{class_id}不存在"
|
||||
|
||||
raise HTTPException(status_code=404, detail=f"班级{class_id}不存在")
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user