class OrderItem(db.Model): __tablename__ = "myaxf_orderitem" # 修改表名 id = db.Column(db.Integer, primary_key=True, autoincrement=True) order_id = db.Column(db.Integer, db.ForeignKey("myaxf_order.id")) goods_id = db.Column(db.Integer, db.ForeignKey("axf_goods.id")) num = db.Column(db.Integer) buy_money = db.Column(db.Numeric(precision=10, scale=2))
class Moviecol(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) movie_id = db.Column(db.Integer, db.ForeignKey(Movie.id)) user_id = db.Column(db.Integer, db.ForeignKey(User.id)) addtime = db.Column(db.DateTime, index=True, default=datetime.now) def __repr__(self): return '<Moviecol %r>' % self.id
class Collection(db.Model): """收藏模型""" id = db.Column(db.Integer, primary_key=True, autoincrement=True) #设置与用户 一对多的关联关系 u_id = db.Column(db.Integer, db.ForeignKey("user.id")) #设置与博客 一对多的关联关系 b_id = db.Column(db.Integer, db.ForeignKey("blog.id")) __table_args__ = (db.UniqueConstraint("u_id", "b_id", name="u_id_b_id_uin_unique"), )
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 Userlog(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) # 登录IP ip = db.Column(db.String(255)) # 登录时间 addtime = db.Column(db.DateTime, index=True, default=datetime.now) user_id = db.Column(db.Integer, db.ForeignKey(User.id)) # 定义返回类型 def __repr__(self): return '<Userlog %r>' % self.name
class Oplog(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) # 登录IP ip = db.Column(db.String(255)) # 登录时间 addtime = db.Column(db.DateTime, index=True, default=datetime.now) # # 操作原因 reason = db.Column(db.String(255)) admin_id = db.Column(db.Integer, db.ForeignKey(Admin.id)) def __repr__(self): return '<Oplog %r>' % self.id