This commit is contained in:
maruizhi
2026-09-22 12:00:00 +08:00
parent d650cfe928
commit d270bd7ad1
3 changed files with 18 additions and 18 deletions
+8 -8
View File
@@ -3,39 +3,39 @@ from dao.statistics_dao import *
from schema.statistics_schema import *
from util.database import get_db
StatisticsAPI = APIRouter()
StatisticsAPI = APIRouter(tags=['统计分析模块'])
@StatisticsAPI.get("/age",response_model=list[StudentResponse],tags=['统计分析模块'],summary='根据年龄查询学生信息')
@StatisticsAPI.get("/age",response_model=list[StudentResponse],summary='根据年龄查询学生信息')
def get_students(min_age:int|None=Query(None,ge=0,le=150),max_age:int|None=Query(None,ge=0,le=150),db=Depends(get_db)):
l = select_age(min_age,max_age,db)
return l
@StatisticsAPI.get("/all",response_model=list[AllStuResponse],tags=['统计分析模块'],summary='统计每个班级的学员总数和男女生总数')
@StatisticsAPI.get("/all",response_model=list[AllStuResponse],summary='统计每个班级的学员总数和男女生总数')
def get_students(db=Depends(get_db)):
l = select_all(db)
return l
@StatisticsAPI.get("/score",response_model=list[GetScoreResponse],tags=['统计分析模块'],summary='根据成绩查询学生信息')
@StatisticsAPI.get("/score",response_model=list[GetScoreResponse],summary='根据成绩查询学生信息')
def get_students(min_score:int|None=None,max_score:int|None=None,db=Depends(get_db)):
l = select_score(min_score,max_score,db)
return l
@StatisticsAPI.get("/avg_score",response_model=list[AcgScoreResponse],tags=['统计分析模块'],summary='统计每次考试每个班级的平均分并排序')
@StatisticsAPI.get("/avg_score",response_model=list[AcgScoreResponse],summary='统计每次考试每个班级的平均分并排序')
def get_scores(db=Depends(get_db)):
l = select_avg_score(db)
return l
@StatisticsAPI.get("/salary",response_model=list[GetStuResponse],tags=['统计分析模块'],summary='统计薪资最高的前五名的学员信息')
@StatisticsAPI.get("/salary",response_model=list[GetStuResponse],summary='统计薪资最高的前五名的学员信息')
def get_scores(db=Depends(get_db)):
l = select_salary(db)
return l
@StatisticsAPI.get("/avg_day",response_model=list[AvgDayResponse],tags=['统计分析模块'],summary='统计每个班级的平均就业时长')
@StatisticsAPI.get("/avg_day",response_model=list[AvgDayResponse],summary='统计每个班级的平均就业时长')
def get_days(db=Depends(get_db)):
l = select_avg_days(db)
return l
@StatisticsAPI.get('/emp',response_model=AllEmpResponse,tags=['统计分析模块'],summary='统计每个学生的就业时长')
@StatisticsAPI.get('/emp',response_model=AllEmpResponse,summary='统计每个学生的就业时长')
def get_emp(db=Depends(get_db)):
l= select_days(db)
return l
+5 -5
View File
@@ -4,9 +4,9 @@ from schema.student_schema import *
from util.database import get_db
StudentAPI = APIRouter()
StudentAPI = APIRouter(tags=['学⽣基本信息管理模块'])
@StudentAPI.get('/students',response_model=StudentPageResponse,tags=['学⽣基本信息管理模块'],summary='学生信息查询接口',description='查询学生信息')
@StudentAPI.get('/students',response_model=StudentPageResponse,summary='学生信息查询接口',description='查询学生信息')
def get_students(stu_id:int|None=None
,stu_name:str|None=None
,class_id:int|None=None
@@ -27,7 +27,7 @@ def get_students(stu_id:int|None=None
totals=total,
data=r)
@StudentAPI.put('/{stu_id}',tags=['学⽣基本信息管理模块'],summary='学生信息更新接口',description='更新学生信息')
@StudentAPI.put('/{stu_id}',summary='学生信息更新接口',description='更新学生信息')
def update_students(s:StudentRequest
,stu_id:int
,db=Depends(get_db)):
@@ -39,7 +39,7 @@ def update_students(s:StudentRequest
raise HTTPException(status_code=500, detail='没有更新!')
return {'code':200,'totals':r,'detail':'更新成功'}
@StudentAPI.delete('/{stu_id}',tags=['学⽣基本信息管理模块'],summary='学生信息删除接口',description='删除学生信息')
@StudentAPI.delete('/{stu_id}',summary='学生信息删除接口',description='删除学生信息')
def del_students(stu_id:int
,db=Depends(get_db)):
rows=delete_student_dao( stu_id=stu_id,db=db )
@@ -47,7 +47,7 @@ def del_students(stu_id:int
raise HTTPException(status_code=404,detail='对象已被删除')
return {'code':200,'totals':rows,'detail':'删除成功'}
@StudentAPI.post('/students',tags=['学⽣基本信息管理模块'],response_model=StugetResponse,summary='学生信息新增接口',description='新增学生信息')
@StudentAPI.post('/students',response_model=StugetResponse,summary='学生信息新增接口',description='新增学生信息')
def add_students(s:StudentRequest
,db=Depends(get_db)):
d=s.model_dump(exclude_unset=True)
+5 -5
View File
@@ -6,16 +6,16 @@ from dao.teacher_dao import update_teacher
from dao.teacher_dao import delete_teacher
from dao.teacher_dao import get_teacher
teacher_api=APIRouter()
teacher_api=APIRouter(tags=['教师基本信息管理模块'])
@teacher_api.post("/teachers",response_model=Teacher_ResponseModel,tags=['教师基本信息管理模块'],summary='新增教师接口')
@teacher_api.post("/teachers",response_model=Teacher_ResponseModel,summary='新增教师接口')
def add_teacher1(x1:Teacher_RequestModel,session=Depends(get_db)):
y=add_teacher(x1.model_dump(),session)
if not y:
raise HTTPException(status_code=500,detail='添加异常!')
return x1
@teacher_api.get("/teachers",tags=['教师基本信息管理模块'],summary='查询教师接口')
@teacher_api.get("/teachers",summary='查询教师接口')
def get_teacher1(teacid:int, session=Depends(get_db)):
# r = get_teacher(id=id,session=session)
# if not r:
@@ -27,7 +27,7 @@ def get_teacher1(teacid:int, session=Depends(get_db)):
raise HTTPException(status_code=500,detail='数据库查询异常!')
@teacher_api.put("/teachers/{t_id}",tags=['教师基本信息管理模块'],summary='更新教师接口')
@teacher_api.put("/teachers/{t_id}",summary='更新教师接口')
def update_teacher1(t_id:int,teacher:Teacher_RequestModel,session=Depends(get_db)):
d=teacher.model_dump(exclude_unset=True)
r=update_teacher(id=t_id,req=d,session=session)
@@ -36,7 +36,7 @@ def update_teacher1(t_id:int,teacher:Teacher_RequestModel,session=Depends(get_db
return {'code':200,'detail':'更新成功!','data':teacher}
@teacher_api.delete("/teachers/{t_id}",tags=['教师基本信息管理模块'],summary='删除教师接口')
@teacher_api.delete("/teachers/{t_id}",summary='删除教师接口')
def delete_teacher1(t_id:int,session=Depends(get_db)):
r=delete_teacher(id=t_id,session=session)
if not r: