create.sql 9.53 KB
Newer Older
刘基明's avatar
刘基明 committed
1

张辰's avatar
张辰 committed
2
CREATE TABLE `home_page` (
刘基明's avatar
刘基明 committed
3
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
4 5 6 7
  `user_id` varchar(64) NOT NULL COMMENT '用户id',
  `head_img` varchar(256) NOT NULL COMMENT '头像url',
  `nick_name` varchar(32) NOT NULL COMMENT '昵称',
  `introduction` varchar(256) NOT NULL COMMENT '个人简介',
刘基明's avatar
刘基明 committed
8 9
  `sex` int(3) COMMENT '性别',
  `location` varchar(256) COMMENT '地址',
刘基明's avatar
刘基明 committed
10 11
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
12 13 14 15 16
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  UNIQUE KEY `uk_userId` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='个人主页';


刘基明's avatar
刘基明 committed
17 18 19
CREATE TABLE `follow_rel` (
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `follow_id` varchar(64) NOT NULL COMMENT '被关注的人id',
张辰's avatar
张辰 committed
20
  `follower_id` varchar(64) NOT NULL COMMENT '粉丝id',
刘基明's avatar
刘基明 committed
21 22
  `follow_time` datetime COMMENT '关注时间',
  `unfollow_time` datetime COMMENT '取消关注时间',
刘基明's avatar
刘基明 committed
23 24
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP  ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
25
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
26
  UNIQUE KEY `uk_idol_follower` (`follow_id`, `follower_id`),
张辰's avatar
张辰 committed
27 28 29 30 31
  INDEX `idx_follower` (`follower_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='粉丝关系';


CREATE TABLE `theme` (
刘基明's avatar
刘基明 committed
32
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
刘基明's avatar
刘基明 committed
33
  `theme_id` varchar(64) NOT NULL COMMENT '主题主键Id',
刘基明's avatar
刘基明 committed
34
  `title` varchar(64) COMMENT '标题',
刘基明's avatar
刘基明 committed
35 36
  `theme_type` int(4) NOT NULL COMMENT '类型 1:讨论无标题 2:长文有标题 3:转发',
  `content` text COMMENT '文本内容(json),type:附件类型(8:文本,88:产品 3:直播 6:短视频 300:课程,9:图片 10:多图),productType:基金类型(0 公募,1 私募,2 白名单,3 私有)',
张辰's avatar
张辰 committed
37
  `attach_type` int(4) NOT NULL COMMENT '附件类型',
刘基明's avatar
刘基明 committed
38
  `discuss_content` text NOT NULL COMMENT '讨论中的文本',
张辰's avatar
张辰 committed
39
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
刘基明's avatar
刘基明 committed
40
  `former_theme_id` varchar(64) COMMENT '被转发的主题',
张辰's avatar
张辰 committed
41
  `topic_id` varchar(64) NOT NULL COMMENT '所属的话题',
刘基明's avatar
刘基明 committed
42 43
  `is_pass` int(4) default 0 NOT NULL COMMENT '是否通过 0:初始值  1:已通过(管理后台使用)',
  `report_status` int(4) default 0 NOT NULL COMMENT '举报状态 0:未被举报  1:被举报 2:已处理',
刘基明's avatar
刘基明 committed
44 45
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
46
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
47
  INDEX `idx_thmee_id` (`theme_id`),
张辰's avatar
张辰 committed
48 49 50 51 52
  INDEX `idx_author` (`author_id`),
  INDEX `idx_former` (`former_theme_id`),
  INDEX `idx_topic` (`topic_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题内容';

刘基明's avatar
刘基明 committed
53 54 55 56 57 58 59 60
CREATE TABLE `theme_attachment` (
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `theme_id` varchar(64) NOT NULL COMMENT '主题ID',
  `attach_type` int(4) NOT NULL COMMENT '附件类型:1:产品 2:直播 3:短视频 4:课程 5:图片',
  `attach_id` varchar(64) NOT NULL COMMENT '附件对应的ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
61
  `ext_info` varchar(100) DEFAULT NULL COMMENT '额外信息',
刘基明's avatar
刘基明 committed
62 63 64
  PRIMARY KEY (`id`),
  KEY `theme_id` (`theme_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题附件';
张辰's avatar
张辰 committed
65 66

CREATE TABLE `comment` (
刘基明's avatar
刘基明 committed
67
  `id` int(32) auto_increment PRIMARY KEY NOT NULL COMMENT 'id',
刘基明's avatar
刘基明 committed
68
  `comment_id` varchar(64) NOT NULL COMMENT '评论主键Id',
刘基明's avatar
刘基明 committed
69 70
  `comment_type` int(4) NOT NULL COMMENT '类型',
  `content` varchar(1024) DEFAULT NULL COMMENT '文本内容',
张辰's avatar
张辰 committed
71
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
刘基明's avatar
刘基明 committed
72 73 74
  `theme_id` varchar(64) DEFAULT NULL COMMENT '主题id',
  `parent_id` varchar(64) DEFAULT NULL COMMENT '一级评论id',
  `reply_id` varchar(64) DEFAULT NULL COMMENT '回复评论id',
刘基明's avatar
刘基明 committed
75 76
  `is_pass` int(4) default 0 NOT NULL COMMENT '是否通过 0:初始值  1:已通过(管理后台使用)',
  `report_status` int(4) default 0 NOT NULL COMMENT '举报状态 0:未被举报  1:被举报 2:已处理',
刘基明's avatar
刘基明 committed
77
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
78
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
79
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
80 81
  KEY `idx_author` (`author_id`) USING BTREE,
  KEY `idx_target` (`reply_id`) USING BTREE
张辰's avatar
张辰 committed
82 83 84 85
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='评论';


CREATE TABLE `collection` (
刘基明's avatar
刘基明 committed
86
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
刘基明's avatar
刘基明 committed
87
  `collection_type` int(4) NOT NULL COMMENT '类型,类型 1:点赞主题,2:收藏主题 3:点赞评论',
刘基明's avatar
刘基明 committed
88
  `user_id` varchar(64) NOT NULL COMMENT '作者id',
张辰's avatar
张辰 committed
89
  `target_id` varchar(64) NOT NULL COMMENT '评论的目标id',
刘基明's avatar
刘基明 committed
90 91
  `collection_time` datetime COMMENT '收藏时间',
  `uncollection_time` datetime COMMENT '取消收藏时间',
刘基明's avatar
刘基明 committed
92 93
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
94
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
95
  INDEX `idx_author` (`user_id`),
张辰's avatar
张辰 committed
96 97 98 99 100
  INDEX `idx_target` (`target_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='收藏/点赞';


CREATE TABLE `topic` (
刘基明's avatar
刘基明 committed
101 102
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `topic_id` varchar(64) NOT NULL COMMENT 'uuid',
刘基明's avatar
刘基明 committed
103
  `topic_title` varchar(64) NOT NULL COMMENT '话题名称',
张辰's avatar
张辰 committed
104 105
  `is_top` int(4) NOT NULL COMMENT '是否置顶',
  `is_conceal` int(4) NOT NULL COMMENT '是否隐藏',
刘基明's avatar
刘基明 committed
106
  `view_cnt_adjust` bigint NOT NULL DEFAULT 0 COMMENT '浏览量调整',
刘基明's avatar
刘基明 committed
107 108
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
109 110 111 112 113 114
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  UNIQUE KEY `uk_title` (`topic_title`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='话题';


CREATE TABLE `file_record` (
刘基明's avatar
刘基明 committed
115 116 117 118 119 120
  `id` int(32) auto_increment NOT NULL COMMENT 'id',
  `file_id` varchar(64) NOT NULL COMMENT 'UUID',
  `file_type` int(4) NOT NULL COMMENT '类型:1:图片',
  `file_name` varchar(64) NOT NULL COMMENT '文件名称',
  `file_oss_key` varchar(64) NOT NULL COMMENT '阿里云key',
  `preview_url` varchar(512) DEFAULT NULL COMMENT '预览url',
刘基明's avatar
刘基明 committed
121
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
122
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
123
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
124
  `ext_info` varchar(100) DEFAULT NULL COMMENT '额外信息',
刘基明's avatar
刘基明 committed
125 126 127
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_logic` (`file_oss_key`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='上传文件';
张辰's avatar
张辰 committed
128 129 130


CREATE TABLE `black_list` (
刘基明's avatar
刘基明 committed
131
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
132
  `blocker` varchar(64) NOT NULL COMMENT '屏蔽发起人',
刘基明's avatar
刘基明 committed
133
  `blocked_type` int(4) NOT NULL COMMENT '屏蔽类型,1:用户,2:内容',
张辰's avatar
张辰 committed
134 135
  `blocked_id` varchar(64) NOT NULL COMMENT '被屏蔽的',
  `create_by` varchar(64) DEFAULT '',
刘基明's avatar
刘基明 committed
136 137
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
138 139 140 141 142 143 144
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  INDEX `uk_blocker` (`blocker`),
  INDEX `uk_blocked` (`blocked_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='黑名单';


CREATE TABLE `black_list` (
刘基明's avatar
刘基明 committed
145
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
146 147 148 149
  `blocker` varchar(64) NOT NULL COMMENT '屏蔽发起人',
  `blocked_type` int(4) NOT NULL COMMENT '屏蔽类型',
  `blocked_id` varchar(64) NOT NULL COMMENT '被屏蔽的',
  `create_by` varchar(64) DEFAULT '',
刘基明's avatar
刘基明 committed
150 151
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
152 153 154 155 156 157 158
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  INDEX `uk_blocker` (`blocker`),
  INDEX `uk_blocked` (`blocked_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='黑名单';


CREATE TABLE `visit_summary` (
刘基明's avatar
刘基明 committed
159
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
160 161 162 163 164 165
  `session_id` varchar(64) NOT NULL COMMENT 'session_id',
  `visitor_id` varchar(64) NOT NULL COMMENT '浏览者id',
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
  `ref_id` varchar(64) NOT NULL COMMENT '关联目标ID',
  `ref_type` int(8) NOT NULL COMMENT '关联目标类型',
  `duration` int(16) NOT NULL COMMENT '浏览时间 单位秒',
刘基明's avatar
刘基明 committed
166 167
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
168 169 170 171 172 173
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  INDEX `idx_session` (`session_id`),
  INDEX `idx_ref` (`ref_id`),
  INDEX `idx_visitor` (`visitor_id`),
  INDEX `idx_author` (`author_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='浏览记录';
刘基明's avatar
刘基明 committed
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191


CREATE TABLE `report_log` (
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `user_id` varchar(64) NOT NULL COMMENT '举报发起人',
  `report_type` int(4) NOT NULL COMMENT '举报类型,1:主题,2:评论 3、用户',
  `target_id` varchar(64) NOT NULL COMMENT '举报对象id',
  `target_user_id` varchar(64) NOT NULL COMMENT '举报对象作者id',
  `report_time` datetime NOT NULL COMMENT '上报时间',
  `deal_result` int(4)  COMMENT '处理结果 0:无操作 1:屏蔽 2:删除 ',
  `deal_user_id` int(4)  COMMENT '处理管理员',
  `deal_time` datetime COMMENT '处理时间',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  INDEX `uk_user` (`user_id`),
  INDEX `uk_report_target_id` (`target_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='举报记录';