init.sql 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. DROP TABLE IF EXISTS `mps_wxapp_info`;
  2. CREATE TABLE `mps_wxapp_info` (
  3. `id` bigint NOT NULL AUTO_INCREMENT,
  4. `create_time` datetime DEFAULT NULL,
  5. `update_time` datetime DEFAULT NULL,
  6. `creator_id` bigint DEFAULT NULL,
  7. `updater_id` bigint DEFAULT NULL,
  8. `openid` varchar(255) COLLATE utf8_bin NOT NULL,
  9. `phone` varchar(255) COLLATE utf8_bin NOT NULL,
  10. PRIMARY KEY (`id`),
  11. UNIQUE KEY `IDX_WXAPP_INFO_01` (`openid`)
  12. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  13. DROP TABLE IF EXISTS `mps_wxapp_access_token`;
  14. CREATE TABLE `mps_wxapp_access_token` (
  15. `id` bigint NOT NULL AUTO_INCREMENT,
  16. `create_time` datetime DEFAULT NULL,
  17. `update_time` datetime DEFAULT NULL,
  18. `creator_id` bigint DEFAULT NULL,
  19. `updater_id` bigint DEFAULT NULL,
  20. `access_token` varchar(512) COLLATE utf8_bin DEFAULT NULL,
  21. `expires_time` bigint DEFAULT NULL,
  22. PRIMARY KEY (`id`)
  23. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  24. -- ----------------------------
  25. -- Table structure for mps_course
  26. -- ----------------------------
  27. DROP TABLE IF EXISTS `mps_course`;
  28. CREATE TABLE `mps_course` (
  29. `id` bigint NOT NULL AUTO_INCREMENT,
  30. `create_time` datetime DEFAULT NULL,
  31. `update_time` datetime DEFAULT NULL,
  32. `creator_id` bigint DEFAULT NULL,
  33. `updater_id` bigint DEFAULT NULL,
  34. `code` varchar(255) COLLATE utf8_bin NOT NULL,
  35. `name` varchar(255) COLLATE utf8_bin NOT NULL,
  36. `school_id` bigint NOT NULL,
  37. PRIMARY KEY (`id`),
  38. UNIQUE KEY `IDX_COURSE_01` (`school_id`,`code`)
  39. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  40. -- ----------------------------
  41. -- Table structure for mps_exam
  42. -- ----------------------------
  43. DROP TABLE IF EXISTS `mps_exam`;
  44. CREATE TABLE `mps_exam` (
  45. `id` bigint NOT NULL AUTO_INCREMENT,
  46. `create_time` datetime DEFAULT NULL,
  47. `update_time` datetime DEFAULT NULL,
  48. `creator_id` bigint DEFAULT NULL,
  49. `updater_id` bigint DEFAULT NULL,
  50. `exam_status` varchar(255) COLLATE utf8_bin NOT NULL,
  51. `name` varchar(255) COLLATE utf8_bin NOT NULL,
  52. `code` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  53. `school_id` bigint NOT NULL,
  54. PRIMARY KEY (`id`),
  55. UNIQUE KEY `IDX_EXAM_01` (`school_id`,`name`),
  56. UNIQUE KEY `IDX_EXAM_02` (`school_id`,`code`)
  57. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  58. -- ----------------------------
  59. -- Table structure for mps_paper
  60. -- ----------------------------
  61. DROP TABLE IF EXISTS `mps_paper`;
  62. CREATE TABLE `mps_paper` (
  63. `id` bigint NOT NULL AUTO_INCREMENT,
  64. `create_time` datetime DEFAULT NULL,
  65. `update_time` datetime DEFAULT NULL,
  66. `creator_id` bigint DEFAULT NULL,
  67. `updater_id` bigint DEFAULT NULL,
  68. `course_id` bigint NOT NULL,
  69. `exam_id` bigint NOT NULL,
  70. `group_finish` bit(1) NOT NULL,
  71. `group_info` text COLLATE utf8_bin,
  72. `objective_score` double NOT NULL,
  73. `paper_type` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  74. `school_id` bigint NOT NULL,
  75. `struct_info` text COLLATE utf8_bin,
  76. `subjective_score` double NOT NULL,
  77. `total_score` double NOT NULL,
  78. PRIMARY KEY (`id`),
  79. UNIQUE KEY `IDX_PAPER_01` (`school_id`,`exam_id`,`course_id`)
  80. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  81. -- ----------------------------
  82. -- Table structure for mps_paper_detail
  83. -- ----------------------------
  84. DROP TABLE IF EXISTS `mps_paper_detail`;
  85. CREATE TABLE `mps_paper_detail` (
  86. `id` bigint NOT NULL AUTO_INCREMENT,
  87. `create_time` datetime DEFAULT NULL,
  88. `update_time` datetime DEFAULT NULL,
  89. `creator_id` bigint DEFAULT NULL,
  90. `updater_id` bigint DEFAULT NULL,
  91. `name` varchar(255) COLLATE utf8_bin NOT NULL,
  92. `number` int NOT NULL,
  93. `paper_id` bigint NOT NULL,
  94. PRIMARY KEY (`id`),
  95. UNIQUE KEY `IDX_PAPER_DETAIL_01` (`paper_id`,`number`)
  96. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  97. -- ----------------------------
  98. -- Table structure for mps_paper_detail_unit
  99. -- ----------------------------
  100. DROP TABLE IF EXISTS `mps_paper_detail_unit`;
  101. CREATE TABLE `mps_paper_detail_unit` (
  102. `id` bigint NOT NULL AUTO_INCREMENT,
  103. `create_time` datetime DEFAULT NULL,
  104. `update_time` datetime DEFAULT NULL,
  105. `creator_id` bigint DEFAULT NULL,
  106. `updater_id` bigint DEFAULT NULL,
  107. `detail_id` bigint NOT NULL,
  108. `detail_number` int NOT NULL,
  109. `number` int NOT NULL,
  110. `objective` bit(1) NOT NULL,
  111. `paper_id` bigint NOT NULL,
  112. `score` double NOT NULL,
  113. `score_step` double NOT NULL,
  114. PRIMARY KEY (`id`),
  115. UNIQUE KEY `IDX_PAPER_DETAIL_UNIT_01` (`paper_id`,`detail_id`,`number`)
  116. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  117. -- ----------------------------
  118. -- Table structure for mps_paper_group
  119. -- ----------------------------
  120. DROP TABLE IF EXISTS `mps_paper_group`;
  121. CREATE TABLE `mps_paper_group` (
  122. `id` bigint NOT NULL AUTO_INCREMENT,
  123. `create_time` datetime DEFAULT NULL,
  124. `update_time` datetime DEFAULT NULL,
  125. `creator_id` bigint DEFAULT NULL,
  126. `updater_id` bigint DEFAULT NULL,
  127. `number` int NOT NULL,
  128. `paper_id` bigint NOT NULL,
  129. PRIMARY KEY (`id`),
  130. UNIQUE KEY `IDX_PAPER_GROUP_01` (`paper_id`,`number`)
  131. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  132. -- ----------------------------
  133. -- Table structure for mps_paper_group_unit
  134. -- ----------------------------
  135. DROP TABLE IF EXISTS `mps_paper_group_unit`;
  136. CREATE TABLE `mps_paper_group_unit` (
  137. `id` bigint NOT NULL AUTO_INCREMENT,
  138. `create_time` datetime DEFAULT NULL,
  139. `update_time` datetime DEFAULT NULL,
  140. `creator_id` bigint DEFAULT NULL,
  141. `updater_id` bigint DEFAULT NULL,
  142. `group_id` bigint NOT NULL,
  143. `paper_id` bigint NOT NULL,
  144. `unit_id` bigint NOT NULL,
  145. PRIMARY KEY (`id`),
  146. UNIQUE KEY `IDX_PAPER_GROUP_UNIT_01` (`paper_id`,`group_id`,`unit_id`),
  147. UNIQUE KEY `IDX_PAPER_GROUP_UNIT_02` (`unit_id`)
  148. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  149. -- ----------------------------
  150. -- Table structure for mps_privilege
  151. -- ----------------------------
  152. DROP TABLE IF EXISTS `mps_privilege`;
  153. CREATE TABLE `mps_privilege` (
  154. `id` bigint NOT NULL AUTO_INCREMENT,
  155. `create_time` datetime DEFAULT NULL,
  156. `update_time` datetime DEFAULT NULL,
  157. `creator_id` bigint DEFAULT NULL,
  158. `updater_id` bigint DEFAULT NULL,
  159. `code` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  160. `description` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  161. `ext1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  162. `ext2` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  163. `ext3` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  164. `ext4` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  165. `ext5` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  166. `name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  167. `parent_id` bigint DEFAULT NULL,
  168. `seq` int DEFAULT NULL,
  169. PRIMARY KEY (`id`),
  170. UNIQUE KEY `IDX_PRIVILEGE_01` (`code`)
  171. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  172. -- ----------------------------
  173. -- Table structure for mps_role
  174. -- ----------------------------
  175. DROP TABLE IF EXISTS `mps_role`;
  176. CREATE TABLE `mps_role` (
  177. `id` bigint NOT NULL AUTO_INCREMENT,
  178. `create_time` datetime DEFAULT NULL,
  179. `update_time` datetime DEFAULT NULL,
  180. `creator_id` bigint DEFAULT NULL,
  181. `updater_id` bigint DEFAULT NULL,
  182. `code` varchar(255) COLLATE utf8_bin NOT NULL,
  183. `name` varchar(255) COLLATE utf8_bin NOT NULL,
  184. `school_id` bigint NOT NULL,
  185. PRIMARY KEY (`id`),
  186. UNIQUE KEY `IDX_ROLE_01` (`school_id`,`code`)
  187. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  188. -- ----------------------------
  189. -- Table structure for mps_role_privilege_relation
  190. -- ----------------------------
  191. DROP TABLE IF EXISTS `mps_role_privilege_relation`;
  192. CREATE TABLE `mps_role_privilege_relation` (
  193. `school_id` bigint NOT NULL,
  194. `role_id` bigint NOT NULL,
  195. `privilege_id` bigint NOT NULL,
  196. `create_time` datetime DEFAULT NULL,
  197. `update_time` datetime DEFAULT NULL,
  198. `creator_id` bigint DEFAULT NULL,
  199. `updater_id` bigint DEFAULT NULL,
  200. PRIMARY KEY (`school_id`,`role_id`,`privilege_id`)
  201. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  202. -- ----------------------------
  203. -- Table structure for mps_school
  204. -- ----------------------------
  205. DROP TABLE IF EXISTS `mps_school`;
  206. CREATE TABLE `mps_school` (
  207. `id` bigint NOT NULL AUTO_INCREMENT,
  208. `create_time` datetime DEFAULT NULL,
  209. `update_time` datetime DEFAULT NULL,
  210. `creator_id` bigint DEFAULT NULL,
  211. `updater_id` bigint DEFAULT NULL,
  212. `contacts` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  213. `enable` bit(1) NOT NULL,
  214. `name` varchar(255) COLLATE utf8_bin NOT NULL,
  215. `code` varchar(255) COLLATE utf8_bin NOT NULL,
  216. `region` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  217. `telephone` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  218. PRIMARY KEY (`id`),
  219. UNIQUE KEY `IDX_SCHOOL_01` (`name`),
  220. UNIQUE KEY `IDX_SCHOOL_02` (`code`)
  221. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  222. -- ----------------------------
  223. -- Table structure for mps_user
  224. -- ----------------------------
  225. DROP TABLE IF EXISTS `mps_user`;
  226. CREATE TABLE `mps_user` (
  227. `id` bigint NOT NULL AUTO_INCREMENT,
  228. `create_time` datetime DEFAULT NULL,
  229. `update_time` datetime DEFAULT NULL,
  230. `creator_id` bigint DEFAULT NULL,
  231. `updater_id` bigint DEFAULT NULL,
  232. `enable` bit(1) NOT NULL,
  233. `login_name` varchar(255) COLLATE utf8_bin NOT NULL,
  234. `name` varchar(255) COLLATE utf8_bin NOT NULL,
  235. `password` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  236. `role_id` bigint NOT NULL,
  237. `school_id` bigint NOT NULL,
  238. PRIMARY KEY (`id`),
  239. UNIQUE KEY `IDX_USER_01` (`login_name`)
  240. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  241. -- ----------------------------
  242. -- Table structure for mps_user_course_relation
  243. -- ----------------------------
  244. DROP TABLE IF EXISTS `mps_user_course_relation`;
  245. CREATE TABLE `mps_user_course_relation` (
  246. `user_id` bigint NOT NULL,
  247. `course_id` bigint NOT NULL,
  248. `create_time` datetime DEFAULT NULL,
  249. `update_time` datetime DEFAULT NULL,
  250. `creator_id` bigint DEFAULT NULL,
  251. `updater_id` bigint DEFAULT NULL,
  252. PRIMARY KEY (`user_id`,`course_id`)
  253. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  254. INSERT INTO `mps_wxapp_access_token` (`id`) VALUES (1);
  255. INSERT INTO `mps_school` (`id`, `create_time`, `update_time`, `enable`, `name`) VALUES (1, now(), now(), 1, '启明泰和');
  256. INSERT INTO `mps_privilege` (`id`, `create_time`, `update_time`, `code`, `description`, `ext1`, `ext2`, `ext3`, `ext4`, `ext5`, `name`, `parent_id`, `seq`) VALUES (1, now(), now(), 'index_school', NULL, 'menu', NULL, NULL, NULL, '/struct/school', '学校管理', NULL, 1);
  257. INSERT INTO `mps_privilege` (`id`, `create_time`, `update_time`, `code`, `description`, `ext1`, `ext2`, `ext3`, `ext4`, `ext5`, `name`, `parent_id`, `seq`) VALUES (2, now(), now(), 'exam_manage', '', 'menu', '', '', '', '', '考试管理', NULL, 2);
  258. INSERT INTO `mps_privilege` (`id`, `create_time`, `update_time`, `code`, `description`, `ext1`, `ext2`, `ext3`, `ext4`, `ext5`, `name`, `parent_id`, `seq`) VALUES (3, now(), now(), 'index_exam', '', 'menu', '', '', '', '/struct/exam', '考试批次管理', 2, 1);
  259. INSERT INTO `mps_privilege` (`id`, `create_time`, `update_time`, `code`, `description`, `ext1`, `ext2`, `ext3`, `ext4`, `ext5`, `name`, `parent_id`, `seq`) VALUES (4, now(), now(), 'index_paper', '', 'menu', '', '', '', '/struct/paper', '科目试卷结构', 2, 2);
  260. INSERT INTO `mps_privilege` (`id`, `create_time`, `update_time`, `code`, `description`, `ext1`, `ext2`, `ext3`, `ext4`, `ext5`, `name`, `parent_id`, `seq`) VALUES (5, now(), now(), 'index_user', '', 'menu', '', '', '', '/struct/user', '用户管理', NULL, 3);
  261. INSERT INTO `mps_role` (`id`, `create_time`, `update_time`, `code`, `name`, `school_id`) VALUES (1, now(), now(), 'SUPER_ADMIN', '超级管理员', -1);
  262. INSERT INTO `mps_role` (`id`, `create_time`, `update_time`, `code`, `name`, `school_id`) VALUES (2, now(), now(), 'SCHOOL_ADMIN', '机构管理员', -1);
  263. INSERT INTO `mps_role` (`id`, `create_time`, `update_time`, `code`, `name`, `school_id`) VALUES (3, now(), now(), 'SECTION_LEADER', '科组长', -1);
  264. INSERT INTO `mps_role_privilege_relation` (`privilege_id`, `role_id`, `school_id`, `create_time`, `update_time`) VALUES (1, 2, -1, now(), now());
  265. INSERT INTO `mps_role_privilege_relation` (`privilege_id`, `role_id`, `school_id`, `create_time`, `update_time`) VALUES (2, 2, -1, now(), now());
  266. INSERT INTO `mps_role_privilege_relation` (`privilege_id`, `role_id`, `school_id`, `create_time`, `update_time`) VALUES (3, 2, -1, now(), now());
  267. INSERT INTO `mps_role_privilege_relation` (`privilege_id`, `role_id`, `school_id`, `create_time`, `update_time`) VALUES (4, 2, -1, now(), now());
  268. INSERT INTO `mps_role_privilege_relation` (`privilege_id`, `role_id`, `school_id`, `create_time`, `update_time`) VALUES (5, 2, -1, now(), now());
  269. INSERT INTO `mps_user` (`id`, `create_time`, `update_time`, `enable`, `login_name`, `name`, `password`, `school_id`, `role_id`) VALUES (1, now(), now(), 1, 'admin1', '超管1', UPPER(SHA2('0',256)), 1, 1);
  270. INSERT INTO `mps_user` (`id`, `create_time`, `update_time`, `enable`, `login_name`, `name`, `password`, `school_id`, `role_id`) VALUES (2, now(), now(), 1, 'admin2', '超管2', UPPER(SHA2('0',256)), 1, 1);
  271. INSERT INTO `mps_user` (`id`, `create_time`, `update_time`, `enable`, `login_name`, `name`, `password`, `school_id`, `role_id`) VALUES (3, now(), now(), 1, 'admin3', '超管3', UPPER(SHA2('0',256)), 1, 1);
  272. INSERT INTO `mps_user` (`id`, `create_time`, `update_time`, `enable`, `login_name`, `name`, `password`, `school_id`, `role_id`) VALUES (4, now(), now(), 1, 'admin4', '超管4', UPPER(SHA2('0',256)), 1, 1);
  273. INSERT INTO `mps_user` (`id`, `create_time`, `update_time`, `enable`, `login_name`, `name`, `password`, `school_id`, `role_id`) VALUES (5, now(), now(), 1, 'admin5', '超管5', UPPER(SHA2('0',256)), 1, 1);