diff --git a/PythonProject/api/employment_api.py b/PythonProject/api/employment_api.py index 6faec0e..71b8f25 100644 --- a/PythonProject/api/employment_api.py +++ b/PythonProject/api/employment_api.py @@ -31,13 +31,13 @@ def get_emp_info2(stu_id:int = Path(description='学生编号') raise HTTPException(status_code=404,detail='该学生就业信息不存在!') return l1 -@emp_api.post('/employment/students/{stu_id}',response_model=EmploymentResponse,summary='新增学生就业信息') +@emp_api.post('/employment/student/{stu_id}',summary='新增学生就业信息') def create_emp_info(emp:EmploymentRequest=Form(),db=Depends(get_db)): d=emp.model_dump(exclude_unset=False) r=add_emp_dao(d,db) if not r: raise HTTPException(status_code=500,detail='服务器繁忙,请稍后添加!') - return r + return {'code':200,'detail':'插入成功!'} @emp_api.put('/employment/students/{emp_id}',summary='更新学生就业信息') def update_emp_info(emp_id:int,emp:UpdateEmpRequest,db=Depends(get_db)): diff --git a/PythonProject/api/student_api.py b/PythonProject/api/student_api.py index be75ffc..66a6ae7 100644 --- a/PythonProject/api/student_api.py +++ b/PythonProject/api/student_api.py @@ -1,4 +1,4 @@ -from fastapi import APIRouter,HTTPException,Depends,Query +from fastapi import APIRouter, HTTPException, Depends, Query, Path from dao.student_dao import * from schema.student_schema import * from util.database import get_db @@ -53,7 +53,7 @@ def update_students(stu_id:int return {'code':200,'totals':r,'detail':'更新成功'} @StudentAPI.delete('/students/{stu_id}',response_model= StudelResponse,summary='学生信息删除接口',description='删除学生信息') -def del_students(stu_id:int=Query(None,description='班级编号') +def del_students(stu_id:int= Path(description='班级编号') ,db=Depends(get_db)): rows=delete_student_dao( stu_id=stu_id,db=db ) if not rows: diff --git a/PythonProject/dao/employment_dao.py b/PythonProject/dao/employment_dao.py index 9e0f8b7..96fd712 100644 --- a/PythonProject/dao/employment_dao.py +++ b/PythonProject/dao/employment_dao.py @@ -49,7 +49,7 @@ def add_emp_dao(o,db): e1 = Employment_info(**o) db.add(e1) db.commit() - return e1 + return o except Exception as e: db.rollback() raise HTTPException(status_code=500, detail=f'新增就业信息失败: {e}')