Files
2026-09-21 17:39:16 +08:00

52 lines
3.1 KiB
Python

from fastapi import FastAPI,APIRouter,Depends
from schemas.analysis import (AnalysisStudentInfoAge,AnalysisStudent_score,AnalysisStudent_score60
,AnalysisStudent_score_class,AnalysisStudent_employments_salary)
from dao.analysis import (student_info_age,student_info_class,student_score,student_score_class,student_employments_salary
,student_employments_time,student_employments_class_time,student_score60)
from database import get_db
from sqlalchemy.orm import Session
router = APIRouter(prefix="/analysis", tags=["统计分析"])
#动态年龄范围查询:支持用户输入年龄阈值及比较条件(如大于、小于、等于、区间等),动态查询符合条件的学员信息
@router.get("/studnet_info/age",summary="动态年龄范围查询")
async def student_info_age1(student:AnalysisStudentInfoAge = Depends(),db: Session = Depends(get_db)):
return student_info_age(db, student.min_age, student.max_age, student.operator)
#多维度班级统计:统计每个班级的总人数,以及按性别(男、女)细分的人数分布
@router.get("/studnet_info/class",summary="多维度班级统计")
async def student_info_class1(db: Session = Depends(get_db)):
return student_info_class(db)
#查询每次考试成绩都在输入分数线(如80分)以上的学生的编号、姓名和成绩。
@router.get("/studnet_score",summary="查询每次考试成绩都在输入分数线以上的学生")
async def student_score1(s_n:AnalysisStudent_score = Depends(),db: Session = Depends(get_db)):
return student_score(db,s_n.s_n)
#查询有输入指定次数(如两次(包含两次))以上不及格的学生的姓名、班级和不及格成绩明细。
@router.get("/studnet_score60",summary="查询有输入指定次数(如两次(包含两次))以上不及格的学生")
async def student_score60_1(n:AnalysisStudent_score60 = Depends(),db: Session = Depends(get_db)):
return student_score60(db,n.n)
#统计每次考试每个班级的平均分,并支持按分数从高到低或从低到高动态排序。
@router.get("/studnet_score_class",summary="统计每次考试每个班级的平均分")
async def student_score_class1(order:AnalysisStudent_score_class = Depends(),db: Session = Depends(get_db)):
return student_score_class(db,order.order)
#查询查询就业薪资排名前n的学生
@router.get("/studnet_employments_salary",summary="查询查询就业薪资排名前n的学生")
async def student_employments_salary1(n:AnalysisStudent_employments_salary = Depends(),db: Session = Depends(get_db)):
return student_employments_salary(db,n.n)
#统计每个学生的就业时长
@router.get("/studnet_employments_time",summary="每个学生的就业时长(天)")
async def student_employments_time1(db: Session = Depends(get_db)):
return student_employments_time(db)
#统计每个班级的平均就业时长(仅统计进入就业阶段,即有就业开放时间的学生)
@router.get("/studnet_employments_class_time",summary="每个班级的平均就业时长(天)")
async def student_employments_class_time1(db: Session = Depends(get_db)):
return student_employments_class_time(db)