class Base(db.Model): __abstract__ = True create_timestamp = db.Column(db.DateTime, default=datetime.utcnow) update_timestamp = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) is_delete = db.Column(db.Integer, default=1) # 1 正常, 0 已删除
class Article(Base): id = db.Column(db.String(25), primary_key=True, default=generate_resource_key) name = db.Column(db.String(255)) real_url = db.Column(db.String(255), nullable=False) resource_url = db.Column(db.String(255), nullable=False) class_id = db.Column(db.Integer, nullable=False)
class User(Base): id = db.Column(db.String(25), primary_key=True, default=generate_user_key) username = db.Column(db.String(25)) password_hash = db.Column(db.String(255)) is_manager = db.Column(db.Integer) # 0 不是管理员 1 是管理员 def set_password(self, password): self.password_hash = generate_password_hash(password) def validate_password(self, password): return check_password_hash(self.password_hash, password)
class Resource(Base): id = db.Column(db.String(25), primary_key=True, default=generate_resource_key) name = db.Column(db.String(255)) real_url = db.Column(db.String(255), nullable=False) resource_url = db.Column(db.String(255), nullable=False) class_id = db.Column(db.Integer, nullable=False) file_md5 = db.Column(db.String(35), nullable=False, unique=True) description = db.Column(db.String(255), default='') size = db.Column(db.Float, nullable=False)
class Log(Base): id = db.Column(db.Integer, primary_key=True, autoincrement=True) ip = db.Column(db.String(50)) url = db.Column(db.String(255))
class ArticleClass(Base): id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(20), unique=True) level = db.Column(db.Integer) parentId = db.Column(db.Integer)