/*
 Navicat Premium Data Transfer

 Source Server         : 腾讯云数据库
 Source Server Type    : MySQL
 Source Server Version : 80024
 Source Host           : 1.116.136.247:3306
 Source Schema         : sz-jiaotong-education

 Target Server Type    : MySQL
 Target Server Version : 80024
 File Encoding         : 65001

 Date: 01/07/2021 13:30:20
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for company
-- ----------------------------
DROP TABLE IF EXISTS `company`;
CREATE TABLE `company`  (
  `department_id` int(0) NOT NULL AUTO_INCREMENT,
  `department_name` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '部门名称',
  `parent_id` int(0) NOT NULL DEFAULT 0 COMMENT '父节点ID',
  `create_time` bigint(0) NOT NULL,
  PRIMARY KEY (`department_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '公司部门表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of company
-- ----------------------------

-- ----------------------------
-- Table structure for config_year
-- ----------------------------
DROP TABLE IF EXISTS `config_year`;
CREATE TABLE `config_year`  (
  `config_id` int(0) NOT NULL,
  `config_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '年度名字',
  `start_date` bigint(0) NOT NULL COMMENT '开始时间',
  `end_date` bigint(0) NOT NULL COMMENT '结束时间',
  PRIMARY KEY (`config_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '年度学习配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of config_year
-- ----------------------------

-- ----------------------------
-- Table structure for course
-- ----------------------------
DROP TABLE IF EXISTS `course`;
CREATE TABLE `course`  (
  `course_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `course_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '课程名称',
  `course_logo` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '图标',
  `course_desc` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '课程介绍',
  `course_hours` float NULL DEFAULT NULL COMMENT '课程时长',
  `course_teacher` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '教师',
  `is_valid` int(0) NULL DEFAULT 0 COMMENT '课程是否上架。下架后不可见',
  `gallery` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '如果有多张详情图，相册',
  PRIMARY KEY (`course_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 599 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '课程表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of course
-- ----------------------------

-- ----------------------------
-- Table structure for course_chapter
-- ----------------------------
DROP TABLE IF EXISTS `course_chapter`;
CREATE TABLE `course_chapter`  (
  `course_chapter_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `chapter_name` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '章节名字',
  `parent_id` int(0) NOT NULL COMMENT '父节点ID',
  `chapter_level` int(0) NOT NULL COMMENT '章节层级',
  `course_id` int(0) NOT NULL COMMENT '课程ID',
  PRIMARY KEY (`course_chapter_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 875 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '课程章节表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of course_chapter
-- ----------------------------

-- ----------------------------
-- Table structure for course_chapter_annex
-- ----------------------------
DROP TABLE IF EXISTS `course_chapter_annex`;
CREATE TABLE `course_chapter_annex`  (
  `annex_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `annex_name` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '附件名字',
  `course_chapter_id` int(0) NOT NULL COMMENT '章节ID',
  `annex_introduction` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '介绍',
  `annex_url` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '附件地址',
  `annex_url_org` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '原始附件地址，保留',
  PRIMARY KEY (`annex_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '章节附件表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of course_chapter_annex
-- ----------------------------

-- ----------------------------
-- Table structure for course_type
-- ----------------------------
DROP TABLE IF EXISTS `course_type`;
CREATE TABLE `course_type`  (
  `course_type_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `course_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '课程分类名称',
  `parent_id` int(0) NOT NULL DEFAULT 0 COMMENT '父节点ID',
  PRIMARY KEY (`course_type_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 60 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '课程类别表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of course_type
-- ----------------------------

-- ----------------------------
-- Table structure for paper
-- ----------------------------
DROP TABLE IF EXISTS `paper`;
CREATE TABLE `paper`  (
  `paper_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `paper_name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '试卷名称',
  `paper_type` int(0) NOT NULL COMMENT '试卷类别 1，2分别表示随机试卷，固定试卷',
  `paper_introduction` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '试卷介绍',
  `paper_score` int(0) NOT NULL COMMENT '总分',
  `paper_score_pass` int(0) NOT NULL COMMENT '及格分数',
  `paper_time` int(0) NOT NULL COMMENT '时长',
  `questions_num` int(0) NOT NULL COMMENT '题目数量',
  `start_time` bigint(0) NULL DEFAULT NULL COMMENT '开始考试时间',
  `end_time` bigint(0) NULL DEFAULT NULL COMMENT '失效时间',
  `status` int(0) NULL DEFAULT NULL COMMENT '1有效2无效',
  `config_id` int(0) NOT NULL COMMENT '年度ID',
  PRIMARY KEY (`paper_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '试卷表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of paper
-- ----------------------------

-- ----------------------------
-- Table structure for paper_question
-- ----------------------------
DROP TABLE IF EXISTS `paper_question`;
CREATE TABLE `paper_question`  (
  `paper_rule_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `paper_id` int(0) NULL DEFAULT NULL COMMENT '试卷编号',
  `question_num` int(0) NOT NULL COMMENT '问题数量',
  `question_level` int(0) NOT NULL COMMENT '难易程度',
  `question_type` int(0) NULL DEFAULT NULL COMMENT '题目类型',
  `question_score` int(0) NULL DEFAULT 0 COMMENT '按照类型每题多少分',
  `score` int(0) NOT NULL COMMENT '分值',
  `tag_id` int(0) NOT NULL COMMENT '基于哪个题库',
  PRIMARY KEY (`paper_rule_id`) USING BTREE,
  INDEX `IDX_paper_qion_paper_idED6A`(`paper_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 121 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '随机试卷问题表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of paper_question
-- ----------------------------

-- ----------------------------
-- Table structure for question
-- ----------------------------
DROP TABLE IF EXISTS `question`;
CREATE TABLE `question`  (
  `question_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `question_description` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '习题题干',
  `tag_id` int(0) NOT NULL COMMENT '标签id',
  `question_type` int(0) NOT NULL COMMENT '习题类型',
  `question_score` int(0) NULL DEFAULT NULL COMMENT '习题分数',
  `question_level` int(0) NOT NULL COMMENT '习题级别，难中易',
  `analysis` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '解析',
  PRIMARY KEY (`question_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1329 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '习题表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of question
-- ----------------------------

-- ----------------------------
-- Table structure for question_answer
-- ----------------------------
DROP TABLE IF EXISTS `question_answer`;
CREATE TABLE `question_answer`  (
  `question_answer_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `question_id` int(0) NOT NULL COMMENT '习题id',
  `question_answer` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '试题答案',
  `is_true` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否正确',
  PRIMARY KEY (`question_answer_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2511 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '问题答案表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of question_answer
-- ----------------------------

-- ----------------------------
-- Table structure for question_tag
-- ----------------------------
DROP TABLE IF EXISTS `question_tag`;
CREATE TABLE `question_tag`  (
  `tag_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `tag_name` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标签名称',
  `parent_id` int(0) NOT NULL DEFAULT 0 COMMENT '父节点ID',
  PRIMARY KEY (`tag_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '题库分类表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of question_tag
-- ----------------------------

-- ----------------------------
-- Table structure for question_type
-- ----------------------------
DROP TABLE IF EXISTS `question_type`;
CREATE TABLE `question_type`  (
  `type_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '题库id',
  `type_name` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类型名称',
  PRIMARY KEY (`type_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '问题类型表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of question_type
-- ----------------------------

-- ----------------------------
-- Table structure for sys_banner
-- ----------------------------
DROP TABLE IF EXISTS `sys_banner`;
CREATE TABLE `sys_banner`  (
  `banner_id` int(0) NOT NULL AUTO_INCREMENT COMMENT 'ID主键',
  `banner_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '广告连接',
  `banner_index` int(0) NOT NULL DEFAULT 0 COMMENT '索引',
  `banner_type` int(0) NOT NULL DEFAULT 0 COMMENT 'banner的位置01分表表示主banner，教师banner',
  PRIMARY KEY (`banner_id`, `banner_index`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '广告表\r\n' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of sys_banner
-- ----------------------------

-- ----------------------------
-- Table structure for sys_flash
-- ----------------------------
DROP TABLE IF EXISTS `sys_flash`;
CREATE TABLE `sys_flash`  (
  `flash_id` int(0) NOT NULL AUTO_INCREMENT COMMENT 'ID主键',
  `flash_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '广告连接',
  PRIMARY KEY (`flash_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '开机闪屏动画图片' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of sys_flash
-- ----------------------------

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `id` bigint(0) NOT NULL COMMENT '主键',
  `user_name` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名',
  `user_password` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码',
  `user_logo` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户头像',
  `user_nickname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '社区昵称',
  `user_gender` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '性别',
  `openid` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信openid',
  `user_mobile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '手机号码',
  `department_id` int(0) NULL DEFAULT NULL COMMENT '用户所属部门',
  `create_time` bigint(0) NULL DEFAULT NULL COMMENT '创建时间',
  `user_type` int(0) NULL DEFAULT NULL COMMENT '用户类型ID',
  `valid` int(0) NOT NULL DEFAULT 0 COMMENT '是否绑定验证',
  `vaid_time` bigint(0) NULL DEFAULT 0 COMMENT '验证时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户表\r\n' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user
-- ----------------------------

-- ----------------------------
-- Table structure for user_annex_history
-- ----------------------------
DROP TABLE IF EXISTS `user_annex_history`;
CREATE TABLE `user_annex_history`  (
  `id` int(0) NOT NULL,
  `user_id` int(0) NOT NULL COMMENT '用户ID',
  `annex_id` int(0) NOT NULL COMMENT '附件ID',
  `course_id` int(0) NOT NULL COMMENT '课程ID',
  `create_time` bigint(0) NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户查看附件记录时间表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_annex_history
-- ----------------------------

-- ----------------------------
-- Table structure for user_login_history
-- ----------------------------
DROP TABLE IF EXISTS `user_login_history`;
CREATE TABLE `user_login_history`  (
  `history_id` int(0) NOT NULL AUTO_INCREMENT,
  `user_id` int(0) NOT NULL COMMENT '用户ID',
  `login_time` bigint(0) NOT NULL COMMENT '登录时间',
  PRIMARY KEY (`history_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户登录历史记录' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_login_history
-- ----------------------------

-- ----------------------------
-- Table structure for user_question_history
-- ----------------------------
DROP TABLE IF EXISTS `user_question_history`;
CREATE TABLE `user_question_history`  (
  `test_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `user_id` int(0) NOT NULL COMMENT '用户Id',
  `config_id` int(0) NULL DEFAULT NULL COMMENT '年度id',
  `score` int(0) NOT NULL DEFAULT 0 COMMENT '成绩',
  `answer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '问题ID数组',
  `test_time` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '考试时间',
  PRIMARY KEY (`test_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2957 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户每日答题记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_question_history
-- ----------------------------

-- ----------------------------
-- Table structure for user_test_history
-- ----------------------------
DROP TABLE IF EXISTS `user_test_history`;
CREATE TABLE `user_test_history`  (
  `test_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `user_id` int(0) NOT NULL COMMENT '用户Id',
  `paper_id` int(0) NOT NULL COMMENT '试卷ID',
  `config_id` int(0) NULL DEFAULT NULL COMMENT '年度id',
  `score` int(0) NOT NULL DEFAULT 0 COMMENT '成绩',
  `answer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '问题ID数组',
  `create_time` bigint(0) NOT NULL,
  `total_score` int(0) NOT NULL,
  `test_time` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '考试时间',
  PRIMARY KEY (`test_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2957 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户考试记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_test_history
-- ----------------------------

-- ----------------------------
-- Table structure for user_type
-- ----------------------------
DROP TABLE IF EXISTS `user_type`;
CREATE TABLE `user_type`  (
  `type_id` int(0) NOT NULL AUTO_INCREMENT,
  `type_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户类别',
  `parent_id` int(0) NOT NULL DEFAULT 0 COMMENT '父节点ID',
  PRIMARY KEY (`type_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户类型表\r\n' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_type
-- ----------------------------

-- ----------------------------
-- Table structure for user_type_course
-- ----------------------------
DROP TABLE IF EXISTS `user_type_course`;
CREATE TABLE `user_type_course`  (
  `id` int(0) NOT NULL,
  `cuorse_id` int(0) NOT NULL COMMENT '课程ID',
  `config_id` int(0) NOT NULL COMMENT '年度ID',
  `user_type_id` int(0) NOT NULL COMMENT '用户类型ID',
  `is_valid` int(0) NOT NULL DEFAULT 1 COMMENT '是否有效默认有效',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户类型 以及学习课程对应表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_type_course
-- ----------------------------

-- ----------------------------
-- Table structure for user_type_paper
-- ----------------------------
DROP TABLE IF EXISTS `user_type_paper`;
CREATE TABLE `user_type_paper`  (
  `id` int(0) NOT NULL AUTO_INCREMENT,
  `paper_id` int(0) NOT NULL COMMENT '试卷ID',
  `create_time` bigint(0) NOT NULL COMMENT '时间',
  `user_type_id` int(0) NOT NULL COMMENT '用户类型ID',
  `is_valid` int(0) NOT NULL DEFAULT 1 COMMENT '是否有效，默认有效',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户类别考试得试卷' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_type_paper
-- ----------------------------

-- ----------------------------
-- Table structure for user_type_question_ruler
-- ----------------------------
DROP TABLE IF EXISTS `user_type_question_ruler`;
CREATE TABLE `user_type_question_ruler`  (
  `ruler_id` int(0) NOT NULL AUTO_INCREMENT,
  `question_count` int(0) NOT NULL COMMENT '题目数量',
  `question_type` int(0) NOT NULL COMMENT '题目类型',
  `question_tag` int(0) NOT NULL COMMENT '题库ID',
  `question_level` int(0) NOT NULL DEFAULT 0 COMMENT '难易程度，暂时i保留',
  PRIMARY KEY (`ruler_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '每日答题规则表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_type_question_ruler
-- ----------------------------

SET FOREIGN_KEY_CHECKS = 1;
