exam_reserve_db.sql 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. create table t_system_property
  2. (
  3. id bigint not null auto_increment,
  4. create_time bigint not null comment '创建时间',
  5. update_time bigint not null comment '更新时间',
  6. prop_key varchar(50) not null comment '属性键',
  7. prop_value varchar(500) not null comment '属性值',
  8. org_id bigint comment '所属机构ID(学校)',
  9. PRIMARY KEY (id),
  10. UNIQUE KEY IDX_01 (org_id, prop_key)
  11. ) comment '系统属性表';
  12. create table t_org
  13. (
  14. id bigint not null auto_increment,
  15. create_time bigint not null comment '创建时间',
  16. update_time bigint not null comment '更新时间',
  17. enable bit(1) not null comment '是否启用',
  18. name varchar(50) not null comment '机构名称',
  19. PRIMARY KEY (id)
  20. ) comment '机构表';
  21. create table t_user
  22. (
  23. id bigint not null auto_increment,
  24. create_time bigint not null comment '创建时间',
  25. update_time bigint not null comment '更新时间',
  26. enable bit(1) not null comment '是否启用',
  27. role varchar(20) not null comment '角色类型:学校管理员;教学点管理员',
  28. name varchar(50) not null comment '姓名',
  29. login_name varchar(50) not null comment '登录名',
  30. password varchar(64) not null comment '密码',
  31. mobile varchar(20) comment '联系方式',
  32. category_id bigint comment '所属教学点ID,角色为教学点管理员,必填',
  33. org_id bigint not null comment '所属机构ID(学校)',
  34. first_login bit(1) comment '第一次修改密码标志',
  35. PRIMARY KEY (id),
  36. UNIQUE KEY IDX_01 (org_id, login_name),
  37. KEY IDX_02 (role),
  38. KEY IDX_03 (category_id)
  39. ) comment '用户表';
  40. create table t_student
  41. (
  42. id bigint not null auto_increment,
  43. create_time bigint not null comment '创建时间',
  44. update_time bigint not null comment '更新时间',
  45. org_id bigint not null comment '所属机构ID(学校)',
  46. name varchar(50) not null comment '考生姓名',
  47. identity_number varchar(20) not null comment '证件号',
  48. student_code varchar(20) not null comment '学号',
  49. password varchar(64) not null comment '密码',
  50. photo_path varchar(100) comment '头像相对路径',
  51. gender varchar(10) comment '性别',
  52. open_id varchar(50) comment '微信OID',
  53. uid varchar(50) comment '微信UID',
  54. apply_task_id bigint not null comment '所属预约任务ID',
  55. category_id bigint not null comment '所属教学点ID',
  56. apply_number int not null comment '允许预约时段数量',
  57. apply_finished bit(1) not null comment '预约时段是否全部完成',
  58. PRIMARY KEY (id),
  59. UNIQUE KEY IDX_01 (apply_task_id, student_code),
  60. UNIQUE KEY IDX_02 (apply_task_id, open_id),
  61. KEY IDX_03 (category_id),
  62. KEY IDX_04 (identity_number)
  63. ) comment '考生表';
  64. create table t_category
  65. (
  66. id bigint not null auto_increment,
  67. create_time bigint not null comment '创建时间',
  68. update_time bigint not null comment '更新时间',
  69. enable bit(1) not null comment '是否启用',
  70. org_id bigint not null comment '所属机构ID(学校)',
  71. parent_id bigint not null default 0 comment '父级ID,顶级值为0',
  72. code varchar(20) not null comment '分类代码',
  73. name varchar(50) not null comment '分类名称',
  74. level int not null comment '层级,第一级值为1',
  75. capacity int null default 0 comment '容量',
  76. self_apply_enable bit(1) null default 1 comment '针对教学点,是否开启考生自主预约',
  77. PRIMARY KEY (id),
  78. UNIQUE KEY IDX_01 (org_id, code),
  79. KEY IDX_02 (parent_id),
  80. KEY IDX_03 (level)
  81. ) comment '数据分类表';
  82. create table t_exam_site
  83. (
  84. id bigint not null auto_increment,
  85. create_time bigint not null comment '创建时间',
  86. update_time bigint not null comment '更新时间',
  87. enable bit(1) not null comment '是否启用',
  88. code varchar(20) not null comment '考点代码',
  89. name varchar(100) not null comment '考点名称',
  90. category_id bigint not null comment '所属教学点ID',
  91. capacity int comment '机房容量',
  92. address varchar(200) comment '考点地址',
  93. guide longtext comment '考点指引',
  94. PRIMARY KEY (id),
  95. UNIQUE KEY IDX_01 (category_id, code)
  96. ) comment '考点表';
  97. create table t_exam_room
  98. (
  99. id bigint not null auto_increment,
  100. create_time bigint not null comment '创建时间',
  101. update_time bigint not null comment '更新时间',
  102. enable bit(1) not null comment '是否启用',
  103. code varchar(20) not null comment '考场代码',
  104. name varchar(100) not null comment '考场名称',
  105. exam_site_id bigint not null comment '所属考点ID',
  106. address varchar(200) comment '考场地址',
  107. capacity int comment '机房容量',
  108. PRIMARY KEY (id),
  109. UNIQUE KEY IDX_01 (exam_site_id, code)
  110. ) comment '考场表';
  111. create table t_apply_task
  112. (
  113. id bigint not null auto_increment,
  114. create_time bigint not null comment '创建时间',
  115. update_time bigint not null comment '更新时间',
  116. enable bit(1) not null comment '是否启用',
  117. org_id bigint not null comment '所属机构ID(学校)',
  118. name varchar(50) not null comment '任务名称',
  119. allow_apply_days int not null comment '考前多少天,禁止考生自主预约',
  120. allow_apply_cancel_days int not null comment '考前多少天,禁止考生自主取消预约',
  121. self_apply_start_time bigint not null comment '自主预约起始时间,只能预约本教学点下的考点',
  122. self_apply_end_time bigint not null comment '自主预约截止时间,只能预约本教学点下的考点',
  123. open_apply_start_time bigint not null comment '开放式预约起始时间,可以在不同教学点间预约',
  124. open_apply_end_time bigint not null comment '开放式预约截止时间,可以在不同教学点间预约',
  125. notice longtext comment '考试说明',
  126. PRIMARY KEY (id),
  127. KEY IDX_01 (org_id)
  128. ) comment '预约任务表';
  129. create table t_time_period
  130. (
  131. id bigint not null auto_increment,
  132. create_time bigint not null comment '创建时间',
  133. update_time bigint not null comment '更新时间',
  134. apply_task_id bigint not null comment '所属预约任务ID',
  135. start_time bigint not null comment '预约起始时间',
  136. end_time bigint not null comment '预约截止时间',
  137. PRIMARY KEY (id),
  138. KEY IDX_01 (apply_task_id),
  139. KEY IDX_02 (start_time),
  140. KEY IDX_03 (end_time)
  141. ) comment '预约任务的时段表';
  142. create table t_student_apply
  143. (
  144. id bigint not null auto_increment,
  145. create_time bigint not null comment '创建时间',
  146. update_time bigint not null comment '更新时间',
  147. exam_site_id bigint not null comment '预约的考点ID',
  148. time_period_id bigint not null comment '预约时段ID',
  149. student_id bigint not null comment '考生ID',
  150. cancel bit(1) not null comment '是否取消预约',
  151. exam_room_id bigint comment '预约的考场ID',
  152. ticket_number varchar(50) comment '准考证号',
  153. seat_number varchar(20) comment '座位号',
  154. operate_id bigint comment '操作人ID',
  155. PRIMARY KEY (id),
  156. UNIQUE KEY IDX_01 (exam_site_id, time_period_id, student_id),
  157. KEY IDX_02 (student_id),
  158. KEY IDX_03 (exam_room_id),
  159. KEY IDX_04 (ticket_number)
  160. ) comment '考生预约记录表';
  161. create table t_student_import_task
  162. (
  163. id bigint not null auto_increment,
  164. create_time bigint not null comment '创建时间',
  165. update_time bigint not null comment '更新时间',
  166. operate_id bigint not null comment '操作人ID',
  167. apply_task_id bigint not null comment '所属预约任务ID',
  168. type varchar(20) not null comment '导入类型',
  169. status varchar(20) not null comment '执行状态',
  170. file_path varchar(200) not null comment '导入文件相对路径',
  171. message text comment '执行结果信息',
  172. PRIMARY KEY (id),
  173. KEY IDX_01 (apply_task_id),
  174. KEY IDX_02 (type),
  175. KEY IDX_03 (status)
  176. ) comment '考生导入任务表';
  177. create table t_operate_log
  178. (
  179. id bigint not null auto_increment,
  180. create_time bigint not null comment '创建时间',
  181. update_time bigint not null comment '更新时间',
  182. operate_id bigint not null comment '操作人ID',
  183. event_type varchar(20) not null comment '事件类型,如:考生取消预约、用户登录等',
  184. content text comment '操作内容(JSON)',
  185. PRIMARY KEY (id),
  186. KEY IDX_01 (event_type),
  187. KEY IDX_02 (operate_id)
  188. ) comment '操作日志表';
  189. create table t_async_task
  190. (
  191. id bigint NOT NULL AUTO_INCREMENT,
  192. create_time bigint NOT NULL COMMENT '创建时间',
  193. update_time bigint NOT NULL COMMENT '更新时间',
  194. operate_id bigint NOT NULL COMMENT '操作人ID',
  195. type varchar(50) NOT NULL COMMENT '任务类型',
  196. status varchar(10) NOT NULL COMMENT '执行状态任务状态,INIT:未开始,RUNNING:进行中,FINISH:已完成',
  197. result varchar(10) NULL COMMENT '执行结果,SUCCESS:成功,ERROR:失败',
  198. import_file_name varchar(100) NULL COMMENT '导入文件名称',
  199. import_file_path varchar(500) NULL COMMENT '导入文件路径',
  200. export_file_path varchar(500) NULL COMMENT '导出文件路径',
  201. summary text NULL COMMENT '执行摘要',
  202. PRIMARY KEY (id),
  203. INDEX IDX_01 (type),
  204. INDEX IDX_02 (status),
  205. INDEX IDX_03 (result)
  206. ) COMMENT = '异步任务表';
  207. create table t_student_course
  208. (
  209. id bigint NOT NULL AUTO_INCREMENT,
  210. create_time bigint NOT NULL COMMENT '创建时间',
  211. update_time bigint NOT NULL COMMENT '更新时间',
  212. student_id bigint NOT NULL COMMENT '考生ID',
  213. course_code varchar(20) NOT NULL COMMENT '科目代码',
  214. course_name varchar(50) NULL COMMENT '科目名称',
  215. PRIMARY KEY (id),
  216. UNIQUE INDEX IDX_01 (course_code, student_id),
  217. INDEX IDX_02 (student_id)
  218. ) COMMENT = '考生科目表';
  219. create table t_time_period_exam_site
  220. (
  221. id bigint NOT NULL AUTO_INCREMENT,
  222. create_time bigint NOT NULL COMMENT '创建时间',
  223. update_time bigint NOT NULL COMMENT '更新时间',
  224. operate_id bigint NOT NULL COMMENT '操作人',
  225. exam_site_id bigint NOT NULL COMMENT '考点ID',
  226. time_period_id bigint NOT NULL COMMENT '预约时段ID',
  227. enable bit(1) NOT NULL COMMENT '是否开启',
  228. PRIMARY KEY (id),
  229. UNIQUE INDEX IDX_01 (exam_site_id, time_period_id),
  230. INDEX IDX_02 (time_period_id)
  231. ) COMMENT = '考点预约时段表';
  232. -- 基础数据
  233. insert into t_org(id, name, enable, create_time, update_time)
  234. values (1, '广东开放大学', 1, unix_timestamp() * 1000, unix_timestamp() * 1000);
  235. insert into t_system_property(org_id, prop_key, prop_value, create_time, update_time)
  236. values (1, 'CATEGORY_LEVEL', '[{"level":1,"title":"城市"},{"level":2,"title":"教学点"}]', unix_timestamp() * 1000,
  237. unix_timestamp() * 1000);
  238. insert into t_user (org_id, role, name, login_name, password, mobile, category_id, enable, create_time, update_time)
  239. values (1, 'ADMIN', '学校管理员', 'admin', UPPER(SHA2('qmth87863577', 256)), null, null, 1, unix_timestamp() * 1000,
  240. unix_timestamp() * 1000);
  241. -- 城市初始化
  242. INSERT INTO t_category VALUES (1, 1717121654419, 1717121654419, b'1', 1, 0, '4401', '广州市', 1, 0,1);
  243. INSERT INTO t_category VALUES (2, 1717121654419, 1717121654419, b'1', 1, 0, '4402', '韶关市', 1, 0,1);
  244. INSERT INTO t_category VALUES (3, 1717121654419, 1717121654419, b'1', 1, 0, '4403', '深圳市', 1, 0,1);
  245. INSERT INTO t_category VALUES (4, 1717121654419, 1717121654419, b'1', 1, 0, '4404', '珠海市', 1, 0,1);
  246. INSERT INTO t_category VALUES (5, 1717121654419, 1717121654419, b'1', 1, 0, '4405', '汕头市', 1, 0,1);
  247. INSERT INTO t_category VALUES (6, 1717121654419, 1717121654419, b'1', 1, 0, '4406', '佛山市', 1, 0,1);
  248. INSERT INTO t_category VALUES (7, 1717121654419, 1717121654419, b'1', 1, 0, '4407', '江门市', 1, 0,1);
  249. INSERT INTO t_category VALUES (8, 1717121654419, 1717121654419, b'1', 1, 0, '4408', '湛江市', 1, 0,1);
  250. INSERT INTO t_category VALUES (9, 1717121654419, 1717121654419, b'1', 1, 0, '4409', '茂名市', 1, 0,1);
  251. INSERT INTO t_category VALUES (10, 1717121654419, 1717121654419, b'1', 1, 0, '4412', '肇庆市', 1, 0,1);
  252. INSERT INTO t_category VALUES (11, 1717121654419, 1717121654419, b'1', 1, 0, '4413', '惠州市', 1, 0,1);
  253. INSERT INTO t_category VALUES (12, 1717121654419, 1717121654419, b'1', 1, 0, '4414', '梅州市', 1, 0,1);
  254. INSERT INTO t_category VALUES (13, 1717121654419, 1717121654419, b'1', 1, 0, '4415', '汕尾市', 1, 0,1);
  255. INSERT INTO t_category VALUES (14, 1717121654419, 1717121654419, b'1', 1, 0, '4416', '河源市', 1, 0,1);
  256. INSERT INTO t_category VALUES (15, 1717121654419, 1717121654419, b'1', 1, 0, '4417', '阳江市', 1, 0,1);
  257. INSERT INTO t_category VALUES (16, 1717121654419, 1717121654419, b'1', 1, 0, '4418', '清远市', 1, 0,1);
  258. INSERT INTO t_category VALUES (17, 1717121654419, 1717121654419, b'1', 1, 0, '4419', '东莞市', 1, 0,1);
  259. INSERT INTO t_category VALUES (18, 1717121654419, 1717121654419, b'1', 1, 0, '4420', '中山市', 1, 0,1);
  260. INSERT INTO t_category VALUES (19, 1717121654419, 1717121654419, b'1', 1, 0, '4451', '潮州市', 1, 0,1);
  261. INSERT INTO t_category VALUES (20, 1717121654419, 1717121654419, b'1', 1, 0, '4452', '揭阳市', 1, 0,1);
  262. INSERT INTO t_category VALUES (21, 1717121654419, 1717121654419, b'1', 1, 0, '4453', '云浮市', 1, 0,1);