新增科目增加接口

This commit is contained in:
2026-09-22 20:43:33 +08:00
parent 91d86d4ea9
commit 748b9f751c
5 changed files with 36 additions and 4 deletions
+19 -1
View File
@@ -1,4 +1,6 @@
from Teachers.model.tea_model import Tea
from sys import excepthook
from Teachers.model.tea_model import Tea,Sub
from datetime import datetime
#增加
@@ -122,3 +124,19 @@ def delete_other_tea_dao(t,db):
def add_subject_dao(t,db):
try:
t1 = db.query(Sub).filter(Sub.name == t.get('name')).first()
if t1:
print('科目已存在')
raise Exception('科目已存在')
s1 = Sub(**t)
db.add(s1)
db.commit()
return '添加成功'
except Exception as e:
db.rollback()
print('失败的原因',e)
return False