Пример #1
0
class Users(BaseModelPrimaryKey):
    username = db.Column(db.String(32), nullable=False, unique=True)
    _password = db.Column(db.String(128), nullable=False)

    @property
    def password(self):
        raise Exception("保存密码异常")

    @password.setter
    def password(self, pwd):
        self._password = generate_password_hash(pwd)

    def verify_password(self, pwd):
        return check_password_hash(self._password, pwd)
Пример #2
0
class UserComment(BaseModelPrimaryKey):
    conten = db.Column(db.Text(), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
Пример #3
0
class BaseModelPrimaryKey(BaseModels):
    __abstract__ = True
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
Пример #4
0
class Books(BaseModelPrimaryKey):
    b_name = db.Column(db.String(32), nullable=False)
    b_author = db.Column(db.String(32), nullable=False)
    b_user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
Пример #5
0
class UserBlog(BaseModelPrimaryKey):
    title = db.Column(db.String(32), nullable=False)
    content = db.Column(db.Text())
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
Пример #6
0
class HobbyBlog(BaseModelPrimaryKey):
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
    blog_id = db.Column(db.Integer, db.ForeignKey("user_blog.id"))