class Movie(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(255), unique=True) url = db.Column(db.String(255), unique=True) info = db.Column(db.Text) # 封面 logo = db.Column(db.String(255)) # 星级,小整形 star = db.Column(db.SmallInteger) # 播放量 playnum = db.Column(db.BigInteger) # 评论量 commentnum = db.Column(db.BigInteger) # 上映时间 release_time = db.Column(db.Date) # 时长 alength = db.Column(db.String(255)) # 上映地区 area = db.Column(db.String(255)) # 添加时间 addtime = db.Column(db.DateTime, index=True, default=datetime.now) # 所属标签 tag_id = db.Column(db.Integer, db.ForeignKey(Tag.id)) comments = db.relationship('Comment', backref='movie', lazy=True) moviecols = db.relationship('Moviecol', backref='movie', lazy=True) def __repr__(self): return '<Movie %r>' % self.title
class Admin(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(30), unique=True) password = db.Column(db.Integer) # 是否为超级管理员 is_super = db.Column(db.SmallInteger) addtime = db.Column(db.DateTime, index=True, default=datetime.now) adminlogs = db.relationship('Adminlog', backref='admin', lazy=True) oplogs = db.relationship('Oplog', backref='admin', lazy=True) def __repr__(self): return '<Admin %r>' % self.id
class User(db.Model): """用户模型""" id = db.Column(db.Integer, primary_key=True, autoincrement=True) u_name = db.Column(db.String(255), nullable=True) u_phone = db.Column(db.String(13), nullable=True) u_password = db.Column(db.String(255), nullable=False) u_icon = db.Column(db.String(255), ) is_delete = db.Column(db.Boolean, default=False) cols = db.relationship("Collection", backref="user", lazy=True)
class Tag(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(255), unique=True) # 添加时间 addtime = db.Column(db.DateTime, index=True, default=datetime.now) movies = db.relationship('Movie', backref='tag', lazy=True) # 定义返回类型 def __repr__(self): return '<Tag %r>' % self.name
class Order(db.Model): __tablename__ = "myaxf_order" # 修改表名 id = db.Column(db.Integer, primary_key=True, autoincrement=True) user_id = db.Column(db.Integer, # db.ForeignKey("myaxf_myuser.id") ) create_time = db.Column(db.DateTime, default=datetime.datetime.now()) status = db.Column(db.Integer) order_items = db.relationship("OrderItem", backref="order", lazy=True)
class User(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(30), unique=True) password = db.Column(db.Integer) email = db.Column(db.String(100), unique=True) phone = db.Column(db.String(11)) # 个性简介 info = db.Column(db.Text) # 头像 face = db.Column(db.String(255)) addtime = db.Column(db.DateTime, index=True, default=datetime.now) uuid = db.Column(db.String(255), unique=True) isdelete = db.Column(db.Boolean, default=False) userlogs = db.relationship('Userlog', backref='user', lazy=True) comments = db.relationship('Comment', backref='user', lazy=True) moviecols = db.relationship('Moviecol', backref='user', lazy=True) # 定义返回类型 def __repr__(self): return '<User %r>' % self.name
class Blog(db.Model): """博客模型""" id = db.Column(db.Integer, primary_key=True, autoincrement=True) b_title = db.Column(db.String(255)) b_content = db.Column(db.String(255)) col = db.relationship("Collection", backref="blog", lazy=True) def to_dict(self): return { "id": self.id, "b_title": self.b_title, "b_content": self.b_content }
class Goods(db.Model): __tablename__ = "axf_goods" #修改表名 id = db.Column(db.Integer, primary_key=True, autoincrement=True) productid = db.Column(db.String(20)) productimg = db.Column(db.String(255)) productname = db.Column(db.String(130), ) productlongname = db.Column(db.String(190)) isxf = db.Column(db.Boolean, default=False) pmdesc = db.Column(db.Integer) specifics = db.Column(db.String(40)) price = db.Column(db.Numeric(precision=10, scale=2) #最大长度10位,小数点两位 ) marketprice = db.Column(db.Numeric(precision=10, scale=2)) categoryid = db.Column(db.Integer) childcid = db.Column(db.Integer) childcidname = db.Column(db.String(30)) dealerid = db.Column(db.String(30)) storenums = db.Column(db.Integer) productnum = db.Column(db.Integer) order_items_goods = db.relationship("OrderItem", backref="goods", lazy=True)