更改新增dao bug

This commit is contained in:
2026-09-22 23:01:59 +08:00
committed by geyuan
parent f2e525b5a5
commit 6e189d0c65
2 changed files with 10 additions and 3 deletions
@@ -4,6 +4,12 @@ from sqlalchemy.orm import Session
#新增班级 #新增班级
def add_class_dao(c,db): def add_class_dao(c,db):
try: try:
exist_class = db.query(ClassInfo).filter(
ClassInfo.num == c["num"],
ClassInfo.is_delete == 0
).first()
if exist_class:
return False
c1 = ClassInfo(**c) c1 = ClassInfo(**c)
db.add(c1) db.add(c1)
except: except:
@@ -11,6 +17,7 @@ def add_class_dao(c,db):
return False return False
else: else:
db.commit() db.commit()
db.refresh(c1)
return True return True
@@ -22,16 +22,16 @@ class ClassInfo(Base_all):
,comment='班级名称' ,comment='班级名称'
) )
head_teacher_id = Column(Integer head_teacher_id = Column(Integer
,ForeignKey('teacher.id') ,ForeignKey('teachers.id')
,comment='班主任编号' ,comment='班主任编号'
) )
coach_teacher_id = Column(Integer coach_teacher_id = Column(Integer
,ForeignKey('teacher.id') ,ForeignKey('teachers.id')
,comment='授课老师编号' ,comment='授课老师编号'
) )
tutor_teacher_id = Column(Integer tutor_teacher_id = Column(Integer
,ForeignKey('teacher.id') ,ForeignKey('teachers.id')
,comment='助教老师编号' ,comment='助教老师编号'
) )
class_start_time = Column(Date class_start_time = Column(Date