class Room(db.Model, CRUD): __tablename__ = "rooms" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20), unique=True) schedules = db.relationship("Schedule", backref="room.id", cascade="delete", lazy=False) users = db.relationship("RoomUser", cascade="all", lazy=False) lastUpdate = db.Column(db.DateTime(), nullable=False) lastSynchronization = db.Column(db.DateTime(), nullable=True) lastAddress = db.Column(db.String(100), nullable=True) active = db.Column(db.Boolean, nullable=False) def __init__(self): self.lastUpdate = datetime.now() self.active = True
class RfidsPermitidos(db.Model, CRUD): __tablename__ = "rfids_permitidos" id = db.Column(db.Integer, primary_key=True) rfid = db.Column(db.String(16), nullable=False, unique=True) tipo = db.Column(db.Enum(TipoUsuario), nullable=False) last_update = db.Column(db.DateTime(), nullable=False) def __init__(self, rfid, tipo, last_update): self.rfid = rfid self.tipo = tipo self.last_update = last_update
class Keyring(db.Model, CRUD): __tablename__ = "keyrings" id = db.Column(db.Integer, primary_key=True) uid = db.Column(db.String(16), nullable=False, unique=True) userId = db.Column(db.Integer, nullable=False) userType = db.Column(db.Enum(UserTypesEnum), nullable=False) lastUpdate = db.Column(db.DateTime(), nullable=False) def __init__(self, uid, userId, userType, lastUpdate): self.uid = uid self.userId = userId self.userType = userType self.lastUpdate = lastUpdate
class Sala(db.Model, CRUD): __tablename__ = "sala" id = db.Column(db.Integer, primary_key=True) nome = db.Column(db.String(20), unique=True) horarios = db.relationship("Horario", cascade="delete") acesso = db.relationship("DireitoAcesso", cascade="delete") last_update = db.Column(db.DateTime(), nullable=False) alive = db.Column(db.Boolean, nullable=False) def __init__(self, nome): self.nome = nome self.last_update = datetime.now() self.alive = True
class RoomUser(db.Model, CRUD): __tablename__ = "roomsUsers" userId = db.Column(db.Integer, db.ForeignKey('users.id'), primary_key=True) roomId = db.Column(db.Integer, db.ForeignKey('rooms.id'), primary_key=True) user = db.relationship("User") room = db.relationship("Room") lastUpdate = db.Column(db.DateTime(), nullable=False) active = db.Column(db.Boolean, nullable=False) description = db.Column(db.String(255), unique=True) def __init__(self): self.lastUpdate = datetime.now() self.active = True
class HorariosPermitidos(db.Model, CRUD): __tablename__ = "horarios_permitidos" id = db.Column(db.Integer, primary_key=True) dia = db.Column(db.Enum(Dia), nullable=False) hora_inicio = db.Column(db.Time, nullable=False) hora_fim = db.Column(db.Time, nullable=False) tipo_usuario = db.Column(db.Enum(TipoUsuario), nullable=False) last_update = db.Column(db.DateTime(), nullable=False) def __init__(self, id, dia, hora_inicio, hora_fim, tipo_usuario, last_update): self.id = id self.dia = dia self.hora_inicio = hora_inicio self.hora_fim = hora_fim self.tipo_usuario = tipo_usuario self.last_update = last_update
class User(db.Model, CRUD): __tablename__ = "users" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) email = db.Column(db.String(100), nullable=False, unique=True) uid = db.Column(db.String(16), nullable=False, unique=True) userType = db.Column(db.Enum(UserTypesEnum), nullable=False) lastUpdate = db.Column(db.DateTime(), nullable=False) active = db.Column(db.Boolean, nullable=False) def __init__(self, name, email, uid, userType): self.name = name self.email = email self.uid = uid self.userType = userType self.active = True self.lastUpdate = datetime.now()
class Schedule(db.Model, CRUD): __tablename__ = "schedules" id = db.Column(db.Integer, primary_key=True) dayOfWeek = db.Column(db.Enum(DaysOfWeekEnum), nullable=False) beginTime = db.Column(db.Time, nullable=False) endTime = db.Column(db.Time, nullable=False) userType = db.Column(db.Enum(UserTypesEnum), nullable=False) lastUpdate = db.Column(db.DateTime(), nullable=False) def __init__(self, id, dayOfWeek, beginTime, endTime, userType, lastUpdate): self.id = id self.dayOfWeek = dayOfWeek self.beginTime = beginTime self.endTime = endTime self.userType = userType self.lastUpdate = lastUpdate
class Usuario(db.Model, CRUD): __tablename__ = "usuario" id = db.Column(db.Integer, primary_key=True) nome = db.Column(db.String(80), nullable=False) tipo = db.Column(db.Enum(TipoUsuario), nullable=False) email = db.Column(db.String(100), nullable=False, unique=True) rfid = db.Column(db.String(16), nullable=False, unique=True) direito_acesso = db.relationship("DireitoAcesso", cascade="delete") last_update = db.Column(db.DateTime(), nullable=False) alive = db.Column(db.Boolean, nullable=False) def __init__(self, nome, email, rfid, tipo): self.nome = nome self.email = email self.rfid = rfid self.tipo = tipo self.alive = True self.last_update = datetime.now()
class LicenseeSales(Base): __tablename__ = 'licensee_sales' id = db.Column(db.Integer, primary_key=True, autoincrement=True) ls_uid = db.Column(db.String(255)) # uid ls_u_uid = db.Column(db.String(255)) # User ls_user_text = db.Column(db.String(255)) # 对接人身份 ls_user_phone = db.Column(db.String(255)) # 对接联系方式 ls_update_time = db.Column(db.DateTime(255)) # 新建时间 ls_name = db.Column(db.String(255)) # 公司名字 ls_province = db.Column(db.String(255)) # 省 ls_city = db.Column(db.String(255)) # 市 ls_area = db.Column(db.String(255)) # 区 ls_address = db.Column(db.String(255)) # 详细地址 ls_registration_money = db.Column(db.String(255)) # 注册资本 ls_sales_money = db.Column(db.String(255)) # 出售价格 ls_buy_money = db.Column(db.String(255)) # 收购价格 ls_time = db.Column(db.Date) # 收购时间 ls_registration_time = db.Column(db.Date) # 注册时间 ls_text = db.Column(db.Text) # 备注 ls_product = db.Column(db.Text) # 产品情况 ls_status = db.Column(db.String(255)) # 对接联系方式 ls_delete = db.Column(db.Integer, default=0)