This commit is contained in:
2026-09-22 11:31:37 +08:00
parent 4198e0af4e
commit 4681652172
4 changed files with 75 additions and 72 deletions
+16 -14
View File
@@ -8,18 +8,20 @@ emp_api = APIRouter(tags=['学生就业管理系统'])
@emp_api.get('/employment/students/{stu_id}',response_model=EmploymentResponse,summary='获取学生就业信息')
def get_emp_info1(stu_id: Optional[int]=Path(description='学生编号')
,company_name: Optional[str]=Query(None,description='公司名称')
,min_salary: Optional[float]=Query(None,description='最低工资')
,max_salary: Optional[float]=Query(None,description='最高工资')
,min_salary: Optional[float]=Query(None,ge=0,description='最低工资')
,max_salary: Optional[float]=Query(None,ge=0,description='最高工资')
,db=Depends(get_db)):
if stu_id or company_name or min_salary or max_salary:
return [employment_dao.get_emp_dao(stu_id=stu_id,db=db)]
raise HTTPException(status_code=404, detail='该学生就业信息不存在')
if min_salary and max_salary:
if min_salary > max_salary:
raise HTTPException(status_code=404, detail='该学生就业信息不存在')
return [employment_dao.get_emp_dao(stu_id=stu_id,db=db)]
@emp_api.get('/employment/class/{class_id}',response_model=EmploymentResponse,summary='获取班级学生就业信息')
def get_emp_info2(class_id: Optional[int]=Path(description='班级编号')
,db=Depends(get_db)):
if class_id:
return employment_dao.get_emp_dao(class_id=class_id,db=db)
e = employment_dao.get_emp_dao(class_id=class_id, db=db)
if e:
return e
raise HTTPException(status_code=404, detail='该班级就业信息不存在')
@emp_api.post('/employment/students/{stu_id}',response_model=EmploymentResponse,summary='新增学生就业信息')
@@ -30,17 +32,17 @@ def create_emp_info(emp:EmploymentRequest=Form(),db=Depends(get_db)):
raise HTTPException(status_code=500,detail='服务器繁忙,请稍后添加!')
return r
@emp_api.put('/employment/students/{stu_id}',response_model=EmploymentResponse,summary='更新学生就业信息')
def update_emp_info(stu_id:int,emp:EmploymentRequest,db=Depends(get_db)):
@emp_api.put('/employment/students/{emp_id}',response_model=EmploymentResponse,summary='更新学生就业信息')
def update_emp_info(emp_id:int,emp:EmploymentRequest,db=Depends(get_db)):
d = emp.model_dump(exclude_unset=True)
r = update_emp_dao(stu_id,d,db)
r = update_emp_dao(emp_id=emp_id,db=db)
if not r:
raise HTTPException(status_code=500,detail='更新失败!')
raise HTTPException(status_code=500,detail='没有更新!')
return {'code':200,'totals':r,'detail':'更新成功!'}
@emp_api.delete('/employment/{stu_id}',summary='删除学生就业信息')
def delete_emp_info(stu_id:int,db=Depends(get_db)):
rows = delete_emp_dao(stu_id, db)
@emp_api.delete('/employment/{emp_id}',summary='删除学生就业信息')
def delete_emp_info(emp_id:int=Path(description='序号'),db=Depends(get_db)):
rows = delete_emp_dao(emp_id, db)
if not rows:
raise HTTPException(status_code=500, detail='没有删除!')
return {'code':200,'detail':'删除成功!'}