class StockInfo(db.Model): __tablename__ = 'stockinfo' __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) a_code = db.Column(db.Integer, index=True) h_code = db.Column(db.Integer, index=True) name = db.Column(db.String(50), index=True) exchange_market = db.Column(db.String(10)) industry_id = db.Column(db.Integer, db.ForeignKey('industryinfo.id')) stockcategory_id = db.Column(db.Integer, db.ForeignKey('stockcategory.id')) industryinfo = db.relationship("IndustryInfo", back_populates='stocks') url = db.Column(db.String(255), unique=True) stockcategory = db.relationship("StockCategory", back_populates='stocks')
class VideoHistory(db.Model): __tablename__ = 'videohistory' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('admin.id')) admin = db.relationship('Admin', back_populates='videos') videoname = db.Column(db.String(255), index=True) lasttime = db.Column(db.DateTime, default=datetime.now()) url = db.Column(db.String(255))
class Account(db.Model, UserMixin): __tablename__ = 'account' id = db.Column(db.Integer, db.ForeignKey("admin.id"), primary_key=True) orders = db.relationship('Order', back_populates='account') balance = db.Column(db.Float) loanorders = db.relationship('LoanOrder', back_populates='account') isactive = db.Column(db.Boolean, default=True) admin = db.relationship('Admin', back_populates='account')
class Comment(db.Model): id = db.Column(db.Integer, primary_key=True) author = db.Column(db.String(30)) email = db.Column(db.String(254)) site = db.Column(db.String(255)) body = db.Column(db.Text) from_admin = db.Column(db.Boolean, default=False) #是否为管理员 reviewed = db.Column(db.Boolean, default=False) #是否经过审核 timestamp = db.Column(db.DateTime, default=datetime.utcnow, index=True) post_id = db.Column(db.Integer, db.ForeignKey('post.id')) post = db.relationship('Post', back_populates='comments') replied_id = db.Column(db.Integer, db.ForeignKey('comment.id')) replied = db.relationship('Comment', back_populates='replies', remote_side=[id]) replies = db.relationship('Comment', back_populates='replied', cascade='all,delete-orphan')
class LoanOrder(db.Model): id = db.Column(db.Integer, primary_key=True) account_id = db.Column(db.Integer, db.ForeignKey('account.id')) account = db.relationship('Account', back_populates='loanorders') value = db.Column(db.Float) starttime = db.Column(db.DateTime) endtime = db.Column(db.DateTime) isended = db.Column(db.Boolean, default=False)
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(60)) body = db.Column(db.Text) timestamp = db.Column(db.DateTime, default=datetime.utcnow) can_comment = db.Column(db.Boolean, default=True) category_id = db.Column(db.Integer, db.ForeignKey('category.id')) category = db.relationship('Category', back_populates='posts') comments = db.relationship('Comment', back_populates='post', cascade='all,delete-orphan')
class Order(db.Model): id = db.Column(db.Integer, primary_key=True) account_id = db.Column(db.Integer, db.ForeignKey('account.id')) account = db.relationship('Account', back_populates='orders') type = db.Column(db.Boolean) date = db.Column(db.DateTime, default=datetime.now()) stock_id = db.Column(db.Integer, index=True) price = db.Column(db.Float) shares = db.Column(db.Integer) commission = db.Column(db.Float) profit = db.Column(db.Float)
class QuantPost(db.Model): __tablename__ = 'quantpost' id = db.Column(db.Integer, primary_key=True) post_id = db.Column(db.Integer) user_id = db.Column(db.Integer, db.ForeignKey('admin.id')) admin = db.relationship('Admin', back_populates='quantposts') title = db.Column(db.String(255)) excerpt = db.Column(db.String(512)) readtime = db.Column(db.DateTime, default=datetime.now()) #阅读次数 times = db.Column(db.Integer, default=0)