forked from wolin_ck666_999/StuManagerSys
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42832b42c8 |
+45
-45
@@ -1,45 +1,45 @@
|
|||||||
from dao import get_db
|
from dao import get_db
|
||||||
from schema import Test
|
from schema import Test
|
||||||
from fastapi import APIRouter,Depends
|
from fastapi import APIRouter,Depends
|
||||||
from dao import a,a1,a2,a3,a4,a5
|
from dao import a,a1,a2,a3,a4,a5
|
||||||
|
|
||||||
ScoreAPI=APIRouter()
|
ScoreAPI=APIRouter()
|
||||||
ScoreAPI1=APIRouter()
|
ScoreAPI1=APIRouter()
|
||||||
@ScoreAPI.post('/scores',tags=['增'])
|
@ScoreAPI.post('/scores',tags=['增'])
|
||||||
def scores(s:Test,db=Depends(get_db)):
|
def scores(s:Test,db=Depends(get_db)):
|
||||||
a(s,db)
|
a(s,db)
|
||||||
return {'code':200,'detail':'添加成功!',}
|
return {'code':200,'detail':'添加成功!',}
|
||||||
@ScoreAPI.delete('/scores',tags=['删'])
|
@ScoreAPI.delete('/scores',tags=['删'])
|
||||||
def scores1(stu_id:int,db=Depends(get_db)):
|
def scores1(stu_id:int,db=Depends(get_db)):
|
||||||
r = a1(stu_id,db)
|
r = a1(stu_id,db)
|
||||||
if r==0:
|
if r==0:
|
||||||
return '没有该学生'
|
return '没有该学生'
|
||||||
else:
|
else:
|
||||||
return f'已删除学生编号为{stu_id}的学生'
|
return f'已删除学生编号为{stu_id}的学生'
|
||||||
@ScoreAPI.put('/scores',tags=['改'])
|
@ScoreAPI.put('/scores',tags=['改'])
|
||||||
def scores2(stu_id:int,exam_seq:int,s:Test,db=Depends(get_db)):
|
def scores2(stu_id:int,exam_seq:int,s:Test,db=Depends(get_db)):
|
||||||
r=a2(stu_id,exam_seq,s,db)
|
r=a2(stu_id,exam_seq,s,db)
|
||||||
if r!=0:
|
if r!=0:
|
||||||
return '更新成功'
|
return '更新成功'
|
||||||
else:
|
else:
|
||||||
return '没有该数据'
|
return '没有该数据'
|
||||||
@ScoreAPI.get('/scores',tags=['查'])
|
@ScoreAPI.get('/scores',tags=['查'])
|
||||||
def Scores3(stu_id:int,exam_seq:int,db=Depends(get_db)):
|
def Scores3(stu_id:int,exam_seq:int,db=Depends(get_db)):
|
||||||
r=a3(stu_id,exam_seq,db)
|
r=a3(stu_id,exam_seq,db)
|
||||||
try:
|
try:
|
||||||
return {'成绩编号':r.id,'学生编号':r.stu_id,f'第{exam_seq}次成绩:':r.score,'创建日期':r.create_date,'更新日期':r.update_date}
|
return {'成绩编号':r.id,'学生编号':r.stu_id,f'第{exam_seq}次成绩:':r.score,'创建日期':r.create_date,'更新日期':r.update_date}
|
||||||
except:
|
except:
|
||||||
return '没有该学生'
|
return '没有该学生'
|
||||||
@ScoreAPI1.put('/scores/{stu_id}',tags=['软删除'])
|
@ScoreAPI1.put('/scores/{stu_id}',tags=['软删除'])
|
||||||
def scores4(stu_id:int,exam_seq:int,db=Depends(get_db)):
|
def scores4(stu_id:int,exam_seq:int,db=Depends(get_db)):
|
||||||
r=a4(stu_id, exam_seq, db)
|
r=a4(stu_id, exam_seq, db)
|
||||||
if r ==0:
|
if r ==0:
|
||||||
return '没有该数据'
|
return '没有该数据'
|
||||||
else:
|
else:
|
||||||
return '已删除'
|
return '已删除'
|
||||||
@ScoreAPI1.get('/scores/{stu_id}',tags=['总分,平均分,最大值,最小值'])
|
@ScoreAPI1.get('/scores/{stu_id}',tags=['总分,平均分,最大值,最小值'])
|
||||||
def scores5(stu_id:int,db=Depends(get_db)):
|
def scores5(stu_id:int,db=Depends(get_db)):
|
||||||
s,r,a=a5(stu_id,db)
|
s,r,a=a5(stu_id,db)
|
||||||
|
|
||||||
return f'总分:{s},平均分:{s/len(r)},最大值:{max(a)},最小值:{min(a)}'
|
return f'总分:{s},平均分:{round(s/len(r))},最大值:{max(a)},最小值:{min(a)}'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user