class Answer(db.Model): __tablename__ = 'answer' id = db.Column(db.Integer, primary_key=True, autoincrement=True) content = db.Column(db.Text, nullable=False) create_time = db.Column(db.DateTime, default=datetime.now()) author_id = db.Column(db.Integer, db.ForeignKey('user.id')) question_id = db.Column(db.Integer, db.ForeignKey('question.id')) author = db.relationship('User', backref=db.backref('answers')) question = db.relationship('Question', backref=db.backref('answers', order_by=id.desc()))
class SignIn(db.Model): __tablename__ = 'sign_in' id = db.Column(db.Integer, primary_key=True, autoincrement=True) time = db.Column(db.DateTime, default=datetime.now()) # 签到时间 num = db.Column(db.Integer) # 连续天数 user_id = db.Column(db.Integer, db.ForeignKey('user.id')) user = db.relationship('User', backref=db.backref('sign_in'))
class UserInfo(db.Model): __tabelname__ = 'user_info' id = db.Column(db.Integer, primary_key=True, autoincrement=True) signature = db.Column(db.Text, nullable=False) birthday = db.Column(db.String(100), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) user = db.relationship('User', backref=db.backref('user-info'))
class Question(db.Model): __tablename__ = 'question' id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(100), nullable=False) content = db.Column(db.Text, nullable=False) # now()服务器第一次运行时间, now每次创建时的当前时间 create_time = db.Column(db.DateTime, default=datetime.now()) author_id = db.Column(db.Integer, db.ForeignKey('user.id')) author = db.relationship('User', backref=db.backref('questions'))
class Notice(db.Model): __tabelname__ = 'notice' id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(100), nullable=False) # 通知标题 content = db.Column(db.Text, nullable=False) # 通知内容 # now()服务器第一次运行时间, now每次创建时的当前时间 create_time = db.Column(db.DateTime, default=datetime.now()) school = db.Column(db.String(100)) # 通知适用范围 author_id = db.Column(db.Integer, db.ForeignKey('user.id')) author = db.relationship('User', backref=db.backref('notices')) # 外链(通知者)
class Feedback(db.Model): __tablename__ = 'feedback' id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(100), nullable=False) content = db.Column(db.Text) reply = db.Column(db.Text) # 回复 manager_id = db.Column(db.Integer) create_time = db.Column(db.DateTime, default=datetime.now()) reply_time = db.Column(db.DateTime) # 回复时间 author_id = db.Column(db.Integer, db.ForeignKey('user.id')) author = db.relationship('User', backref=db.backref('feedbacks')) # 用户