Merge remote-tracking branch 'origin/conding' into conding
This commit is contained in:
@@ -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=None,class_id=None,company_name=None,min_salary=None,max_salary=None,db=None):
|
||||
try:
|
||||
q = db.query(Employment_info).\
|
||||
join(Student_Model,Employment_info.stu_id == Student_Model.stu_id).\
|
||||
@@ -11,16 +10,24 @@ def get_employment_dao(stu_id,class_id,db):
|
||||
filter(Employment_info.delete_status == 0).\
|
||||
filter(Student_Model.delete_status == 0).\
|
||||
filter(ClassManagement.delete_status == 0)
|
||||
if stu_id is not None:
|
||||
if stu_id:
|
||||
q = q.filter(Employment_info.stu_id == stu_id)
|
||||
if class_id is not None:
|
||||
if class_id:
|
||||
q = q.filter(ClassManagement.class_id == class_id)
|
||||
if company_name:
|
||||
q = q.filter(Employment_info.company_name == company_name)
|
||||
if min_salary:
|
||||
q = q.filter(Employment_info.salary >= min_salary)
|
||||
if max_salary:
|
||||
q = q.filter(Employment_info.salary <= max_salary)
|
||||
|
||||
r = q.all()
|
||||
|
||||
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 +39,36 @@ 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 update_emp_dao(stu_id,o,db):
|
||||
try:
|
||||
rows = db.query(Employment_info).filter(Employment_info.stu_id == stu_id,Employment_info.delete_status == 0).first()
|
||||
db.commit()
|
||||
return rows
|
||||
except:
|
||||
db.rollback()
|
||||
raise HTTPException(status_code=404,detail='该就业记录已存在')
|
||||
|
||||
|
||||
def delete_emp_dao(stu_id,db):
|
||||
try:
|
||||
rows = db.query(Employment_info).filter(Employment_info.stu_id == stu_id,Employment_info.delete_status == 0).delete()
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
rows = 0
|
||||
finally:
|
||||
return rows
|
||||
|
||||
@@ -4,11 +4,22 @@ from util.database import get_db
|
||||
|
||||
from model.all_model import *
|
||||
|
||||
# 根据id查询单条有效成绩
|
||||
def get_score_by_id_dao(score_id:int, db):
|
||||
return db.query(WlScore).filter(
|
||||
WlScore.id == score_id
|
||||
,WlScore.delete_status==1
|
||||
).first()
|
||||
|
||||
# 根据stu_id+exam_order查重(新增、修改时校验重复)
|
||||
def get_score_by_stu_exam_order_dao(stu_id:str,exam_order:int,db):
|
||||
return db.query(WlScore).filter(WlScore.stu_id==stu_id,WlScore.exam_order==exam_order,WlScore.delete_status==0).first()
|
||||
|
||||
def get_grade_dao( stu_id:int , db):
|
||||
|
||||
r1 =db.query(WlScore).filter(WlScore.stu_id == stu_id,WlScore.delete_status == 0).all()
|
||||
if r1:
|
||||
|
||||
return r1
|
||||
else:
|
||||
raise HTTPException(status_code=404,detail="学生不存在")
|
||||
@@ -21,15 +32,15 @@ def add_grade_dao(g,db):
|
||||
return o1
|
||||
except Exception:
|
||||
db.rollback()
|
||||
return None
|
||||
raise HTTPException(status_code=500,detail="学生添加失败")
|
||||
|
||||
def update_grade_dao(score_id:int, update_data, db):
|
||||
try:
|
||||
rows = db.query(WlScore).filter(
|
||||
WlScore.stu_id == score_id,
|
||||
WlScore.score_id == score_id,
|
||||
WlScore.delete_status == 0
|
||||
).update(update_data)
|
||||
except:
|
||||
except Exception:
|
||||
db.rollback()
|
||||
return False
|
||||
else:
|
||||
|
||||
@@ -12,7 +12,6 @@ def select_age(min_age,max_age,db):
|
||||
db = db.filter(Student_Model.age >= min_age,Student_Model.delete_status == 0)
|
||||
if max_age is not None:
|
||||
db = db.filter(Student_Model.age <= max_age,Student_Model.delete_status == 0)
|
||||
print('abc',db.all())
|
||||
return db.all()
|
||||
except HTTPException:
|
||||
raise
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
from fastapi import HTTPException,Depends
|
||||
from schema.teacher_schema import Teacher_RequestModel
|
||||
from model.all_model import *
|
||||
from fastapi import HTTPException
|
||||
from model.all_model import Teacher_Model
|
||||
|
||||
def add_teacher(teacher,session):
|
||||
try:
|
||||
print(teacher)
|
||||
x=Teacher_Model(**teacher)
|
||||
session.add(x)
|
||||
session.commit()
|
||||
|
||||
Reference in New Issue
Block a user