外键
This commit is contained in:
@@ -13,13 +13,13 @@ def get_scores_dao(s,db):
|
||||
ab = ab.filter(Score.num==s.get('num'))
|
||||
if s.get('score'):
|
||||
ab = ab.filter(Score.score==s.get('score'))
|
||||
if s.get('tsub'):
|
||||
ab = ab.filter(Score.tsub==s.get('tsub'))
|
||||
if s.get('t_subject'):
|
||||
ab = ab.filter(Score.t_subject==s.get('t_subject'))
|
||||
aa = ab.all()
|
||||
if aa:
|
||||
return [{'id':i.id,'sid':i.sid
|
||||
,'cid':i.cid,'num':i.num
|
||||
,'score': i.score,'tsub':i.tsub
|
||||
,'score': i.score,'t_subject':i.tsub
|
||||
,'create_date':i.create_date,'update_date':i.update_date
|
||||
,'is_deleted': i.is_deleted,'deleted_date': i.deleted_date
|
||||
}for i in aa]
|
||||
@@ -29,7 +29,7 @@ def get_scores_dao(s,db):
|
||||
def add_scores_dao(b,db):
|
||||
try:
|
||||
aa = db.query(Score).filter(Score.sid==b['sid']
|
||||
,Score.tsub==b['tsub']).all()
|
||||
,Score.t_subject==b['t_subject']).all()
|
||||
if aa:
|
||||
raise ValueError
|
||||
else:
|
||||
@@ -43,7 +43,7 @@ def add_scores_dao(b,db):
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
def update_scores_dao(sid:int,cid:int,num:int,tsub:str,update_data:dict,db):
|
||||
def update_scores_dao(sid:int,cid:int,num:int,t_subject:int,update_data:dict,db):
|
||||
if not update_data:
|
||||
return 0
|
||||
update_data['update_date']=datetime.now()
|
||||
@@ -51,7 +51,7 @@ def update_scores_dao(sid:int,cid:int,num:int,tsub:str,update_data:dict,db):
|
||||
aa = db.query(Score).filter(Score.sid == sid
|
||||
,Score.cid == cid
|
||||
,Score.num == num
|
||||
,Score.tsub == tsub ).update(update_data)
|
||||
,Score.t_subject == t_subject ).update(update_data)
|
||||
db.commit()
|
||||
return aa
|
||||
except Exception :
|
||||
@@ -59,11 +59,11 @@ def update_scores_dao(sid:int,cid:int,num:int,tsub:str,update_data:dict,db):
|
||||
return -1
|
||||
|
||||
|
||||
def delete_scores_dao(sid:int,cid:int,tsub:str,db):
|
||||
def delete_scores_dao(sid:int,cid:int,t_subject:int,db):
|
||||
try:
|
||||
aaa = db.query(Score).filter(Score.sid ==sid
|
||||
,Score.cid == cid
|
||||
,Score.tsub == tsub
|
||||
,Score.t_subject == t_subject
|
||||
,Score.is_deleted==0
|
||||
).update({'is_deleted':1
|
||||
,'deleted_date':datetime.now()})
|
||||
|
||||
Reference in New Issue
Block a user