# ************************************************************
# Sequel Pro SQL dump
# Version 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 192.168.10.30 (MySQL 5.7.23-0ubuntu0.16.04.1-log)
# Database: stmms_gx_init
# Generation Time: 2018-09-29 07:30:42 +0000
# ************************************************************


# Dump of table b_campus
# ------------------------------------------------------------

DROP TABLE IF EXISTS `b_campus`;

CREATE TABLE `b_campus` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `school_id` int(11) NOT NULL COMMENT '所属学校',
  `code` varchar(32) DEFAULT '' COMMENT '代码',
  `name` varchar(64) NOT NULL DEFAULT '' COMMENT '名称',
  `province` varchar(16) DEFAULT '' COMMENT '省份',
  `city` varchar(16) DEFAULT '' COMMENT '城市',
  `district` varchar(16) DEFAULT NULL COMMENT '地区',
  `address` varchar(128) DEFAULT NULL COMMENT '地址',
  `phone` varchar(32) DEFAULT NULL COMMENT '电话',
  `description` varchar(256) DEFAULT NULL COMMENT '学校描述',
  PRIMARY KEY (`id`),
  KEY `index1` (`school_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='学习中心表';



# Dump of table b_role_auth
# ------------------------------------------------------------

DROP TABLE IF EXISTS `b_role_auth`;

CREATE TABLE `b_role_auth` (
  `role_name` varchar(16) NOT NULL DEFAULT '' COMMENT '角色名称',
  `auth_names` text NOT NULL COMMENT '权限名称列表',
  PRIMARY KEY (`role_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色权限表';

LOCK TABLES `b_role_auth` WRITE;
/*!40000 ALTER TABLE `b_role_auth` DISABLE KEYS */;

INSERT INTO `b_role_auth` (`role_name`, `auth_names`)
VALUES
    ('campus_admin','campus_view_self,campus_edit_self,campus_user_view,campus_user_create,campus_user_edit,campus_user_delete,student_view,student_add,student_edit,student_delete,exam_create,exam_view_self,exam_param_edit'),
    ('exam_admin','role_view,role_edit,campus_view_all,campus_view_self,campus_create,campus_edit_all,campus_edit_self,campus_delete,campus_admin_create,campus_admin_edit,campus_admin_delete,campus_user_view,campus_user_create,campus_user_edit,student_view,student_add,student_edit,exam_create,exam_view_all,exam_param_edit'),
    ('head_teacher','role_view,campus_admin_edit'),
    ('master','role_view,role_edit,campus_admin_delete,exam_view_self'),
    ('school_admin','school_view_self,school_edit_self,school_user_view,school_user_create,school_user_edit,school_user_delete,campus_create,campus_edit_all,student_view,student_add,student_edit,student_delete,exam_create,exam_view_self,exam_param_edit'),
    ('school_viewer','exam_view_self'),
    ('sys_admin','role_view,role_edit,school_view_all,school_create,school_edit_all,school_delete,school_admin_create,school_admin_edit,school_admin_delete,campus_view_all,campus_create,campus_edit_all,campus_delete,campus_admin_create,campus_admin_edit,campus_admin_delete');

/*!40000 ALTER TABLE `b_role_auth` ENABLE KEYS */;
UNLOCK TABLES;


# Dump of table b_school
# ------------------------------------------------------------

DROP TABLE IF EXISTS `b_school`;

CREATE TABLE `b_school` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `name` varchar(64) NOT NULL COMMENT '名称',
  `province` varchar(16) NOT NULL DEFAULT '' COMMENT '省份',
  `city` varchar(16) NOT NULL DEFAULT '' COMMENT '城市',
  `address` varchar(128) DEFAULT NULL COMMENT '地址',
  `phone` varchar(32) DEFAULT NULL COMMENT '电话',
  `logo_url` varchar(64) DEFAULT NULL COMMENT '图片地址、名称',
  `description` varchar(256) DEFAULT NULL COMMENT '描述',
  `enable` int(11) NOT NULL DEFAULT '1' COMMENT '0:停用，1:启用',
  `time_create` datetime NOT NULL COMMENT '创建时间',
  `time_modified` datetime DEFAULT NULL COMMENT '修改时间',
  PRIMARY KEY (`id`),
  KEY `area` (`province`,`city`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='学校表';


# Dump of table b_tag
# ------------------------------------------------------------

DROP TABLE IF EXISTS `b_tag`;

CREATE TABLE `b_tag` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `name` varchar(128) NOT NULL DEFAULT '' COMMENT '问题类型',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='试卷标记类型';

LOCK TABLES `b_tag` WRITE;
/*!40000 ALTER TABLE `b_tag` DISABLE KEYS */;

INSERT INTO `b_tag` (`id`, `name`)
VALUES
    (1,'试卷雷同'),
    (2,'科目错误'),
    (3,'贴错条码'),
    (4,'违纪');

/*!40000 ALTER TABLE `b_tag` ENABLE KEYS */;
UNLOCK TABLES;


# Dump of table b_user
# ------------------------------------------------------------

DROP TABLE IF EXISTS `b_user`;

CREATE TABLE `b_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `login_name` varchar(64) NOT NULL COMMENT '登录名',
  `name` varchar(64) NOT NULL COMMENT '名称',
  `password` varchar(128) NOT NULL COMMENT '密码',
  `type` int(11) NOT NULL DEFAULT '0' COMMENT '用户基本类型',
  `status` int(11) NOT NULL DEFAULT '1' COMMENT '状态0：失效1：有效',
  `school_id` int(11) NOT NULL DEFAULT '0' COMMENT '所属学校ID',
  `role_names` varchar(256) DEFAULT NULL COMMENT '角色名称列表，以逗号分隔',
  `last_login_time` datetime DEFAULT NULL COMMENT '最后一次登录时间',
  `last_login_ip` varchar(64) DEFAULT NULL COMMENT '最后一次登录IP',
  `created_time` datetime NOT NULL COMMENT '创建时间',
  `updated_time` datetime DEFAULT NULL COMMENT '修改时间',
  `updator_id` int(11) DEFAULT NULL COMMENT '更新用户',
  PRIMARY KEY (`id`),
  KEY `login_name` (`login_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户表';


LOCK TABLES `b_user` WRITE;
/*!40000 ALTER TABLE `b_user` DISABLE KEYS */;

INSERT INTO `b_user` (`id`, `login_name`, `name`, `password`, `type`, `status`, `school_id`, `role_names`, `last_login_time`, `last_login_ip`, `created_time`, `updated_time`, `updator_id`)
VALUES
    (1,'admin','超级管理员','c5421ac9e62a8fefe78d57a5266a61fa',0,1,0,'sys_admin','2018-10-10 09:51:11','0:0:0:0:0:0:0:1','2018-10-16 18:11:51','2018-10-10 09:51:11',NULL);

/*!40000 ALTER TABLE `b_user` ENABLE KEYS */;
UNLOCK TABLES;


# Dump of table b_school_user
# ------------------------------------------------------------

DROP TABLE IF EXISTS `b_school_user`;

CREATE TABLE `b_school_user` (
  `school_id` int(11) NOT NULL COMMENT '学校ID',
  `user_id` int(11) NOT NULL COMMENT '用户ID',
  PRIMARY KEY (`user_id`,`school_id`),
  KEY `FK_f5a2c07727764f069e375c2d196` (`school_id`),
  KEY `FK_30a064a4d1ff4c4d883750afe5e` (`user_id`),
  CONSTRAINT `FK_30a064a4d1ff4c4d883750afe5e` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`),
  CONSTRAINT `FK_f5a2c07727764f069e375c2d196` FOREIGN KEY (`school_id`) REFERENCES `b_school` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='学习关联用户表';


# Dump of table eb_exam
# ------------------------------------------------------------

DROP TABLE IF EXISTS `eb_exam`;

CREATE TABLE `eb_exam` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `name` varchar(64) NOT NULL COMMENT '考试名称',
  `school_id` int(11) NOT NULL COMMENT '学校ID',
  `exam_time` datetime NOT NULL COMMENT '考试时间',
  `status` int(11) NOT NULL DEFAULT '0' COMMENT '状态0:未结束，1:已结束',
  `description` varchar(128) DEFAULT NULL COMMENT '描述',
  `creator_id` int(11) NOT NULL COMMENT '创建人ID',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  PRIMARY KEY (`id`),
  KEY `creator_id` (`creator_id`,`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='考试表';



# Dump of table eb_exam_package
# ------------------------------------------------------------

DROP TABLE IF EXISTS `eb_exam_package`;

CREATE TABLE `eb_exam_package` (
  `exam_id` int(11) NOT NULL COMMENT '考试ID',
  `code` varchar(128) NOT NULL DEFAULT '' COMMENT '签到表编号',
  `pic_count` int(11) NOT NULL COMMENT '上传图片数量',
  PRIMARY KEY (`exam_id`,`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='考试签到表';



# Dump of table eb_exam_question
# ------------------------------------------------------------

DROP TABLE IF EXISTS `eb_exam_question`;

CREATE TABLE `eb_exam_question` (
  `exam_id` int(11) NOT NULL COMMENT '考试ID',
  `subject_code` varchar(32) NOT NULL DEFAULT '' COMMENT '科目代码',
  `main_number` int(11) NOT NULL COMMENT '大题号',
  `sub_number` int(11) NOT NULL COMMENT '小题号',
  `is_objective` tinyint(1) NOT NULL COMMENT '是否客观题',
  `main_title` varchar(128) NOT NULL DEFAULT '' COMMENT '大题名称',
  `answer` varchar(16) DEFAULT NULL COMMENT '正确答案',
  `total_score` double NOT NULL COMMENT '满分',
  `interval_score` double NOT NULL COMMENT '间隔分',
  `total_count` int(11) DEFAULT NULL COMMENT '总人数',
  `zero_count` int(11) DEFAULT NULL COMMENT '零分人数',
  `full_count` int(11) DEFAULT NULL COMMENT '满分人数',
  PRIMARY KEY (`exam_id`,`subject_code`,`is_objective`,`main_number`,`sub_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='试卷信息表';



# Dump of table eb_exam_student
# ------------------------------------------------------------

DROP TABLE IF EXISTS `eb_exam_student`;

CREATE TABLE `eb_exam_student` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `exam_id` int(11) NOT NULL DEFAULT '0' COMMENT '考试ID',
  `school_id` int(11) NOT NULL COMMENT '学校ID',
  `campus_name` varchar(128) NOT NULL DEFAULT '0' COMMENT '学习中心',
  `subject_code` varchar(32) NOT NULL DEFAULT '' COMMENT '科目代码',
  `subject_name` varchar(32) NOT NULL DEFAULT '0' COMMENT '科目名称',
  `exam_number` varchar(64) NOT NULL COMMENT '准考证号',
  `student_code` varchar(64) NOT NULL DEFAULT '' COMMENT '学号',
  `name` varchar(32) NOT NULL DEFAULT '' COMMENT '姓名',
  `package_code` varchar(128) DEFAULT NULL COMMENT '签到表编号',
  `exam_site` varchar(128) DEFAULT NULL COMMENT '考点信息',
  `exam_room` varchar(128) DEFAULT NULL COMMENT '考场信息',
  `remark` varchar(255) DEFAULT NULL COMMENT '考生备注信息',
  `batch_code` varchar(32) DEFAULT NULL COMMENT '扫描批次号',
  `sheet_count` int(11) NOT NULL COMMENT '原图数量',
  `slice_count` int(11) NOT NULL COMMENT '裁切图数量',
  `answers` text COMMENT '客观题答案',
  `is_upload` tinyint(1) NOT NULL COMMENT '是否已上传',
  `is_absent` tinyint(1) NOT NULL COMMENT '是否缺考',
  `is_manual_absent` tinyint(1) NOT NULL COMMENT '是否人工指定缺考',
  `is_breach` tinyint(1) NOT NULL COMMENT '是否违纪',
  `is_exception` tinyint(1) NOT NULL COMMENT '数据检查是否有异常',
  `upload_time` datetime DEFAULT NULL COMMENT '上传时间',
  `objective_score` double DEFAULT NULL COMMENT '客观总分',
  `objective_score_list` text COMMENT '客观题得分明细',
  `subjective_score` double DEFAULT NULL COMMENT '主观总分',
  `subjective_score_list` text COMMENT '主观题得分明细',
  `subject_level` varchar(255) DEFAULT NULL COMMENT '科目层次信息',
  `subject_category` varchar(255) DEFAULT NULL COMMENT '专业类型信息',
  `grade` varchar(255) DEFAULT NULL COMMENT '年级',
  `department` varchar(255) DEFAULT NULL COMMENT '专业',
  PRIMARY KEY (`id`),
  UNIQUE KEY `index1` (`exam_id`,`exam_number`),
  KEY `index2` (`exam_id`,`student_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='考生库';



# Dump of table eb_exam_student_paper
# ------------------------------------------------------------

DROP TABLE IF EXISTS `eb_exam_student_paper`;

CREATE TABLE `eb_exam_student_paper` (
  `exam_id` int(11) NOT NULL COMMENT '考试ID',
  `exam_number` varchar(128) NOT NULL DEFAULT '' COMMENT '准考证号',
  `is_objective` tinyint(1) NOT NULL COMMENT '是否客观题',
  `struct` text NOT NULL COMMENT '结构内容',
  PRIMARY KEY (`exam_id`,`exam_number`,`is_objective`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='考生专属试卷结构表';



# Dump of table eb_exam_subject
# ------------------------------------------------------------

DROP TABLE IF EXISTS `eb_exam_subject`;

CREATE TABLE `eb_exam_subject` (
  `exam_id` int(11) NOT NULL COMMENT '考试ID',
  `code` varchar(32) NOT NULL DEFAULT '' COMMENT '科目代码',
  `name` varchar(32) NOT NULL DEFAULT '' COMMENT '科目名称',
  `level` varchar(255) DEFAULT NULL COMMENT '科目层次',
  `category` varchar(255) DEFAULT NULL COMMENT '专业类型',
  `status` int(11) NOT NULL COMMENT '状态',
  `objective_score` double NOT NULL COMMENT '客观题总分',
  `subjective_score` double NOT NULL COMMENT '主观题总分',
  `total_score` double NOT NULL COMMENT '卷面总分',
  `library_count` int(11) NOT NULL COMMENT '评卷任务数',
  `marked_count` int(11) NOT NULL COMMENT '已评任务数',
  `left_count` int(11) NOT NULL COMMENT '未评任务数',
  `has_answer` tinyint(1) NOT NULL COMMENT '是否有答案文件',
  `has_paper` tinyint(1) NOT NULL COMMENT '是否有试卷文件',
  `remark` varchar(255) DEFAULT NULL COMMENT '科目备注信息',
  PRIMARY KEY (`exam_id`,`code`),
  KEY `index1` (`exam_id`,`status`,`subjective_score`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='考试科目表';



# Dump of table eb_exam_subject_paper
# ------------------------------------------------------------

DROP TABLE IF EXISTS `eb_exam_subject_paper`;

CREATE TABLE `eb_exam_subject_paper` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `exam_id` int(11) DEFAULT NULL COMMENT '考试ID',
  `code` varchar(32) DEFAULT NULL COMMENT '科目代码',
  `question_type_name` varchar(255) DEFAULT NULL COMMENT '题型名称',
  `total_count` int(11) DEFAULT NULL COMMENT '题型总个数',
  `count` int(11) DEFAULT NULL COMMENT '题型有效个数',
  `total_score` double DEFAULT NULL COMMENT '题型总分',
  `interval_score` double DEFAULT NULL COMMENT '题型间隔分',
  `main_number` int(11) DEFAULT NULL COMMENT '大题号',
  `is_objective` int(11) DEFAULT NULL COMMENT '是否客观题',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Dump of table eb_marker
# ------------------------------------------------------------

DROP TABLE IF EXISTS `eb_marker`;

CREATE TABLE `eb_marker` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `exam_id` int(11) NOT NULL COMMENT '考试ID',
  `subject_code` varchar(32) NOT NULL DEFAULT '' COMMENT '科目代码',
  `login_name` varchar(128) NOT NULL DEFAULT '' COMMENT '登录名',
  `name` varchar(32) NOT NULL DEFAULT '' COMMENT '姓名',
  `password` varchar(128) NOT NULL COMMENT '登录密码',
  `enable` tinyint(1) NOT NULL COMMENT '是否启用',
  `common` tinyint(1) NOT NULL COMMENT '是否通用账号',
  `last_login_ip` varchar(64) DEFAULT NULL COMMENT '上次登录IP',
  `last_login_time` datetime DEFAULT NULL COMMENT '上次登录时间',
  `mode` varchar(16) DEFAULT NULL COMMENT '当前评卷模式',
  `top_count` int(11) DEFAULT NULL COMMENT '评卷任务上限',
  PRIMARY KEY (`id`),
  KEY `index1` (`login_name`),
  KEY `index2` (`exam_id`,`subject_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='评卷员表';



# Dump of table m_library
# ------------------------------------------------------------

DROP TABLE IF EXISTS `m_library`;

CREATE TABLE `m_library` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `exam_id` int(11) NOT NULL COMMENT '考试ID',
  `subject_code` varchar(32) NOT NULL DEFAULT '' COMMENT '科目代码',
  `campus_id` int(11) NOT NULL COMMENT '学习中心ID',
  `student_id` int(11) NOT NULL COMMENT '考生ID',
  `exam_number` varchar(128) NOT NULL DEFAULT '' COMMENT '准考证号',
  `pic_start` int(11) NOT NULL COMMENT '起始小图',
  `pic_count` int(11) NOT NULL COMMENT '小图数量',
  `marker_id` int(11) DEFAULT NULL COMMENT '评卷员ID',
  `marker_time` datetime DEFAULT NULL COMMENT '评卷时间',
  `marker_score` double DEFAULT NULL COMMENT '评卷总分',
  `marker_score_list` varchar(256) DEFAULT NULL COMMENT '评卷给分明细',
  `marker_duration` bigint(20) NOT NULL DEFAULT '0' COMMENT '评卷时长',
  `tags` varchar(255) DEFAULT NULL COMMENT '试卷标记信息',
  `status` int(11) NOT NULL COMMENT '任务状态',
  PRIMARY KEY (`id`),
  UNIQUE KEY `index1` (`student_id`) USING BTREE,
  KEY `index2` (`exam_id`,`subject_code`,`status`) USING BTREE,
  KEY `index3` (`status`,`marker_id`,`marker_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='评卷任务表';



# Dump of table m_special_tag
# ------------------------------------------------------------

DROP TABLE IF EXISTS `m_special_tag`;

CREATE TABLE `m_special_tag` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `library_id` int(11) NOT NULL COMMENT '评卷任务ID',
  `tag_name` varchar(128) NOT NULL DEFAULT '' COMMENT '标记名称',
  `position_x` double NOT NULL COMMENT 'X轴坐标',
  `position_y` double NOT NULL COMMENT 'Y轴坐标',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='评卷特殊标记表';



# Dump of table m_track
# ------------------------------------------------------------

DROP TABLE IF EXISTS `m_track`;

CREATE TABLE `m_track` (
  `student_id` int(11) NOT NULL COMMENT '考生ID',
  `question_number` varchar(128) NOT NULL DEFAULT '' COMMENT '题号',
  `number` int(11) NOT NULL COMMENT '序号',
  `exam_id` int(11) NOT NULL COMMENT '考试ID',
  `subject_code` varchar(255) NOT NULL DEFAULT '' COMMENT '科目代码',
  `marker_id` int(11) NOT NULL COMMENT '评卷员ID',
  `score` double NOT NULL COMMENT '给分',
  `position_x` double NOT NULL COMMENT 'X轴坐标',
  `position_y` double NOT NULL COMMENT 'Y轴坐标',
  PRIMARY KEY (`student_id`,`question_number`,`number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='评卷轨迹表';



# Dump of table s_score_rate
# ------------------------------------------------------------

DROP TABLE IF EXISTS `s_score_rate`;

CREATE TABLE `s_score_rate` (
  `exam_id` int(11) NOT NULL COMMENT '考试ID',
  `campus_name` varchar(255) NOT NULL DEFAULT '' COMMENT '学习中心',
  `subject_code` varchar(32) NOT NULL DEFAULT '' COMMENT '科目代码',
  `main_number` int(11) NOT NULL COMMENT '大题号',
  `sub_number` int(11) NOT NULL COMMENT '小题号',
  `is_objective` tinyint(1) NOT NULL COMMENT '是否客观题',
  `main_title` varchar(128) DEFAULT NULL COMMENT '大题名称',
  `total_score` double DEFAULT NULL COMMENT '总分',
  `avg_score` double DEFAULT NULL COMMENT '平均分',
  PRIMARY KEY (`exam_id`,`campus_name`,`subject_code`,`main_number`,`sub_number`,`is_objective`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='得分统计表';
