更改新增dao bug
This commit is contained in:
@@ -4,6 +4,12 @@ from sqlalchemy.orm import Session
|
||||
#新增班级
|
||||
def add_class_dao(c,db):
|
||||
try:
|
||||
exist_class = db.query(ClassInfo).filter(
|
||||
ClassInfo.num == c["num"],
|
||||
ClassInfo.is_delete == 0
|
||||
).first()
|
||||
if exist_class:
|
||||
return False
|
||||
c1 = ClassInfo(**c)
|
||||
db.add(c1)
|
||||
except:
|
||||
@@ -11,6 +17,7 @@ def add_class_dao(c,db):
|
||||
return False
|
||||
else:
|
||||
db.commit()
|
||||
db.refresh(c1)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -22,16 +22,16 @@ class ClassInfo(Base_all):
|
||||
,comment='班级名称'
|
||||
)
|
||||
head_teacher_id = Column(Integer
|
||||
,ForeignKey('teacher.id')
|
||||
,ForeignKey('teachers.id')
|
||||
,comment='班主任编号'
|
||||
)
|
||||
|
||||
coach_teacher_id = Column(Integer
|
||||
,ForeignKey('teacher.id')
|
||||
,ForeignKey('teachers.id')
|
||||
,comment='授课老师编号'
|
||||
)
|
||||
tutor_teacher_id = Column(Integer
|
||||
,ForeignKey('teacher.id')
|
||||
,ForeignKey('teachers.id')
|
||||
,comment='助教老师编号'
|
||||
)
|
||||
class_start_time = Column(Date
|
||||
|
||||
Reference in New Issue
Block a user