就业get次昂管的dao层和api接口

This commit is contained in:
2026-09-21 22:51:45 +08:00
parent e53e0fd764
commit 7216922d8d
2 changed files with 66 additions and 23 deletions
+36 -12
View File
@@ -1,9 +1,8 @@
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):
def get_emp_dao(stu_id,class_id,db):
try:
q = db.query(Employment_info).\
join(Student_Model,Employment_info.stu_id == Student_Model.stu_id).\
@@ -19,8 +18,8 @@ def get_employment_dao(stu_id,class_id,db):
if r:
return [{'emp_id':i.emp_id
,'stu_id': i.stu_id
,'stu_name':i.stu_name
,'class_id':i.class_id
,'stu_name':i.Student_Model.stu_name
,'class_id':i.Student_Model.class_id
,'email':i.email
,'employment_opening_date':i.employment_opening_date
,'offer_issuance_date':i.offer_issuance_date
@@ -32,14 +31,39 @@ def get_employment_dao(stu_id,class_id,db):
except:
raise HTTPException(status_code=404,detail='信息不存在!')
def add_employment_dao(e:EmploymentRequest,db):
def add_emp_dao(o,db):
try:
d = e.model_dump()
e1 = Employment_info(**d)
e1 = Employment_info(**o)
db.add(e1)
except:
db.rollback()
raise HTTPException(status_code=404, detail='信息不存在!')
else:
db.commit()
return e1
except Exception as e:
db.rollback()
raise HTTPException(status_code=500, detail=f'新增就业信息失败: {e}')
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 update_emp_dao(emp_id,o,db):
try:
rows = db.query(Employment_info).filter(Employment_info.emp_id == emp_id,Employment_info.delete_status == 0).first()
db.commit()
return rows
except:
db.rollback()
raise HTTPException(status_code=404,detail='该就业记录已存在')
def delete_emp_dao(emp_id,db):
try:
rows = db.query(Employment_info).filter(Employment_info.emp_id == emp_id,Employment_info.delete_status == 0).delete()
db.commit()
except:
db.rollback()
rows = 0
finally:
return rows