class StarModel(db.Model): __tablename__ = 'star' id = db.Column(db.Integer, primary_key=True, autoincrement=True) post_id = db.Column(db.String(150), db.ForeignKey("posts.id")) author_id = db.Column(db.String(100), db.ForeignKey("front_user.id")) author = db.relationship("FrontUserModel", backref='stars') post = db.relationship("PostsModel", backref='stars')
class Album_StarModel(db.Model): __tablename__ = 'album_star' id = db.Column(db.Integer,primary_key=True,autoincrement=True) album_id = db.Column(db.Integer, db.ForeignKey("album.id")) author_id = db.Column(db.String(100),db.ForeignKey("front_user.id")) author = db.relationship("FrontUserModel",backref='album_stars') album = db.relationship("AlbumModel",backref='album_stars')
class GroupManageModel(db.Model): __tablename__ = 'group_manage' id = db.Column(db.Integer, primary_key=True, autoincrement=True) group_id = db.Column(db.Integer, db.ForeignKey("group.id")) author_id = db.Column(db.String(150), db.ForeignKey("front_user.id")) author = db.relationship("FrontUserModel", backref='manager') group = db.relationship("GroupModel", backref='managers')
class CollectModel(db.Model): __tablename__ = 'collect' id = db.Column(db.Integer, primary_key=True, autoincrement=True) collect_time = db.Column(db.DateTime, default=datetime.now) post_id = db.Column(db.String(150), db.ForeignKey("posts.id")) author_id = db.Column(db.String(100), db.ForeignKey("front_user.id")) post = db.relationship("PostsModel", backref='collects') author = db.relationship("FrontUserModel", backref='collects')
class TopicModel(db.Model): __tablename__ = 'topic' id = db.Column(db.String(150), primary_key=True, default=shortuuid.uuid) title = db.Column(db.String(150), nullable=False) content = db.Column(db.Text, nullable=False) create_time = db.Column(db.DateTime, default=datetime.now) group_id = db.Column(db.Integer, db.ForeignKey("group.id")) author_id = db.Column(db.String(150), db.ForeignKey("front_user.id")) author = db.relationship("FrontUserModel", backref='topics') group = db.relationship("GroupModel", backref='topics')
class Album_CommentModel(db.Model): __tablename__ = 'album_comment' id = db.Column(db.Integer,primary_key=True,autoincrement=True) content = db.Column(db.Text,nullable=False) create_time = db.Column(db.DateTime,default=datetime.now) album_id = db.Column(db.Integer, db.ForeignKey("album.id")) author_id = db.Column(db.String(100),db.ForeignKey("front_user.id")) origin_comment_id = db.Column(db.Integer,db.ForeignKey("album_comment.id")) album = db.relationship("AlbumModel", backref='album_comments') author = db.relationship("FrontUserModel",backref="album_comments") origin_comment = db.relationship("Album_CommentModel",backref="album_replys",remote_side =[id])
class ImagesModel(db.Model): __tablename__ = 'image' id = db.Column(db.Integer,primary_key=True,autoincrement=True) url = db.Column(db.String(150)) create_time = db.Column(db.DateTime, default=datetime.now) album_id = db.Column(db.Integer,db.ForeignKey("album.id")) album = db.relationship("AlbumModel",backref='images')
class FocusModel(db.Model): __tablename__ = 'focus' id = db.Column(db.Integer, primary_key=True, autoincrement=True) focus_time = db.Column(db.DateTime, default=datetime.now) own_user_id = db.Column(db.String(150), nullable=False) author_id = db.Column(db.String(100), db.ForeignKey("front_user.id"), nullable=False) author = db.relationship("FrontUserModel", backref='focuses')
class AlbumModel(db.Model): __tablename__ = 'album' id = db.Column(db.Integer,primary_key=True,autoincrement=True) name = db.Column(db.String(150),nullable=False) create_time = db.Column(db.DateTime,default=datetime.now) see_count = db.Column(db.Integer,default=0) desc = db.Column(db.Text) power = db.Column(db.Integer,default=0) author_id = db.Column(db.String(150), db.ForeignKey("front_user.id")) author = db.relationship("FrontUserModel", backref='albums')
class HighlightModel(db.Model): __tablename__ = 'hightlight_post' id = db.Column(db.Integer, primary_key=True, autoincrement=True) post_id = db.Column(db.String(150), db.ForeignKey("posts.id")) create_time = db.Column(db.DateTime, default=datetime.now) post = db.relationship("PostsModel", backref='hightlight')
class PostsModel(db.Model): __tablename__ = 'posts' id = db.Column(db.String(150), primary_key=True, default=shortuuid.uuid) title = db.Column(db.String(150), nullable=False) content = db.Column(db.Text, nullable=False) create_time = db.Column(db.DateTime, default=datetime.now) read_count = db.Column(db.Integer, default=0) author_id = db.Column(db.String(150), db.ForeignKey("front_user.id")) author = db.relationship("FrontUserModel", backref='posts') post_tag = db.Table( 'post_tag', db.Column('post_id', db.ForeignKey("posts.id"), primary_key=True), db.Column('tag_id', db.ForeignKey("tag.id"), primary_key=True)) # 标签 class TagsModel(db.Model): __tablename__ = 'tag' id = db.Column(db.Integer, primary_key=True, autoincrement=True) tagname = db.Column(db.String(150)) posts = db.relationship("PostsModel", backref='tags', secondary=post_tag) # 点赞 class StarModel(db.Model): __tablename__ = 'star' id = db.Column(db.Integer, primary_key=True, autoincrement=True)
class AlbumModel(db.Model): __tablename__ = 'album' id = db.Column(db.Integer,primary_key=True,autoincrement=True) name = db.Column(db.String(150),nullable=False) create_time = db.Column(db.DateTime,default=datetime.now) see_count = db.Column(db.Integer,default=0) desc = db.Column(db.Text) power = db.Column(db.Integer,default=0) author_id = db.Column(db.String(150), db.ForeignKey("front_user.id")) author = db.relationship("FrontUserModel", backref='albums') album_tag = db.Table( 'album_tag', db.Column('album_id',db.ForeignKey("album.id"),primary_key=True), db.Column('tag_id',db.ForeignKey("img_tag.id"),primary_key=True) ) # 标签 class AlbumTagsModel(db.Model): __tablename__ = 'img_tag' id = db.Column(db.Integer,primary_key=True,autoincrement=True) tagname = db.Column(db.String(150)) album = db.relationship("AlbumModel",backref='tags',secondary=album_tag) class ImagesModel(db.Model): __tablename__ = 'image' id = db.Column(db.Integer,primary_key=True,autoincrement=True) url = db.Column(db.String(150))
#encoding:utf-8 from exct import db from datetime import datetime import shortuuid user_group = db.Table( 'user_group', db.Column('user_id', db.ForeignKey("front_user.id"), primary_key=True), db.Column('group_id', db.ForeignKey("group.id"), primary_key=True), ) class GroupModel(db.Model): __tablename__ = 'group' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(150)) avatar = db.Column(db.String(150)) create_time = db.Column(db.DateTime, default=datetime.now) create_user = db.Column(db.String(100), nullable=False) point = db.Column(db.Integer, default=0) desc = db.Column(db.Text) users = db.relationship("FrontUserModel", backref='groups', secondary=user_group) class TopicModel(db.Model): __tablename__ = 'topic' id = db.Column(db.String(150), primary_key=True, default=shortuuid.uuid) title = db.Column(db.String(150), nullable=False)