class Genre(db.Model): genreId = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) description = db.Column(db.String(50), nullable=True) def __repr__(self): return 'genreId = {0}, description = {1}'.format( self.genreId, self.description)
class Feedback(db.Model): feedbackId = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(200), nullable=False) name = db.Column(db.String(50), nullable=True) content = db.Column(db.String(1000), nullable=False) def __repr__(self): return '{}, {}, {}, {}'.format(self.feedbackId, self.email, self.name, self.content)
class ItemLink(db.Model): __tablename__ = 'ItemLink' linkId = db.Column(db.Integer, primary_key=True) itemId = db.Column(db.Integer, db.ForeignKey('item.itemId'), nullable=False) platform = db.Column(db.String(50), nullable=False) source = db.Column(db.String(100), nullable=False) link = db.Column(db.String(1000), nullable=False) def __repr__(self): return '{}{}{}{}'.format(self.linkId, self.itemId, self.platform, self.source, self.link)
class Post(db.Model): postId = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(50)) authorId = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) threadId = db.Column(db.Integer, db.ForeignKey('thread.threadId'), nullable=False) content = db.Column(db.String(5000), nullable=False) dateTimePosted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) def __repr__(self): return f"Post('{self.postId}', '{self.title}', '{self.threadId}', '{self.dateTimePosted}')"
class Thread(db.Model): threadId = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(50), nullable=False) content = db.Column(db.String(5000)) category = db.Column(db.String(50), nullable=False) userId = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) dateTimeCreated = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) posts = db.relationship("Post", backref="Thread", lazy=True) def __repr__(self): return '{}, {}, {}, {}'.format(self.threadId, self.title, self.category, self.dateTimeCreated)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True, nullable=False) username = db.Column(db.String(50), unique=True, nullable=False) email = db.Column(db.String(100), unique=True, nullable=False) password = db.Column(db.String(50), nullable=False) role = db.Column(db.String(50), nullable=False) comments = db.relationship('Comment', backref='user', lazy=True) posts = db.relationship("Post", backref='author', lazy=True) threads = db.relationship("Thread", backref="author", lazy=True) ban = db.Column(db.Boolean, nullable=False) def __repr__(self): return 'userId = {0}, username = {1}, role = {2}'.format( self.id, self.username, self.role)
class Feature(db.Model): featureId = db.Column(db.Integer, primary_key=True) itemId = db.Column(db.Integer, db.ForeignKey('item.itemId'), nullable=False) description = db.Column(db.String(500), nullable=False) positive = db.Column(db.Boolean, nullable=False)
class Comment(db.Model): commentId = db.Column(db.Integer, primary_key=True) userId = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) itemId = db.Column(db.Integer, db.ForeignKey('item.itemId'), nullable=False) content = db.Column(db.String(10000), nullable=False) creationDateTime = db.Column(db.DateTime, nullable=False, default=datetime.now()) def __repr__(self): return 'commentId = {0}, userId = {1}, itemId = {2}, content = {3}, creationDateTime = {4}'.format( self.commentId, self.userId, self.itemId, self.content, self.creationDateTime)
class Item(db.Model): itemId = db.Column(db.Integer, primary_key=True) refid = db.Column(db.Integer, nullable=True) title = db.Column(db.String(100), nullable=False) rating = db.Column(db.Float, nullable=True) description = db.Column(db.String(20000), nullable=True) reviewAI = db.Column(db.String(10000), nullable=True) link = db.relationship('ItemLink', backref='item', lazy=True) image = db.Column(db.String(500), nullable=True) comments = db.relationship('Comment', backref='item', lazy=True) address = db.Column(db.String(500), nullable=True) itemType = db.Column(db.String(500), nullable=False) genre = db.relationship('Genre', secondary=GenreItem, lazy='subquery', backref=db.backref('item', lazy=True)) def __repr__(self): return 'ItemId = {0}, title = {1}, rating = {2}, description = {3}, credibility = {4}, reviewAI = {5}'.format( self.itemId, self.title, self.rating, self.description, self.credibility, self.reviewAI)