1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| from exts import db
class User(db.Model): __tablename__ = "user" id_user = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(45), nullable=False, unique=True) password = db.Column(db.String(45), nullable=False) name = db.Column(db.String(45), nullable=False) phone = db.Column(db.String(45), nullable=False) role = db.Column(db.String(45), nullable=False) power = db.Column(db.Integer, nullable=False) grade = db.Column(db.String(45), nullable=False)
class UserExtends(db.Model): __tablename__ = "user_extends" id = db.Column(db.Integer, primary_key=True, autoincrement=True)
id_user = db.Column(db.Integer, db.ForeignKey("user.id")) user = db.relationship("User", backref=db.backref("user_extends", uselist=False))
class RegisterRequests(db.Model): __tablename__ = "register_requests" id_register_requests = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(45), nullable=False, unique=True) password = db.Column(db.String(45), nullable=False) name = db.Column(db.String(45), nullable=False) phone = db.Column(db.String(45), nullable=False) role = db.Column(db.String(45), nullable=False) power = db.Column(db.Integer, nullable=False) grade = db.Column(db.String(45), nullable=False)
class Device(db.Model): __tablename__ = "device" id_device = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(45), nullable=False) pic = db.Column(db.String(200), nullable=False) time = db.Column(db.String(45), nullable=False)
id_user = db.Column(db.Integer, db.ForeignKey("user.id_user")) user = db.relationship("User", backref="devices")
class Data(db.Model): __tablename__ = "data" id_data = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(45), nullable=False) content = db.Column(db.Text, nullable=False) appendix = db.Column(db.String(200), nullable=False) appendix_name = db.Column(db.String(45), nullable=False) time = db.Column(db.String(45), nullable=False)
id_user = db.Column(db.Integer, db.ForeignKey("user.id_user")) user = db.relationship("User", backref="data_s")
class BigData(db.Model): __tablename__ = "big_data" id_big_data = db.Column(db.Integer, primary_key=True, autoincrement=True) filename = db.Column(db.String(45), nullable=False) path = db.Column(db.String(200), nullable=False) time = db.Column(db.String(45), nullable=False) who_can_see = db.Column(db.Integer, nullable=False) size = db.Column(db.String(45), nullable=False)
id_user = db.Column(db.Integer, db.ForeignKey("user.id_user")) user = db.relationship("User", backref="big_data_s")
|