diff --git a/PythonProject/api/cla_api.py b/PythonProject/api/cla_api.py index f061525..d0e5109 100644 --- a/PythonProject/api/cla_api.py +++ b/PythonProject/api/cla_api.py @@ -3,7 +3,7 @@ from util.database import get_db from schema.cla_schema import claRequest from dao.cla_dao import add_class_dao,get_class_dao,update_class_dao,delete_class_dao -claAPI = APIRouter(prefix="/class", tags=["班级管理"]) +claAPI = APIRouter(prefix="/class", tags=["班级管理模块"]) @claAPI.post("/", summary="新增班级信息") def add_class(data: claRequest, Session = Depends(get_db)): diff --git a/PythonProject/api/grade_api.py b/PythonProject/api/grade_api.py index 6cbce56..f1988c8 100644 --- a/PythonProject/api/grade_api.py +++ b/PythonProject/api/grade_api.py @@ -5,7 +5,7 @@ from dao.grade_dao import * from schema.grade_schema import * from fastapi import APIRouter, Depends, HTTPException, Body -gradeAPI = APIRouter(tags=['学生考核成绩']) +gradeAPI = APIRouter(tags=['学生考核成绩管理模块']) @gradeAPI.get("/grade/{stu_id}",response_model=list[GradeResponse],summary="根据学生id查询成绩") def get_grade(stu_id: int,db=Depends(get_db)): diff --git a/PythonProject/api/statistics_api.py b/PythonProject/api/statistics_api.py index f82bdd3..bb256cc 100644 --- a/PythonProject/api/statistics_api.py +++ b/PythonProject/api/statistics_api.py @@ -35,7 +35,7 @@ def get_days(db=Depends(get_db)): l = select_avg_days(db) return l -@StatisticsAPI.get('/emp',response_model=AllEmpResponse,summary='统计每个学生的就业时长') +@StatisticsAPI.get('/emp',response_model=list[AllDayResponse],summary='统计每个学生的就业时长') def get_emp(db=Depends(get_db)): l= select_days(db) return l diff --git a/PythonProject/api/student_api.py b/PythonProject/api/student_api.py index 3ef4333..57676e7 100644 --- a/PythonProject/api/student_api.py +++ b/PythonProject/api/student_api.py @@ -4,7 +4,7 @@ from schema.student_schema import * from util.database import get_db -StudentAPI = APIRouter(tags=['学⽣基本信息管理模块']) +StudentAPI = APIRouter(tags=['学生基本信息管理模块']) @StudentAPI.get('/students',response_model=StudentPageResponse,summary='学生信息查询接口',description='查询学生信息') def get_students(stu_id:int|None=None diff --git a/PythonProject/dao/statistics_dao.py b/PythonProject/dao/statistics_dao.py index 0675ebc..c576206 100644 --- a/PythonProject/dao/statistics_dao.py +++ b/PythonProject/dao/statistics_dao.py @@ -124,18 +124,11 @@ def select_avg_days(db): #统计每个学⽣的就业时⻓ def select_days(db): try: - l2 =db.query( - Employment_info.stu_id - ,Employment_info.employment_opening_date - ,Employment_info.offer_issuance_date - ,func.datediff( - Employment_info.offer_issuance_date - ,Employment_info.employment_opening_date - ) - .label("employment_duration_day") - ).filter( - Employment_info.delete_status == 0 - ).all() + l2 =db.query(Employment_info.stu_id + ,func.coalesce(func.datediff(Employment_info.offer_issuance_date + ,Employment_info.employment_opening_date),0)\ + .label("diff_days") + ).filter(Employment_info.delete_status == 0).all() return l2 except Exception: raise HTTPException(status_code=500, detail="查询异常") \ No newline at end of file diff --git a/PythonProject/main.py b/PythonProject/main.py index 3b07189..3474b17 100644 --- a/PythonProject/main.py +++ b/PythonProject/main.py @@ -5,7 +5,16 @@ from api.statistics_api import StatisticsAPI from api.teacher_api import teacher_api from api.grade_api import gradeAPI from api.cla_api import claAPI -app = FastAPI(title='沃林学⽣管理系统') + +tags_metadata = [ + {"name": "教师基本信息管理模块"}, + {"name": "班级管理模块"}, + {"name": "学生基本信息管理模块"}, + {"name": "学生考核成绩管理模块"}, + {"name": "学生就业管理模块"}, + {"name": "统计分析模块"}, +] +app = FastAPI(title='沃林学⽣管理系统',openapi_tags=tags_metadata) app.include_router(StudentAPI) diff --git a/PythonProject/schema/statistics_schema.py b/PythonProject/schema/statistics_schema.py index 028cd91..dbd532d 100644 --- a/PythonProject/schema/statistics_schema.py +++ b/PythonProject/schema/statistics_schema.py @@ -65,14 +65,9 @@ class AvgDayResponse(BaseModel): class_id: int avg_days: float | None -class EmpItem(BaseModel): +class AllDayResponse(BaseModel): + code:int = 200 + detail:str = 'ok' stu_id: int - employment_opening_date:date | None - offer_issuance_date:date | None - employment_duration_day: int | None - -class AllEmpResponse(BaseModel): - code: int - msg: str - data: List[EmpItem] + diff_days: int | None