From 337bfce8b195dd88c1bfbce397cb3e132a72bca1 Mon Sep 17 00:00:00 2001 From: wolin_chenyulin001 <123@163.com> Date: Mon, 21 Sep 2026 22:58:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=B1=E4=B8=9Aget=E6=AC=A1=E6=98=82?= =?UTF-8?q?=E7=AE=A1=E7=9A=84dao=E5=B1=82=E5=92=8Capi=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PythonProject/api/employment_api.py | 10 +++++----- PythonProject/dao/employment_dao.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/PythonProject/api/employment_api.py b/PythonProject/api/employment_api.py index 3e4a380..acb8e61 100644 --- a/PythonProject/api/employment_api.py +++ b/PythonProject/api/employment_api.py @@ -31,14 +31,14 @@ def create_emp_info(stu_id:int,emp:EmploymentRequest,db=Depends(get_db)): return r @emp_api.put('/employment/students/{stu_id}',response_model=EmploymentResponse,summary='更新学生就业信息') -def update_emp_info(emp_id:int,emp:EmploymentRequest,db=Depends(get_db)): +def update_emp_info(stu_id:int,emp:EmploymentRequest,db=Depends(get_db)): d = emp.model_dump(exclude_unset=True) - r = update_emp_dao(emp_id,d,db) + r = update_emp_dao(stu_id,d,db) if not r: raise HTTPException(status_code=500,detail='更新失败!') return {'code':200,'totals':r,'detail':'更新成功!'} -@emp_api.delete('/employment/{emp_id}',summary='删除学生就业信息') -def delete_emp_info(emp_id:int,db=Depends(get_db)): - delete_emp_dao(emp_id,db) +@emp_api.delete('/employment/{stu_id}',summary='删除学生就业信息') +def delete_emp_info(stu_id:int,db=Depends(get_db)): + delete_emp_dao(stu_id,db) return {'code':200,'detail':'删除成功!'} diff --git a/PythonProject/dao/employment_dao.py b/PythonProject/dao/employment_dao.py index b3ef67c..dc7cacc 100644 --- a/PythonProject/dao/employment_dao.py +++ b/PythonProject/dao/employment_dao.py @@ -45,12 +45,12 @@ def check_stu_dao(stu_id,db): stu = db.query(Student_Model).filter(Student_Model.stu_id == stu_id,Student_Model.delete_status == 0).first() return stu -def check_emp_dao(stu_id=): +# def check_emp_dao(stu_id=): -def update_emp_dao(emp_id,o,db): +def update_emp_dao(stu_id,o,db): try: - rows = db.query(Employment_info).filter(Employment_info.emp_id == emp_id,Employment_info.delete_status == 0).first() + rows = db.query(Employment_info).filter(Employment_info.stu_id == stu_id,Employment_info.delete_status == 0).first() db.commit() return rows except: @@ -58,9 +58,9 @@ def update_emp_dao(emp_id,o,db): raise HTTPException(status_code=404,detail='该就业记录已存在') -def delete_emp_dao(emp_id,db): +def delete_emp_dao(stu_id,db): try: - rows = db.query(Employment_info).filter(Employment_info.emp_id == emp_id,Employment_info.delete_status == 0).delete() + rows = db.query(Employment_info).filter(Employment_info.stu_id == stu_id,Employment_info.delete_status == 0).delete() db.commit() except: db.rollback()