就业get次昂管的dao层和api接口
This commit is contained in:
@@ -13,7 +13,7 @@ def get_emp_info1(stu_id: int,db=Depends(get_db)):
|
||||
if stu_id:
|
||||
return employment_dao.get_employment_info()
|
||||
except:
|
||||
raise HTTPException(status_code=404, detail='就业信息不存在')
|
||||
raise HTTPException(status_code=404, detail='该学生就业信息不存在')
|
||||
|
||||
@app.get('employment/class/{class_id}',summary='获取班级学生就业信息')
|
||||
def get_emp_info2(class_id: int,db=Depends(get_db)):
|
||||
@@ -21,10 +21,9 @@ def get_emp_info2(class_id: int,db=Depends(get_db)):
|
||||
if class_id:
|
||||
return employment_dao.get_employment_info()
|
||||
except:
|
||||
raise HTTPException(status_code=404, detail='就业信息不存在')
|
||||
raise HTTPException(status_code=404, detail='该班级就业信息不存在')
|
||||
|
||||
|
||||
|
||||
@app.post('employment/students/{stu_id}')
|
||||
def create_emp_info(stu_id: int,db=Depends(get_db)):
|
||||
# @app.post('employment/students/{stu_id}')
|
||||
# def create_emp_info(stu_id: int,db=Depends(get_db)):
|
||||
# try:
|
||||
pass
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
|
||||
from fastapi import HTTPException,Depends
|
||||
from model.all_model import Employment_info, ClassManagement, Student_Model
|
||||
from util.database import get_db
|
||||
from schema.employment_schema import EmlpoymentRequest
|
||||
|
||||
def get_employment_dao(stu_id,class_id,db):
|
||||
def get_employment_dao(stu_id,class_id,db=Depends(get_db())):
|
||||
try:
|
||||
q = db.query(Employment_info).\
|
||||
join(ClassManagement,ClassManagement.stu_id == Employment_info.stu_id).\
|
||||
join(Student_Model,Employment_info.stu_id == Student_Model.stu_id).\
|
||||
join(ClassManagement,Student_Model.class_id == ClassManagement.class_id).\
|
||||
filter(Employment_info.delete_status == 0).\
|
||||
filter(Student_Model.delete_status == 0).\
|
||||
filter(ClassManagement.delete_status == 0)
|
||||
@@ -27,14 +29,18 @@ def get_employment_dao(stu_id,class_id,db):
|
||||
,'salary':i.salary
|
||||
}for i in r
|
||||
]
|
||||
|
||||
def add_employment_dao(e:EmlpoymentRequest,db,stu_id):
|
||||
try:
|
||||
e1 = Employment_info(**e)
|
||||
db.add(e1)
|
||||
except:
|
||||
db.rollback()
|
||||
return False
|
||||
else:
|
||||
db.commit()
|
||||
return True
|
||||
raise HTTPException(status_code=404,detail='信息不存在!')
|
||||
|
||||
# def add_employment_dao(e:EmlpoymentRequest,db=Depends(get_db()),stu_id):
|
||||
# try:
|
||||
# r = db.query(Employment_info).filter(Employment_info.stu_id == stu_id).all()
|
||||
# if r:
|
||||
# e1 = Employment_info(**e)
|
||||
# db.add(e1)
|
||||
# except:
|
||||
# db.rollback()
|
||||
# return False
|
||||
# else:
|
||||
# db.commit()
|
||||
# return True
|
||||
|
||||
Reference in New Issue
Block a user