上传文件至「api」
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
from fastapi import APIRouter, Depends,FastAPI
|
||||
from model.teaModel import Session
|
||||
from dao.dao1 import fun1,fun2,fun3,fun4,fun5,fun6, fun7 ,fun8
|
||||
|
||||
StatsAPI = APIRouter(prefix='/stats', tags=['统计分析'])
|
||||
app = FastAPI()
|
||||
app.include_router(StatsAPI)
|
||||
def get_db():
|
||||
db=Session()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@StatsAPI.get('/age-over-30', summary='超过30岁学员')
|
||||
def stat_age(db= Depends(get_db)):
|
||||
rows = fun1(db)
|
||||
return {'code': 200, 'data':rows }
|
||||
|
||||
@StatsAPI.get('/class-gender', summary='各班人数及男女比')
|
||||
def stat_class_gender(db= Depends(get_db)):
|
||||
rows = fun2(db)
|
||||
return {'code': 200, 'data': rows}
|
||||
|
||||
@StatsAPI.get('/all-pass-80', summary='每次考试都≥80分')
|
||||
def stat_pass80(db= Depends(get_db)):
|
||||
rows = fun3(db)
|
||||
return {'code': 200, 'data': rows}
|
||||
|
||||
@StatsAPI.get('/two-fail', summary='两次以上不及格')
|
||||
def stat_fail(db= Depends(get_db)):
|
||||
rows = fun4(db)
|
||||
return {'code': 200, 'data': rows}
|
||||
|
||||
@StatsAPI.get('/avg-score', summary='各班每次考试平均分')
|
||||
def stat_avg(db= Depends(get_db)):
|
||||
rows = fun5(db)
|
||||
return {'code': 200, 'data': rows}
|
||||
|
||||
@StatsAPI.get('/top5-salary', summary='薪资前五名')
|
||||
def stat_top5(db= Depends(get_db)):
|
||||
rows = fun6(db)
|
||||
return rows
|
||||
@StatsAPI.get('/duration', summary='每个学生就业时长')
|
||||
def stat_duration(db= Depends(get_db)):
|
||||
rows = fun7(db)
|
||||
return {'code': 200, 'data': rows}
|
||||
|
||||
@StatsAPI.get('/avg-duration', summary='各班平均就业时长')
|
||||
def stat_avg_duration(db= Depends(get_db)):
|
||||
rows = fun8(db)
|
||||
return {'code': 200, 'data': rows}
|
||||
|
||||
if __name__ == '__main__':
|
||||
import uvicorn
|
||||
uvicorn.run('cxjk:app',host='127.0.0.1',port=9999)
|
||||
Reference in New Issue
Block a user