예제 #1
0
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')
예제 #2
0
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')
예제 #3
0
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')
예제 #4
0
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')
예제 #5
0
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')
예제 #6
0
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])
예제 #7
0
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')
예제 #8
0
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')
예제 #9
0
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')
예제 #10
0
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')
예제 #11
0

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)
예제 #12
0

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))
예제 #13
0
#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)