Merge remote-tracking branch 'origin/conding' into conding
This commit is contained in:
@@ -6,14 +6,6 @@ from util.database import get_db
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
emp_api = APIRouter(tags=['学生就业管理模块'])
|
emp_api = APIRouter(tags=['学生就业管理模块'])
|
||||||
|
|
||||||
@emp_api.get('/employment/class/{stu_id}',response_model=EmploymentResponse,summary='获取学生就业信息')
|
|
||||||
def get_emp_info1(stu_id: Optional[int]=Path(description='学生编号')
|
|
||||||
,db=Depends(get_db)):
|
|
||||||
e1 = employment_dao.get_emp_dao(stu_id=stu_id, db=db)
|
|
||||||
if e1:
|
|
||||||
return e1[0]
|
|
||||||
raise HTTPException(status_code=404, detail='该学生就业信息不存在')
|
|
||||||
|
|
||||||
@emp_api.get('/employment/class/{class_id}',response_model=EmploymentResponse,summary='获取班级学生就业信息')
|
@emp_api.get('/employment/class/{class_id}',response_model=EmploymentResponse,summary='获取班级学生就业信息')
|
||||||
def get_emp_info2(class_id: Optional[int]=Path(description='班级编号')
|
def get_emp_info2(class_id: Optional[int]=Path(description='班级编号')
|
||||||
,db=Depends(get_db)):
|
,db=Depends(get_db)):
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ def get_grade(stu_id: int,db=Depends(get_db)):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=500,detail=f'数据库查询异常:{str(e)}')
|
raise HTTPException(status_code=500,detail=f'数据库查询异常:{str(e)}')
|
||||||
|
|
||||||
@gradeAPI.post('/grade',response_model=GradeResponse,summary='添加学生成绩')
|
@gradeAPI.post('/grade',summary='添加学生成绩')
|
||||||
def post_grade(o:GradeRequest,db=Depends(get_db)):
|
def post_grade(o:GradeRequest,db=Depends(get_db)):
|
||||||
d=o.model_dump()
|
d=o.model_dump()
|
||||||
r=add_grade_dao(g=d,db=db)
|
r=add_grade_dao(g=d,db=db)
|
||||||
|
|||||||
@@ -40,3 +40,8 @@ def get_days(db=Depends(get_db)):
|
|||||||
def get_emp(db=Depends(get_db)):
|
def get_emp(db=Depends(get_db)):
|
||||||
l= select_days(db)
|
l= select_days(db)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
@StatisticsAPI.get('/salaries',summary='统计薪资分布')
|
||||||
|
def get_salaries(db=Depends(get_db)):
|
||||||
|
s=classify_salary(db)
|
||||||
|
return s
|
||||||
@@ -132,3 +132,25 @@ def select_days(db):
|
|||||||
return l2
|
return l2
|
||||||
except Exception:
|
except Exception:
|
||||||
raise HTTPException(status_code=500, detail="查询异常")
|
raise HTTPException(status_code=500, detail="查询异常")
|
||||||
|
|
||||||
|
|
||||||
|
# 薪资区间分布:统计薪资在5k以下、5k-10k、10k-15k、15k以上的人数分布,反映学生的整体就业质量。
|
||||||
|
def classify_salary(db):
|
||||||
|
try:
|
||||||
|
a=b=c=d=0
|
||||||
|
l=db.query(Employment_info).filter(Employment_info.delete_status==0).all()
|
||||||
|
for i in l:
|
||||||
|
if i.salary is None:
|
||||||
|
continue
|
||||||
|
elif i.salary<5000:
|
||||||
|
a+=1
|
||||||
|
elif 5000<=i.salary<10000:
|
||||||
|
b+=1
|
||||||
|
elif 10000<=i.salary<15000:
|
||||||
|
c+=1
|
||||||
|
else:
|
||||||
|
d+=1
|
||||||
|
return {'5k以下': a, '5k-10k': b, '10k-15k': c, '15k': d}
|
||||||
|
except:
|
||||||
|
raise HTTPException(status_code=500,detail='查询异常!')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user