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

This commit is contained in:
2026-09-21 19:21:40 +08:00
13 changed files with 227 additions and 115 deletions
+11 -12
View File
@@ -1,30 +1,29 @@
from fastapi import FastAPI,APIRouter,Depends,HTTPException
from fastapi import APIRouter,Depends,HTTPException
from dao import employment_dao
from dao.employment_dao import get_employment_dao
from schema.employment_schema import EmlpoymentRequest,EmploymentResponse
from schema.employment_schema import EmploymentRequest,EmploymentResponse
from model.all_model import ClassManagement,Employment_info
from util.database import get_db
app = FastAPI()
@app.get('employment/students/{stu_id}',response_model=EmploymentResponse,summary='获取学生就业信息')
emp_api = APIRouter()
@emp_api.get('employment/students/{stu_id}',response_model=EmploymentResponse,summary='获取学生就业信息')
def get_emp_info1(stu_id: int,db=Depends(get_db)):
try:
if stu_id:
return employment_dao.get_employment_info()
except:
raise HTTPException(status_code=404, detail='就业信息不存在')
raise HTTPException(status_code=404, detail='该学生就业信息不存在')
@app.get('employment/class/{class_id}',summary='获取班级学生就业信息')
@emp_api.get('employment/class/{class_id}',summary='获取班级学生就业信息')
def get_emp_info2(class_id: int,db=Depends(get_db)):
try:
if class_id:
return employment_dao.get_employment_info()
except:
raise HTTPException(status_code=404, detail='就业信息不存在')
@app.post('employment/students/{stu_id}')
def create_emp_info(stu_id: int,db=Depends(get_db)):
raise HTTPException(status_code=404, detail='该班级就业信息不存在')
# @emp_api.post('employment/students/{stu_id}')
# def create_emp_info(stu_id: int,db=Depends(get_db)):
# try:
# pass
+5
View File
@@ -16,6 +16,11 @@ def get_grade(stu_id: int,db=Depends(get_db)):
@gradeAPI.post('/{stu_id}',response_model=GradeResponse,summary='添加学生成绩')
def post_grade(o:GradeRequest=Form(),db=Depends(get_db)):
exist_obj = get_grade_dao(db,o.stu_id)
if exist_obj:
raise HTTPException(status_code=409, detail="该学生此考核序次成绩已存在!")
d=o.model_dump()
r=add_grade_dao(g=d,db=db)
if not r:
+21 -5
View File
@@ -1,21 +1,37 @@
from fastapi import APIRouter,Depends
from dao.statistics_dao import select_all,select_age,select_score
from dao.statistics_dao import select_all,select_age,select_score,select_avg_score,select_salary,select_days
from schema.student_schema import StudentResponse
from schema.statistics_schema import AllStuResponse,AvgDayResponse,AcgScoreResponse
from util.database import get_db
StatisticsAPI = APIRouter()
@StatisticsAPI.get("/age",response_model=list[StudentResponse],tags=['统计分析模块'],description='根据年龄查询学生信息')
@StatisticsAPI.get("/age",response_model=list[StudentResponse],tags=['统计分析模块'],summary='根据年龄查询学生信息')
def get_students(min_age:int|None=None,max_age:int|None=None,db=Depends(get_db)):
l = select_age(min_age,max_age,db)
return l
@StatisticsAPI.get("/all",response_model=StudentResponse,tags=['统计分析模块'],description='统计每个班级的学员总数和男女生总数')
@StatisticsAPI.get("/all",response_model=list[AllStuResponse],tags=['统计分析模块'],summary='统计每个班级的学员总数和男女生总数')
def get_students(db=Depends(get_db)):
l = select_all(db)
return [i for i in l]
return l
@StatisticsAPI.get("/score",response_model=StudentResponse,tags=['统计分析模块'],description='根据成绩查询学生信息')
@StatisticsAPI.get("/score",response_model=StudentResponse,tags=['统计分析模块'],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 [i for i in l]
@StatisticsAPI.get("/avg_score",response_model=list[AcgScoreResponse],tags=['统计分析模块'],summary='统计每次考试每个班级的平均分并排序')
def get_scores(db=Depends(get_db)):
l = select_avg_score(db)
return l
@StatisticsAPI.get("/salary",response_model=list[StudentResponse],tags=['统计分析模块'],summary='统计薪资最高的前五名的学员信息')
def get_scores(db=Depends(get_db)):
l = select_salary(db)
return l
@StatisticsAPI.get("/avg_day",response_model=list[AvgDayResponse],tags=['统计分析模块'],summary='统计每个班级的平均就业时长')
def get_days(db=Depends(get_db)):
l = select_days(db)
return l
+25 -11
View File
@@ -1,28 +1,41 @@
from fastapi import APIRouter,Depends,HTTPException
from dao.student_dao import delete_student_dao,add_student_dao,update_student_dao,get_student_dao
from schema.student_schema import StudentRequest,StudentResponse,StugetResponse
from dao.student_dao import *
from schema.student_schema import *
from util.database import get_db
StudentAPI = APIRouter()
@StudentAPI.get('/',tags=['学⽣基本信息管理模块'],description='查询学生信息')
@StudentAPI.get('/',response_model=list[StudentPageResponse],tags=['学⽣基本信息管理模块'],description='查询学生信息')
def get_students(stu_id:int|None=None
,stu_name:str|None=None
,class_id:int|None=None
,db=Depends(get_db)
,page:int=1
,page_size:int=10):
r=get_student_dao(stu_id,stu_name,class_id,db,page,page_size)
if r:
return r
raise HTTPException(status_code=404,detail='学生不存在')
r, total = get_student_dao(stu_id=stu_id
,stu_name=stu_name
,class_id=class_id
,page=page
,page_size=page_size
,db=db)
if not r:
raise HTTPException(status_code=404,detail='学生不存在')
return {'code': 200
, 'detail': 'ok'
, 'page': page
, 'page_size': page_size
, 'total': total
, 'data': r}
@StudentAPI.put('/{stu_id}',tags=['学⽣基本信息管理模块'])
def update_students(s:StudentRequest
,stu_id:int
,db=Depends(get_db)):
d = s.model_dump(exclude_unset=True)
if not d:
raise HTTPException(status_code=400, detail='更新内容不能为空!')
r = update_student_dao( stu_id=stu_id,update_data=d,db=db )
if not r:
raise HTTPException(status_code=500, detail='没有更新!')
@@ -36,13 +49,14 @@ def del_students(stu_id:int
raise HTTPException(status_code=500,detail='没有删除')
return {'code':200,'totals':rows,'detail':'删除成功'}
@StudentAPI.post('/',tags=['学⽣基本信息管理模块'],response_model=list[StugetResponse])
@StudentAPI.post('/',tags=['学⽣基本信息管理模块'],response_model=StugetResponse)
def add_students(s:StudentRequest
,db=Depends(get_db)):
d=s.model_dump(exclude_unset=True)
r=add_student_dao(o=d,db=db)
if not r:
d=s.model_dump(exclude_unset=False)
stu_new=add_student_dao(o=d,db=db)
if not stu_new:
raise HTTPException(status_code=500,detail='添加失败')
return stu_new
@StudentAPI.put('/',tags=['学⽣基本信息管理模块'])