整体bug修改。
This commit is contained in:
@@ -9,7 +9,7 @@ def add_tea_dao(t,db):
|
||||
not_delete = db.query(Tea).filter(Tea.phone ==t.get('phone'),Tea.is_delete == False).first()
|
||||
if not_delete:
|
||||
print('该老师已存在')
|
||||
raise Exception('老师已存在')
|
||||
raise Exception('该老师已存在,不可重复添加')
|
||||
existing = db.query(Tea).filter(Tea.phone == t.get('phone'),Tea.is_delete == True).first()
|
||||
if existing:
|
||||
for key,value in t.items():
|
||||
@@ -19,11 +19,11 @@ def add_tea_dao(t,db):
|
||||
#将value的值赋值到existing的key中,配合循环,让所有输入的信息都覆盖原信息
|
||||
existing.is_delete = False
|
||||
db.commit()
|
||||
return '恢复修改成功'
|
||||
return '新增成功-修订数据'
|
||||
t1 = Tea(**t)
|
||||
db.add(t1)
|
||||
db.commit()
|
||||
return True
|
||||
return '新增成功'
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
print('新增失败原因',e)
|
||||
|
||||
Reference in New Issue
Block a user