class User(db.Model): #主键为id id = db.Column(db.Integer, primary_key=True) #不允许相同值 openid = db.Column(db.String(120), unique=True) session_key = db.Column(db.String(120)) uuid = db.Column(db.String(120), unique=True) username = db.Column(db.String(120)) phonenum = db.Column(db.String(120))
class Lock(db.Model): #主键为id id = db.Column(db.Integer, primary_key=True) #锁体的标识符id lockid=db.Column(db.String(120), unique=True) #锁体名称 lockname = db.Column(db.String(120)) #锁体的用户uuid lockmasteruuid = db.Column(db.String(120)) #功能模块是否存在 qrcode = db.Column(db.Integer) monitor = db.Column(db.Integer) password = db.Column(db.Integer) nfc = db.Column(db.Integer) alart = db.Column(db.Integer) logic = db.Column(db.Integer)
class User(db.Model): __tablename__ = 'User' user_id = db.Column(db.Integer, primary_key=True, unique=True, nullable=False, index=True) name = db.Column(db.String(80), nullable=False) account = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(120), nullable=False) portrait = db.Column(db.String(80), nullable=False, default="http://212.64.38.61/tools/head.jpg") def to_json(self): dict = self.__dict__ if "_sa_instance_state" in dict: del dict["_sa_instance_state"] return dict def __repr__(self): return '<User %r>' % self.name
class Share(db.Model): ''' 分享 ''' __tablename__ = 'Share' share_id = db.Column(db.Integer, primary_key=True, nullable=False) message = db.Column(db.String(120), nullable=False) liking = db.Column(db.Integer) name = db.Column(db.String(80), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('User.user_id'), nullable=False) def to_json(self): dict = self.__dict__ if "_sa_instance_state" in dict: del dict["_sa_instance_state"] return dict def __repr__(self): return '<Share %r>' % (self.message)
class Comment(db.Model): ''' 评论 ''' comment_id = db.Column(db.Integer, primary_key=True, nullable=False) content = db.Column(db.String(120), nullable=False) name = db.Column(db.String(80), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('User.user_id'), nullable=False) share_id = db.Column(db.Integer, db.ForeignKey('Share.share_id'), nullable=False) def to_json(self): dict = self.__dict__ if "_sa_instance_state" in dict: del dict["_sa_instance_state"] return dict def __repr__(self): return '<Comment %r>' % (self.content)