新增StatCalc文件夹,统计分析模块,初步框架搭建。
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
# statcalc_api所有统计分析模块的api路由、接口
|
||||
|
||||
from fastapi import APIRouter , Depends , HTTPException
|
||||
from StatCalc.dao.statcalc_dao import *
|
||||
from StatCalc.model.statcalc_model import *
|
||||
from StatCalc.schema.statcalc_request import *
|
||||
from databases import *
|
||||
|
||||
statcalc_api = APIRouter()
|
||||
|
||||
@statcalc_api.get("/statcalc"
|
||||
,summary='人员信息查询'
|
||||
,description=f'查询所有超过30岁的学员的信息。'
|
||||
)
|
||||
def get_students( stu:StudentsQuery = Depends()
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||
result = get_student_dao( s=s_dict , db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get("/statcalc"
|
||||
,summary='人数统计'
|
||||
,description=f'统计每个班级的人数以及男生女生的人数。'
|
||||
)
|
||||
def get_students( stu:StudentsQuery = Depends()
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||
result = get_student_dao( s=s_dict , db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get("/statcalc"
|
||||
,summary='80分以上成绩学生信息查询'
|
||||
,description=f'查询每次考试成绩都在80分以上的学生的编号,姓名和成绩。'
|
||||
)
|
||||
def get_students( stu:StudentsQuery = Depends()
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||
result = get_student_dao( s=s_dict , db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get("/statcalc"
|
||||
,summary='不及格成绩查询'
|
||||
,description=f'查询有两次以上不及格的学生的姓名,班级和不及格成绩。'
|
||||
)
|
||||
def get_students( stu:StudentsQuery = Depends()
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||
result = get_student_dao( s=s_dict , db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get("/statcalc"
|
||||
,summary='班级平均分查询'
|
||||
,description=f'统计每次考试每个班级的平均分,按照从高到低排序。'
|
||||
)
|
||||
def get_students( stu:StudentsQuery = Depends()
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||
result = get_student_dao( s=s_dict , db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get("/statcalc"
|
||||
,summary='排名前五的学生信息'
|
||||
,description=f'统计就业薪资最高的前五名学生的姓名,班级和就业时间,就业公司。'
|
||||
)
|
||||
def get_students( stu:StudentsQuery = Depends()
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||
result = get_student_dao( s=s_dict , db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get("/statcalc"
|
||||
,summary='就业时长统计'
|
||||
,description=f'统计每个学生的就业时长(offer下发时间-就业开放时间)。'
|
||||
)
|
||||
def get_students( stu:StudentsQuery = Depends()
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||
result = get_student_dao( s=s_dict , db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get("/statcalc"
|
||||
,summary='班级的平均就业时长'
|
||||
,description=f'统计每个班级的平均就业时长(只统计进入就业阶段的学生,也就是有就业开放时间)'
|
||||
)
|
||||
def get_students( stu:StudentsQuery = Depends()
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||
result = get_student_dao( s=s_dict , db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# from StatCalc.model.statcalc_model import
|
||||
from StatCalc.schema.statcalc_request import *
|
||||
from fastapi import HTTPException
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
from fastapi import FastAPI,APIRouter
|
||||
from StatCalc.api.statcalc_api import statcalc_api
|
||||
from databases import *
|
||||
from StatCalc.model import statcalc_model
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
StatCalc_API = APIRouter()
|
||||
StatCalc_API.include_router(statcalc_api)
|
||||
@@ -0,0 +1,9 @@
|
||||
# students_schema:请求、响应的模型框架
|
||||
|
||||
from pydantic import BaseModel , Field , field_validator
|
||||
from datetime import datetime
|
||||
import enum
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,24 +4,25 @@ from scores.main import Scores_API
|
||||
from stu_jiuye.main import Shtudent_Jiuye
|
||||
from students.main import Students_API
|
||||
from Teachers.main import Teachers_API
|
||||
from StatCalc.main import StatCalc_API
|
||||
from databases import *
|
||||
app = FastAPI(title="学生管理系统")
|
||||
|
||||
Base_all.metadata.create_all(bind=engine_all)
|
||||
|
||||
|
||||
app.include_router(Classes_API,tags=["classes"])
|
||||
app.include_router(Scores_API,tags=["scores"])
|
||||
app.include_router(Shtudent_Jiuye,tags=["Employments"])
|
||||
app.include_router(Students_API,tags=["students"])
|
||||
app.include_router(Teachers_API,tags=["teachers"])
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
print("Hello from student-manage-system!")
|
||||
app.include_router(StatCalc_API,tags=["StatCalc"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
print("Hello from student-manage-system!")
|
||||
|
||||
import uvicorn
|
||||
uvicorn.run("main:app", host="0.0.0.0", port=59000)
|
||||
"""
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class Employments(Base_all): #学生
|
||||
id = Column(Integer #主键,自增主键
|
||||
, primary_key=True
|
||||
, autoincrement=True
|
||||
# , ForeignKey='student.id'
|
||||
# , ForeignKey('student.id')
|
||||
, comment='自增主键'
|
||||
)
|
||||
sname = Column(String(50)) #学生姓名,冗余字段
|
||||
|
||||
Reference in New Issue
Block a user