示例#1
0
文件: item.py 项目: BeingApple/CMS
class Item(db.Model):
    __tablename__ = 'item'

    id = db.Column(UUIDType(binary=False), primary_key=True)
    name = db.Column(db.Text)
    unit_price = db.Column(db.Numeric)

    def __init__(self, id=None, name=None, unit_price=None):
        self.id = id
        self.name = name
        self.unit_price = unit_price

    def __repr__(self):
        return "<Item %r>" % self.id
示例#2
0
文件: store.py 项目: BeingApple/CMS
class Store(db.Model):
    __tablename__ = 'store'

    id = db.Column(UUIDType(binary=False), primary_key=True)
    name = db.Column(db.Text)
    address = db.Column(db.Text)

    def __init__(self, id=None, name=None, address=None):
        self.id = id
        self.name = name
        self.address = address

    def __repr__(self):
        return "<Store %r>" % self.id
示例#3
0
class OrderItem(db.Model):
    __tablename__ = 'order_item'

    id = db.Column(UUIDType(binary=False), primary_key=True)
    order_id = db.Column(UUIDType(binary=False), ForeignKey('order.id'))
    item_id = db.Column(UUIDType(binary=False), ForeignKey('item.id'))

    order = relationship("Order", backref=backref('order_item', order_by=id))
    item = relationship("Item", backref=backref('order_item', order_by=id))

    def __init__(self, id=None, order_id=None, item_id=None):
        self.id = id
        self.order_id = order_id
        self.item_id = item_id

    def __repr__(self):
        return "<OrderItem %r>" % self.id
示例#4
0
文件: user.py 项目: BeingApple/CMS
class User(db.Model):
    __tablename__ = 'user'

    id = db.Column(UUIDType(binary=False), primary_key=True)
    name = db.Column(db.Text)
    gender = db.Column(db.Text)
    age = db.Column(db.Numeric)
    ages = db.Column(db.Numeric)
    phone = db.Column(db.Text)
    birthdate = db.Column(db.Date)

    def __init__(self,
                 id=None,
                 name=None,
                 gender=None,
                 age=None,
                 ages=None,
                 phone=None,
                 birthdate=None):
        self.id = id
        self.name = name
        self.gender = gender
        self.age = age
        self.ages = ages
        self.phone = phone
        self.birthdate = birthdate

    def __repr__(self):
        return "<User %r>" % self.id
示例#5
0
class Order(db.Model):
    __tablename__ = 'order'

    id = db.Column(UUIDType(binary=False), primary_key=True)
    created_at = db.Column(db.TIMESTAMP)
    store_id = db.Column(UUIDType(binary=False), ForeignKey('store.id'))
    user_id = db.Column(UUIDType(binary=False), ForeignKey('user.id'))

    user = relationship("User", backref=backref('order', order_by=id))
    store = relationship("Store", backref=backref('order', order_by=id))

    def __init__(self, id=None, created_at=None, store_id=None, user_id=None):
        self.id = id
        self.created_at = created_at
        self.store_id = store_id
        self.user_id = user_id

    def __repr__(self):
        return "<Order %r>" % self.id