ceshi
This commit is contained in:
@@ -4,26 +4,39 @@ from dao.employment_dao import add_emp_dao, update_emp_dao, delete_emp_dao
|
||||
from schema.employment_schema import EmploymentRequest,EmploymentResponse
|
||||
from util.database import get_db
|
||||
from typing import Optional
|
||||
emp_api = APIRouter(tags=['学生就业管理系统'])
|
||||
@emp_api.get('/employment/students/{stu_id}',response_model=EmploymentResponse,summary='获取学生就业信息')
|
||||
emp_api = APIRouter(tags=['学生就业管理模块'])
|
||||
|
||||
@emp_api.get('/employment/class/{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,ge=0,description='最低工资')
|
||||
,max_salary: Optional[float]=Query(None,ge=0,description='最高工资')
|
||||
,db=Depends(get_db)):
|
||||
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)]
|
||||
e1 = employment_dao.get_emp_dao(stu_id=stu_id, db=db)
|
||||
if e1:
|
||||
return e1[0]
|
||||
raise HTTPException(status_code=404, detail='该学生就业信息不存在')
|
||||
|
||||
@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)):
|
||||
e = employment_dao.get_emp_dao(class_id=class_id, db=db)
|
||||
if e:
|
||||
return e
|
||||
e2 = employment_dao.get_emp_dao(class_id=class_id, db=db)
|
||||
if e2:
|
||||
return e2
|
||||
raise HTTPException(status_code=404, detail='该班级就业信息不存在')
|
||||
|
||||
@emp_api.get('/employment}',response_model=EmploymentResponse,summary='按照学⽣编号,公司名字,⼯资范围查询学⽣就业信息')
|
||||
def get_emp_info3(stu_id:int|None = Query(None, description='学生编号')
|
||||
,company_name: str|None = Query(None,description='公司名称')
|
||||
,min_salary: float|None = Query(None,ge=0,description='最低工资')
|
||||
,max_salary: float|None = Query(None,ge=0,description='最高工资')
|
||||
,db=Depends(get_db)):
|
||||
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
|
||||
,company_name=company_name
|
||||
,min_salary=min_salary
|
||||
,max_salary=max_salary
|
||||
,db=db)]
|
||||
|
||||
@emp_api.post('/employment/students/{stu_id}',response_model=EmploymentResponse,summary='新增学生就业信息')
|
||||
def create_emp_info(emp:EmploymentRequest=Form(),db=Depends(get_db)):
|
||||
d=emp.model_dump(exclude_unset=False)
|
||||
|
||||
Reference in New Issue
Block a user