class Curriculum(BaseModel): __tablename__ = "curriculum" c_id = models.Column(models.String(32)) c_name = models.Column(models.String(32)) c_time = models.Column(models.Date) def __repr__(self): return self.c_name
class Teachers(BaseModel): #教师表 __tablename__ = "teacher" username = models.Column(models.String(32)) age = models.Column(models.Integer) gender = models.Column(models.String(32)) course_id = models.Column(models.Integer, models.ForeignKey("course.id")) teacher_id = models.Column(models.Integer, models.ForeignKey("user.identify_id"))
class Leave(BaseModel): __tablename__ = "leave" request_id = models.Column(models.Integer) # 请假人id request_name = models.Column(models.String(32)) # 请假人姓名 request_type = models.Column(models.String(32)) # 假期类型 start_time = models.Column(models.String(32)) # 起始时间 end_time = models.Column(models.String(32)) # 结束时间 description = models.Column(models.Text) # 请假事由 phone = models.Column(models.String(32)) # 联系方式 status = models.Column(models.Integer) # 假条状态 0 申请 1批准 2驳回 3销假
class VacationTip(BaseModel): __tablename__ = "vacationTip" vacation_id = models.Column(models.Integer) vacation_name = models.Column(models.String(32)) vacation_type = models.Column(models.String(32)) vacation_start = models.Column(models.String(32)) vacation_deadline = models.Column(models.String(32)) vacation_description = models.Column(models.Text) vacation_phone = models.Column(models.String(32)) vacation_status = models.Column(models.Integer) vacation_day = models.Column(models.Integer)
class Ask(BaseModel): __tablename__ = "ask" student_name = models.Column(models.String(32)) #请假学生姓名 reason = models.Column(models.Text) #请假原因 asktime = models.Column(models.DateTime) #请假时间 subtime = models.Column(models.DateTime) #线上申请时间 course_name = models.Column(models.String(32)) #请假课程 teacher_name = models.Column(models.String(32)) #相关课程老师 status = models.Column(models.Integer, default=0) #请假状态,0代表正在审核1代表老师批准2代表老师拒绝 student_id = models.Column(models.Integer, models.ForeignKey('students.id')) #假条与学生是多对一关系 teacher_id = models.Column(models.Integer, models.ForeignKey('teacher.id')) #假条与老师是多对易关系
class Students(BaseModel): #学生表 __tablename__ = "students" #表名称 name = models.Column(models.String(32)) age = models.Column(models.Integer) gender = models.Column(models.Integer) #0 男 1 女 2 unknown student_id = models.Column(models.Integer, models.ForeignKey("user.identify_id"))
class Teacher(Base): __tablebname__ = "teacher" name = models.Column(models.String(32)) age = models.Column(models.Integer) gender = models.Column(models.Integer, default=1) # 1 男,2 女 ,3 未知 course_id = models.Column(models.Integer, models.ForeignKey("course.id"))
class Score(Base): __tablebname__ = "score" name = models.Column(models.String(32), unique=True) course_id = models.Column(models.Integer, models.ForeignKey("course.id")) students_id = models.Column(models.Integer, models.ForeignKey("students.id"))
class Students(BaseModel): #继承BaseModel中的方法 """ 学员表 """ __tablename__ = 'students' #设置数据表的名称 name = models.Column(models.String(32)) #设置对应的字段 age = models.Column(models.Integer) gender = models.Column(models.Integer) #0男 1女 -1未知
class Students(BaseModel): """ 学员表 """ __tablename__ = "students" name = models.Column(models.String(32)) age = models.Column(models.Integer) gender = models.Column(models.Integer,default = 13) #0 男 1女 -1 unknown
class Teachers(BaseModel): """ 教师 老师与课程是多对一关系 """ __tablename__ = "teachers" name = models.Column(models.String(32)) age = models.Column(models.Integer) gender = models.Column(models.Integer,default = 3) # 0 男 1女 -1 unknown course_id = models.Column(models.Integer, models.ForeignKey("course.id")) #教师多对一 映射表是课程
class Course(Base): __tablename__ = 'course' lable = models.Column(models.String(32), unique=True) teachers = models.relationship('Teachers', backref='to_course') # 外表用这个字段,本表用backref to_student = models.relationship( 'Student', secondary=Stu_Cou, #指向多对多表 backref=models.backref('to_course_ya', lazy='dynamic'), lazy='dynamic' #不加载数据 )
class Teacher(BaseModel): """ 教师表 教师与课程多对一 """ __tablename__ = 'teachers' name = models.Column(models.String(32)) age = models.Column(models.Integer) gender = models.Column(models.Integer) #0男 1女 -1未知 course_id = models.Column(models.Integer, models.ForeignKey('course.id')) #教师,课程多对一映射
class Course(Base): __tablebname__ = "course" name = models.Column(models.String(32), unique=True) description = models.Column(models.Text) to_teacher = models.relationship("Teacher", backref="to_course_data") to_student = models.relationship("Students", secondary=Stu_Cou, backref=models.backref("to_course", lazy="dynamic"), lazy="dynamic")
class Course(BaseModel): __tablename__ = 'course' lable = models.Column(models.String(32)) description = models.Column(models.Text) to_teacher = models.relationship('Teacher', backref='to_course1') to_student = models.relationship('Student', secondary=Stu_Cou, backref=models.backref('to_course', lazy='dynamic'), lazy='dynamic')
class Students(BaseModel): __tablename__ = 'students' #学生表名 #id=models.Column(models.Integer,primary_key=True,autoincrement=True)#学生id name = models.Column(models.String(32)) #学生姓名 age = models.Column(models.Integer) #学生年龄 gender = models.Column(models.Integer) #学生性别 has_id = models.Column(models.Integer, nullable=True) #1是有id,0是没有id has_school = models.Column(models.Integer, default=1) #1是有学籍,0是没有学籍 #与考勤表是一对多的关系 to_attendance = models.relationship('Attendance', backref='to_students') #与假条表是一对多的关系 to_ask = models.relationship('Ask', backref='to_students')
class Leave(BaseModel): __tablename__ = "leave" request_id = models.Column(models.Integer) #请假人id request_name = models.Column(models.String(32)) #请假人姓名 request_type = models.Column(models.String(32)) #请假类型 request_start_time = models.Column(models.String(32)) #起始时间 request_end_time = models.Column(models.String(32)) #结束时间 request_days = models.Column(models.String(32)) #请假天数 request_description = models.Column(models.Text) #请假原因 request_phone = models.Column(models.String(32)) #联系方式 request_status = models.Column(models.String(32)) #假条状态
class Leave(BaseModel): __tablename__ = 'leave' leave_id = models.Column(models.Integer) # 请假人id leave_name = models.Column(models.String(32)) # 请假人姓名 leave_type = models.Column(models.String(32)) # 假期类型 leave_start = models.Column(models.String(32)) # 起始时间 leave_end = models.Column(models.String(32)) # 结束时间 leave_desc = models.Column(models.Text) # 请假描述 leave_phone = models.Column(models.String(32)) # 联系方式 leave_status = models.Column(models.String(32)) # 假条状态 0 请假 1 批准 2 驳回 3 销假
class Leave(BaseModel): __tablename__ = 'leave' leave_id = models.Column(models.Integer) # 请假人id leave_name = models.Column(models.String(32)) # 请假人姓名 leave_type = models.Column(models.String(32)) # 请假类型 leave_start_time = models.Column(models.String(32)) # 请假开始时间 leave_end_time = models.Column(models.String(32)) # 请假结束时间 leave_phone = models.Column(models.String(32)) # 请假人电话 leave_status = models.Column(models.String(32)) # 请假状态 0请假、1批准、2驳回、3销假 leave_description = models.Column(models.Text) # 请假事由
class Leave(BaseModel): __tablename__='leave' request_id=models.Column(models.Integer) request_name=models.Column(models.String(32)) request_type=models.Column(models.String(32)) request_start_time=models.Column(models.String(32)) request_end_time=models.Column(models.String(32)) request_description=models.Column(models.TEXT) request_phone = models.Column(models.String(32)) request_status=models.Column(models.String(32))
class Course(BaseModel): #课程表 __tablename = "course" label = models.Column(models.String(32)) description = models.Column(models.Text) #双向映射 to_teachers = models.relationship( #relationship关联关系relationship 'Teachers', #映射类的名称和类名一致#双向映射 backref='to_course') #教师类映射到该表 #双向映射语法(一对多):字段名=models.relationship( #"映射的类名", #backref="本表名") to_student = models.relationship( "Students", secondary=Stu_Cou, #多对多关系表 backref=models.backref("to_course", lazy="dynamic"), lazy="dynamic")
class Teacher(BaseModel): __tablename__ = 'teacher' #id = models.Column(models.Integer, primary_key=True, autoincrement=True) name = models.Column(models.String(32)) # 老师姓名 age = models.Column(models.Integer) # 老师年龄 gender = models.Column(models.Integer) # 老师性别0男,1女,-1不知道 description = models.Column(models.Text) #老师简介信息 course_id = models.Column(models.Integer, models.ForeignKey('course.id')) #专业与老师一对多关系 # 多对多关系查询 to_students = models.relationship('Students', secondary=Stu_Tea, backref=models.backref("to_teacher", lazy='dynamic'), lazy='dynamic') # 与假条表是一对多的关系 to_ask = models.relationship('Ask', backref='to_teacher')
class Course(BaseModel): __tablename__ = 'course' # 课程表名 #id = models.Column(models.Integer, primary_key=True, autoincrement=True) lable = models.Column(models.String(32)) description = models.Column(models.Text) updatetime = models.Column(models.DateTime, default=datetime.timezone) #反向映射字段,一对多关系查询 to_teacher = models.relationship( 'Teacher', #映射表 backref='to_course', #反向映射字段,通过该字段查询当表的内容 lazy='dynamic') #多对多关系查询 to_students = models.relationship('Students', secondary=Stu_Cou, backref=models.backref("to_course", lazy='dynamic'), lazy='dynamic')
class Course(BaseModel): #课程 __tablename__ = "course" label = models.Column(models.String(32)) description = models.Column(models.Text) to_teacher = models.relationship( "Teachers", #映射表 backref="to_course_data" #反向映射字段,映射表通过该字段可以查到当前表内容 ) to_student = models.relationship( "Students", secondary=Stu_Cou, backref=models.backref("to_course", lazy="dynamic"), lazy="dynamic", # lazy 的参数 # select 访问该字段时候,加载所有的映射数据 # joined 对关联的两个表students和stu_cou进行join查询 # dynamic 不加载数据 )
class Leave(BaseModel): """ 请假 0 批准 1 驳回 2 销假 3 """ __tablename__ = "leave" request_id = models.Column(models.Integer) #请假人id request_name = models.Column(models.String(32)) #请假人姓名 request_type = models.Column(models.String(32)) #假期类型 request_start_time = models.Column(models.String(32)) #起始时间 request_end_time = models.Column(models.String(32)) #结束时间 request_description = models.Column(models.TEXT) #请假事由 request_phone = models.Column(models.String(32)) #联系方式 request_status = models.Column(models.String(32)) #假条状态
class ApplicationForLeave(BaseModel): """ 申请 0 批准 1 驳回 2 销假 3 """ __tablename = "application_for_leave" person_id = models.Column(models.String(32)) person_name = models.Column(models.String(32)) person_phone = models.Column(models.String(32)) leave_type = models.Column(models.String(32)) leave_description = models.Column(models.Text) leave_start_time = models.Column(models.String(32)) leave_end_time = models.Column(models.String(32)) leave_status = models.Column(models.Integer)
class Course(BaseModel): """ 课程表 """ __tablename__ = 'course' label = models.Column(models.String(32)) description = models.Column(models.Text) #设置双向映射 to_teacher = models.relationship( #执行映射表的字段 'Teacher', #映射表,映射到谁 backref='to_course_data' #反向映射字段 ) #多对多 to_student = models.relationship( 'Students', secondary=Stu_Cou, backref=models.backref('to_course', lazy='dynamic'), #stu_cou course lazy='dynamic', #stu_cou student #select 访问该字段的时候加载所有映射数据 #joined 对关联的两个表student和teacher表进行join查询 #dynamic 不加载数据,为了防止数据多的时候查询卡 )
class Picture(BaseModel): label = models.Column(models.String(64)) picture = models.Column(models.String(64))
class User(BaseModel): __tablename__ = "user" user_name = models.Column(models.String(32)) password = models.Column(models.String(32)) email = models.Column(models.String(32))
class Picture(BaseModel): __tablename__ = 'picture' picture=models.Column(models.String(64)) type=models.Column(models.String(32))