class User_Item(Base): log.info('---->> 用户关联的项目表') __tablename__ = 'user_item' id = Column(Integer, primary_key=True, autoincrement=True) User_ID = Column(String(20), comment='用户ID') Item_ID = Column(String(20), comment='项目ID') Item_Power_ID = Column(Integer, comment='权限ID')
class User_Company(Base): log.info('----->>用户与公司关联表') __tablename__ = 'user_company' id = Column(Integer, primary_key=True, autoincrement=True) User_ID = Column(String(20), comment='用户ID') Company_ID = Column(String(20), comment='公司ID') Company_Power_ID = Column(Integer, comment='公司权限ID')
class Power(Base): log.info('----->权限表') __tablename__ = 'power' id = Column(Integer, primary_key=True, autoincrement=True) Power_ID = Column(String(20), comment='权限ID') Power_Name = Column(String(20), comment='权限名称') Power_Status = Column(Enum('0', '1', '2'), comment='权限位置:0、公司权限,1、项目组权限,2、待定。。')
class Company_list(Base): log.info('----->>公司表') __tablename__ = 'company_list' id = Column(Integer, primary_key=True, autoincrement=True) Company_ID = Column(String(20)) Company_Name = Column(String(20), comment='公司名称') Company_Introd = Column(LONGTEXT, comment='公司介绍') Creation_Time = Column(DateTime, comment='公司创建时间') User_ID = Column(String(20), comment='创建人ID')
class Item_list(Base): log.info('---->> 项目表') __tablename__ = 'item_list' id = Column(Integer, primary_key=True, autoincrement=True) Item_ID = Column(String(20)) Company_ID = Column(String(40), comment='公司ID') Item_Name = Column(String(20), comment='项目名称') Item_Introduce = Column(LONGTEXT, comment='项目介绍') Item_Status = Column(INT, comment='项目状态:0、正常进行,1、未开始,2、已结束,3、暂停项目,4、') Creation_Time = Column(DateTime, comment='项目创建日期') Last_Modified = Column(DateTime, comment='最后更新时间') User_ID = Column(String(20), comment='创建人ID')
class Groups(db.Model): __tablename__ = 'Groups' id = Column(Integer, primary_key=True) name = Column(String(), nullable=False) old_name = Column(String) teacher_1 = Column(Integer, nullable=False) number_students = Column(Integer) subject = Column(String) cost = Column(Integer) location = Column(Integer) teacher_name = Column(String) teacher_surname = Column(String) type_of_course = Column(String) def add_group(self): db.session.add(self) db.session.commit() def add_teacher(self): db.session.add(self) db.session.commit() def delete(self): db.session.delete(self) db.session.commit() def init(self, name, teacher_1, student1): self.name = name self.student1 = student1 self.teacher_1 = teacher_1 def format_teacher(self, name, location, teacher_1): return {'name': name, 'location': location, 'teacher_1': teacher_1}
class due_days(db.Model): id = Column(Integer, primary_key=True) img_due_days = Column(String, nullable=False) group_id_student = Column(Integer, nullable=False) id_of_student = Column(Integer, nullable=False) date_of_absent = Column(DateTime, nullable=False) reason_due = Column(String(), nullable=False)
class Item_Power(Base): log.info('---->> 账户在项目内的权限表') __tablename__ = 'item_power' id = Column(Integer, primary_key=True, autoincrement=True) Item_Power_ID = Column(Integer, comment='权限ID') Power_ID = Column(String(20), comment='权限名称') Power_Status = Column(Enum('0', '1', '2'), comment='权限状态:0、有权限,1、没有权限,2、半权限')
class Person(Base): __tablename__ = 'person' nid = Column(Integer, primary_key=True) name = Column(String(32), index=True, nullable=True) hobby_id = Column(Integer, ForeignKey("hobby.id")) # 建FK关系 # 与生成表结构无关,仅用于查询方便 hobby = relationship("Hobby", backref='pers') # 反向关联的名字
class reason_apset_days(db.Model): tablename = 'Reason' id = Column(Integer, primary_key=True) img_due_days = Column(String, nullable=False) reason_due = Column(String(), nullable=False) student_id = Column(Integer, nullable=False) date_abset = Column(DateTime, nullable=False) group_id = Column(Integer, nullable=False)
class User(Base): log.info('----->>用户表') __tablename__ = "user" id = Column(Integer, primary_key=True, autoincrement=True) User_ID = Column(String(20), comment='用户ID') User_Name = Column(String(20), comment='用户昵称') User_Introduce = Column(String(40), comment='用户简介') User_Identity = Column(Enum('0', '1', '2'), comment='用户身份:0、普通用户,1、草鸡管理员,2、临时用户') User_Phone = Column(Integer, comment='电话号码') User_Email = Column(String(20), comment='邮箱') User_Password = Column(String(40), comment='密码') File_ID = Column(String(20), comment='用户头像保存位置') Creation_Time = Column(DateTime, comment='用户创建日期') Last_Modified = Column(DateTime, comment='用户最后登录时间') Token = Column(String(20), comment='token') User_Status = Column( Enum('0', '1', '2', '3', '4', '5', '6'), comment='用户状态:0、正常状态,1、未分配公司,2、未分配项目,3、账户已过期,4、账户冻结,5、账户异常,6、待定。。')
class Case(Base): log.info('----->用例表') __tablename__ = 'case' Case_ID = Column(Integer, primary_key=True, autoincrement=True, comment='用例编号') Case_Title = Column(String(40), comment='用例标题') Case_Describe = Column(Text, comment='描述') File_ID = Column(String(20), comment='文件表ID') Case_Status = Column(Enum('1', '2', '3', '4', '5'), comment='用例等级:1,2,3,4,5') User_ID = Column(String(20), comment='创建人ID') Responsibility_ID = Column(String(20), comment='责任人ID') Partake_ID = Column(String(20), comment='参与人') Item_ID = Column(String(20), comment='项目ID')
class Hobby(Base): __tablename__ = 'hobby' id = Column(Integer, primary_key=True) caption = Column(String(50), default='篮球')
class File(Base): log.info('----->文件管理表') __tablename__ = 'file' id = Column(Integer, primary_key=True, autoincrement=True, comment='用例编号') File_ID = Column(String(20), comment='文件ID') File_Position = Column(Text, comment='文件位置')
class Teachers(db.Model): __tablename__ = 'Teachers' id = Column(Integer, primary_key=True) teacher = Column(Boolean) name = Column(String(), nullable=False) surname = Column(String(), nullable=False) phone = Column(String, nullable=False) password = Column(String, nullable=False) age = Column(String, nullable=False) username = Column(String(), nullable=False) locations = Column(Integer, ForeignKey('Locations.id'), nullable=False) subject = Column(String(), nullable=False) for_group = Column(Boolean, default=False) otasining_ismi = Column(String) salary = Column(Integer) number_groups = Column(Integer) group1 = Column(Integer) group2 = Column(Integer) group3 = Column(Integer) group4 = Column(Integer) group5 = Column(Integer) group6 = Column(Integer) group7 = Column(Integer) group8 = Column(Integer) group9 = Column(Integer) group10 = Column(Integer) photo = Column(String) def add_teacher(self): db.session.add(self) db.session.commit() def init(self, name, surname, age, username, phone, password, subject, locations, teacher): self.name = name self.surname = surname self.age = age self.username = username self.phone = phone self.password = password self.subject = subject self.locations = locations self.teacher = teacher def format_teacher(self, name, Surname, age, gmail, phone, password, subject, locations, xojakent_admin, gazalkent_admin, director, teacher): return { 'name': name, 'Surname': Surname, 'age': age, 'gmail': gmail, 'phone': phone, 'password': password, 'subject': subject, 'locations': locations, 'xojakent_admin': xojakent_admin, 'gazalkent_admin': gazalkent_admin, 'director': director, 'teacher': teacher } def delete(self): db.session.delete(self) db.session.commit()