class OrderDetail(db.Model): __tablename__ = "OrderDetail" id = db.Column(db.Integer, primary_key=True) product_count = db.Column(db.Integer, nullable=False) order_id = db.Column(db.Integer, db.ForeignKey("Order.id"), nullable=False) product_id = db.Column(db.Integer, db.ForeignKey("Product.id"), nullable=False)
class OrderAddress(db.Model): __tablename__ = "OrderAddress" id = db.Column(db.Integer, primary_key=True) consignee = db.Column(db.String(20), nullable=False) address = db.Column(db.String(40), nullable=False) telephone = db.Column(db.String(20), nullable=False) order_id = db.Column(db.Integer, db.ForeignKey("Order.id"), nullable=False)
class CustomerDetail(db.Model): __tablename__ = "CustomerDetail" id = db.Column(db.Integer, primary_key=True) consignee = db.Column(db.String(20), nullable=False) address = db.Column(db.String(40), nullable=False) telephone = db.Column(db.String(20), nullable=False) customer_id = db.Column(db.Integer, db.ForeignKey("Customer.id"), nullable=False) is_default = db.Column(db.Integer, nullable=False, default=0) def __repr__(self): return f"Customer_Detail('{self.consignee}','{self.telephone}','id:{self.id}',customer_id:{self.customer_id})"
class Order(db.Model): __tablename__ = "Order" id = db.Column(db.Integer, primary_key=True) status = db.Column(db.Integer, nullable=False, default=0) start_time = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) end_time = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) total_price = db.Column(db.Float, nullable=False, default=0.00) #address customer_id = db.Column("customer_id", db.Integer, db.ForeignKey("Customer.id"), nullable=False) orderdetails = db.relationship("OrderDetail", backref="order", lazy=True)
class Crew(db.Model, UserMixin): __tablename__ = "Crew" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) massage = db.Column(db.String(140), nullable=False, default="这个人很懒,什么也没有写。") is_employ = db.Column(db.SMALLINT, nullable=False, default=0) #默认未被雇佣为0 crew_name = db.Column(db.String(40), nullable=False, default="尚未填写") address = db.Column(db.String(40), nullable=False, default="尚未填写") telephone = db.Column(db.String(20), nullable=False, default="尚未填写") supplier_id = db.Column(db.Integer, db.ForeignKey("Supplier.id"), nullable=False, default=-1)
address = db.Column(db.String(40), nullable=False) telephone = db.Column(db.String(20), nullable=False) customer_id = db.Column(db.Integer, db.ForeignKey("Customer.id"), nullable=False) is_default = db.Column(db.Integer, nullable=False, default=0) def __repr__(self): return f"Customer_Detail('{self.consignee}','{self.telephone}','id:{self.id}',customer_id:{self.customer_id})" Supply = db.Table( "Supply", db.Column("supplier_id", db.Integer, db.ForeignKey("Supplier.id"), nullable=False), db.Column("product_id", db.Integer, db.ForeignKey("Product.id"), nullable=False), ) class Supplier(db.Model, UserMixin): __tablename__ = "Supplier" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) supplier_name = db.Column(db.String(40), nullable=False, default="尚未填写")