上传文件至「dao」
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
from model import Session
|
||||
from model import Scores
|
||||
def get_db():
|
||||
db = Session()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
# @ScoreAPI.post('/scores')
|
||||
def a(s,db):
|
||||
d = s.model_dump()
|
||||
o = Scores(**d)
|
||||
db.add(o)
|
||||
db.commit()
|
||||
# @ScoreAPI.delete('/scores')
|
||||
def a1(stu_id,db):
|
||||
r=db.query(Scores).filter(Scores.stu_id==stu_id).delete()
|
||||
db.commit()
|
||||
return r
|
||||
# @ScoreAPI.put('/scores')
|
||||
def a2(stu_id,exam_seq,s,db):
|
||||
r = db.query(Scores).filter((Scores.stu_id == stu_id) & (Scores.exam_seq == exam_seq)).update(
|
||||
s.model_dump(exclude={'stu_id', 'exam_seq'}))
|
||||
db.commit()
|
||||
return r
|
||||
#@ScoreAPI.get('/scores')
|
||||
def a3(stu_id,exam_seq,db):
|
||||
r=db.query(Scores).filter((Scores.stu_id==stu_id)&(Scores.exam_seq==exam_seq)).first()
|
||||
return r
|
||||
# @ScoreAPI1.put('/scores/{stu_id}',tags=['软删除'])
|
||||
def a4(stu_id, exam_seq, db):
|
||||
r=db.query(Scores).filter((Scores.stu_id==stu_id)&(Scores.exam_seq==exam_seq)).update({Scores.deleted:0})
|
||||
db.commit()
|
||||
return r
|
||||
# @ScoreAPI1.get('/scores/{stu_id}',tags=['总分,平均分,最大值,最小值'])
|
||||
def a5(stu_id,db):
|
||||
r = db.query(Scores).filter((Scores.stu_id == stu_id)).all()
|
||||
s = 0
|
||||
a = []
|
||||
for i in r:
|
||||
s += i.score
|
||||
a.append(i.score)
|
||||
return s,r,a
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user