class Comment(db.Model): """ 评论 """ __tablename__ = 'comment' id = db.Column(db.Integer, primary_key=True) content = db.Column(db.String(160), nullable=False) is_valid = db.Column(db.Boolean, default=True) created_at = db.Column(db.DateTime) weibo_id = db.Column(db.Integer, db.ForeignKey('weibo.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) def __repr__(self): return '<Weibo %r>' % self.name
class Topic(db.Model): """ 话题 """ __tablename__ = 'topic' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(160), unique=True, nullable=False) desc = db.Column(db.String(160)) head_img = db.Column(db.String(200)) is_valid = db.Column(db.Boolean, default=True) created_at = db.Column(db.DateTime) rel_weibos = db.relationship('WeiboRelTopic', backref='topic') # weibos = db.relationship('Weibo', secondary=weibo_topic, # backref=db.backref('weibos', lazy='dynamic')) def __repr__(self): return '<Topic %r>' % self.name
class WeiboRelTopic(db.Model): """ wb讨论话题 """ __tablename__ = 'weibo_rel_topic' id = db.Column(db.Integer, primary_key=True) weibo_id = db.Column(db.Integer, db.ForeignKey('weibo.id')) topic_id = db.Column(db.Integer, db.ForeignKey('topic.id'))
class WeiboAtUser(db.Model): """ wb@用户 """ __tablename__ = 'weibo_at_user' id = db.Column(db.Integer, primary_key=True) weibo_id = db.Column(db.Integer, db.ForeignKey('weibo.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id'))