Merge remote-tracking branch 'origin/conding' into conding

This commit is contained in:
test1
2026-09-22 10:54:43 +08:00
9 changed files with 61 additions and 63 deletions
+18 -8
View File
@@ -1,7 +1,8 @@
from fastapi import HTTPException
from fastapi import HTTPException, APIRouter
from model.all_model import Employment_info, ClassManagement, Student_Model
from datetime import datetime
emp_api = APIRouter()
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).\
@@ -41,18 +42,25 @@ def get_emp_dao(stu_id=None,class_id=None,company_name=None,min_salary=None,max_
def add_emp_dao(o,db):
try:
stu = db.query(Student_Model).filter(Student_Model.stu_id == o['stu_id'], Student_Model.delete_status == 0).first()
if not stu:
raise HTTPException(status_code=404, detail='该学生不存在,无法添加就业信息')
exist = db.query(Employment_info).filter(Employment_info.stu_id == o['stu_id'],
Employment_info.delete_status == 0).first()
if exist:
raise HTTPException(status_code=409, detail='该学生已有就业信息,请勿重复增加!')
e1 = Employment_info(**o)
db.add(e1)
db.commit()
return e1
return o
except HTTPException:
raise
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()
@@ -65,7 +73,9 @@ def update_emp_dao(stu_id,o,db):
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()
rows = db.query(Employment_info)\
.filter(Employment_info.stu_id == stu_id,Employment_info.delete_status == 0)\
.update({'delete_status':1,'delete_time': datetime.now()})
db.commit()
except:
db.rollback()
+6 -4
View File
@@ -7,13 +7,15 @@ 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
WlScore.score_id == score_id
,WlScore.delete_status==0
).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()
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):
@@ -52,7 +54,7 @@ def delete_grade_dao(stu_id:int,db):
rows = db.query(WlScore).filter(
WlScore.stu_id == stu_id,
WlScore.delete_status == 0
).update({'delete_status':1})
).update({'delete_status':1,'delete_time':datetime.now()})
except:
db.rollback()
return False
+4 -2
View File
@@ -28,12 +28,14 @@ def delete_student_dao(stu_id,db):
def update_student_dao(stu_id,update_data,db):
try:
rows = db.query( Student_Model ).filter( Student_Model.stu_id == stu_id,Student_Model.delete_status == 0).update( update_data )
rows = (db.query( Student_Model )
.filter( Student_Model.stu_id == stu_id,Student_Model.delete_status == 0)
.update( update_data ))
db.commit()
except:
db.rollback()
return False
else:
db.commit()
return rows
def get_student_dao(stu_id:Optional[int]