Merge remote-tracking branch 'origin/conding' into conding
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
from fastapi import HTTPException,Depends
|
||||
from fastapi import HTTPException
|
||||
from model.all_model import Employment_info, ClassManagement, Student_Model
|
||||
from util.database import get_db
|
||||
from schema.employment_schema import EmploymentRequest
|
||||
|
||||
def get_employment_dao(stu_id,class_id,db=Depends(get_db())):
|
||||
def get_employment_dao(stu_id,class_id,db):
|
||||
try:
|
||||
q = db.query(Employment_info).\
|
||||
join(Student_Model,Employment_info.stu_id == Student_Model.stu_id).\
|
||||
@@ -27,20 +27,19 @@ def get_employment_dao(stu_id,class_id,db=Depends(get_db())):
|
||||
,'company_name':i.company_name
|
||||
,'company_address':i.company_address
|
||||
,'salary':i.salary
|
||||
}for i in r
|
||||
}for i in r
|
||||
]
|
||||
except:
|
||||
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
|
||||
def add_employment_dao(e:EmploymentRequest,db):
|
||||
try:
|
||||
d = e.model_dump()
|
||||
e1 = Employment_info(**d)
|
||||
db.add(e1)
|
||||
except:
|
||||
db.rollback()
|
||||
raise HTTPException(status_code=404, detail='信息不存在!')
|
||||
else:
|
||||
db.commit()
|
||||
return e1
|
||||
|
||||
Reference in New Issue
Block a user