1
This commit is contained in:
@@ -44,7 +44,7 @@ def del_students(stu_id:int
|
||||
,db=Depends(get_db)):
|
||||
rows=delete_student_dao( stu_id=stu_id,db=db )
|
||||
if not rows:
|
||||
raise HTTPException(status_code=500,detail='没有删除')
|
||||
raise HTTPException(status_code=404,detail='对象已被删除')
|
||||
return {'code':200,'totals':rows,'detail':'删除成功'}
|
||||
|
||||
@StudentAPI.post('/students',tags=['学⽣基本信息管理模块'],response_model=StugetResponse,summary='学生信息新增接口',description='新增学生信息')
|
||||
@@ -53,5 +53,5 @@ def add_students(s:StudentRequest
|
||||
d=s.model_dump(exclude_unset=True)
|
||||
stu_new=add_student_dao(o=d,db=db)
|
||||
if not stu_new:
|
||||
raise HTTPException(status_code=500,detail='添加失败')
|
||||
raise HTTPException(status_code=404,detail='添加失败')
|
||||
return stu_new
|
||||
|
||||
@@ -28,12 +28,14 @@ def delete_student_dao(stu_id,db):
|
||||
|
||||
def update_student_dao(stu_id,update_data,db):
|
||||
try:
|
||||
rows = db.query( Student_Model ).filter( Student_Model.stu_id == stu_id,Student_Model.delete_status == 0).update( update_data )
|
||||
rows = (db.query( Student_Model )
|
||||
.filter( Student_Model.stu_id == stu_id,Student_Model.delete_status == 0)
|
||||
.update( update_data ))
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
return False
|
||||
else:
|
||||
db.commit()
|
||||
return rows
|
||||
|
||||
def get_student_dao(stu_id:Optional[int]
|
||||
|
||||
@@ -52,6 +52,7 @@ class StugetResponse(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
code:int = 200
|
||||
detail:str = 'ok'
|
||||
stu_id:int | None = None
|
||||
class_id: int | None = None
|
||||
stu_name: str | None = None
|
||||
age: int | None = None
|
||||
|
||||
Reference in New Issue
Block a user