return check_password_hash(self.pwd_hash, pwd) def to_basic_dict(self): return { 'id': self.id, 'avatar': self.avatar, 'name': self.name, 'phone': self.phone } ihome_house_facility = db.Table( 'ihome_houst_facility', db.Column('house_id', db.INTEGER, db.ForeignKey('ihome_house.id'), primary_key=True), db.Column('facility_id', db.INTEGER, db.ForeignKey('ihome_facility.id'), primary_key=True)) class House(BaseModel, db.Model): """房屋信息""" __tablename__ = 'ihome_house' id = db.Column(db.INTEGER, primary_key=True) # 房屋编号牌 # 房屋主人的用户编号 user_id = db.Column(db.INTEGER, db.ForeignKey('ihome_user.id'),
s_g = db.Column(db.Integer, db.ForeignKey("grade.g_id"), nullable=True) __tablename__ = "student" def __init__(self, name, age): # 初始化函数 self.s_name = name self.s_age = age sc = db.Table( # 定义中间表 'sc', # 外键中的内容一定是“关联表名.主键”,如果不是关联表名,则会出现如下错误 # NoForeignKeysError: Could not determine join condition between parent/child tables on relationship Course.students # - there are no foreign keys linking these tables via secondary table 'sc'. # Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, # or specify 'primaryjoin' and 'secondaryjoin' expressions. db.Column('s_id', db.Integer, db.ForeignKey("student.s_id"), primary_key=True), db.Column('c_id', db.Integer, db.ForeignKey('course.c_id'), primary_key=True)) class Course(db.Model): c_id = db.Column(db.Integer, primary_key=True, autoincrement=True) c_name = db.Column(db.String(10), unique=True) students = db.relationship( 'Student', # 关联模块 secondary=sc, # 中间表名称
def to_basic_dict(self): return { 'id': self.id, 'avatar': self.avatar if self.avatar else '', 'name': self.name, 'phone': self.phone } ihome_house_facility = db.Table( "ihome_house_facility", db.Column("house_id", db.Integer, db.ForeignKey("ihome_house.id"), primary_key=True), db.Column("facility_id", db.Integer, db.ForeignKey("ihome_facility.id"), primary_key=True)) class House(BaseModel, db.Model): """房屋信息""" __tablename__ = "ihome_house" id = db.Column(db.Integer, primary_key=True) # 房屋编号 # 房屋主人的用户编号 user_id = db.Column(db.Integer, db.ForeignKey("ihome_user.id"),
ORDER_CODE = { 'WAIT_ACCEPT': '1', 'WAIT_PAYMENT': '2', 'PAID': '3', 'WAIT_COMMENT': '4', 'COMPLETE': '5', 'CANCELED': '6', 'REJECTED': '0' } goodscomments_goods_order = db.Table( "goodscomments_goods_order", db.Column('goods_id', db.Integer, db.ForeignKey("goods.id"), primary_key=True), # 商品id db.Column('order_id', db.Integer, db.ForeignKey("order.id"), primary_key=True), # 订单id # db.Column('comments_id', db.Integer, db.ForeignKey("GoodsComments.id"), primary_key=True), # 订单id ) # inventory_goods_order = db.Table( # "inventory_goods_order", # db.Column('goods_id', db.Integer, db.ForeignKey("goods.id"), primary_key=True), # 商品id # db.Column('order_id', db.Integer, db.ForeignKey("order.id"), primary_key=True), # 订单id # db.Column('inventory_id', db.Integer, db.ForeignKey("Inventory.id"), primary_key=True), # 订单id # ) goods_goodsclassification = db.Table( "goods_goodsclassification", db.Column('goods_id',