exam_reserve_db.sql 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 (open_id, uid),
  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. PRIMARY KEY (id),
  77. UNIQUE KEY IDX_01 (org_id, code),
  78. KEY IDX_02 (parent_id),
  79. KEY IDX_03 (level)
  80. ) comment '数据分类表';
  81. create table t_exam_site
  82. (
  83. id bigint not null auto_increment,
  84. create_time bigint not null comment '创建时间',
  85. update_time bigint not null comment '更新时间',
  86. enable bit(1) not null comment '是否启用',
  87. code varchar(20) not null comment '考点代码',
  88. name varchar(100) not null comment '考点名称',
  89. category_id bigint not null comment '所属教学点ID',
  90. capacity int comment '机房容量',
  91. address varchar(200) comment '考点地址',
  92. guide longtext comment '考点指引',
  93. PRIMARY KEY (id),
  94. UNIQUE KEY IDX_01 (category_id, code)
  95. ) comment '考点表';
  96. create table t_exam_room
  97. (
  98. id bigint not null auto_increment,
  99. create_time bigint not null comment '创建时间',
  100. update_time bigint not null comment '更新时间',
  101. enable bit(1) not null comment '是否启用',
  102. code varchar(20) not null comment '考场代码',
  103. name varchar(100) not null comment '考场名称',
  104. exam_site_id bigint not null comment '所属考点ID',
  105. address varchar(200) comment '考场地址',
  106. capacity int comment '机房容量',
  107. PRIMARY KEY (id),
  108. UNIQUE KEY IDX_01 (exam_site_id, code)
  109. ) comment '考场表';
  110. create table t_apply_task
  111. (
  112. id bigint not null auto_increment,
  113. create_time bigint not null comment '创建时间',
  114. update_time bigint not null comment '更新时间',
  115. enable bit(1) not null comment '是否启用',
  116. org_id bigint not null comment '所属机构ID(学校)',
  117. name varchar(50) not null comment '任务名称',
  118. allow_apply_days int not null comment '考前多少天,禁止考生自主预约',
  119. allow_apply_cancel_days int not null comment '考前多少天,禁止考生自主取消预约',
  120. self_apply_start_time bigint not null comment '自主预约起始时间,只能预约本教学点下的考点',
  121. self_apply_end_time bigint not null comment '自主预约截止时间,只能预约本教学点下的考点',
  122. open_apply_start_time bigint not null comment '开放式预约起始时间,可以在不同教学点间预约',
  123. open_apply_end_time bigint not null comment '开放式预约截止时间,可以在不同教学点间预约',
  124. notice longtext comment '考试说明',
  125. PRIMARY KEY (id),
  126. KEY IDX_01 (org_id)
  127. ) comment '预约任务表';
  128. create table t_time_period
  129. (
  130. id bigint not null auto_increment,
  131. create_time bigint not null comment '创建时间',
  132. update_time bigint not null comment '更新时间',
  133. apply_task_id bigint not null comment '所属预约任务ID',
  134. start_time bigint not null comment '预约起始时间',
  135. end_time bigint not null comment '预约截止时间',
  136. PRIMARY KEY (id),
  137. KEY IDX_01 (apply_task_id),
  138. KEY IDX_02 (start_time),
  139. KEY IDX_03 (end_time)
  140. ) comment '预约任务的时段表';
  141. create table t_student_apply
  142. (
  143. id bigint not null auto_increment,
  144. create_time bigint not null comment '创建时间',
  145. update_time bigint not null comment '更新时间',
  146. exam_site_id bigint not null comment '预约的考点ID',
  147. time_period_id bigint not null comment '预约时段ID',
  148. student_id bigint not null comment '考生ID',
  149. cancel bit(1) not null comment '是否取消预约',
  150. exam_room_id bigint comment '预约的考场ID',
  151. ticket_number varchar(50) comment '准考证号',
  152. seat_number varchar(20) comment '座位号',
  153. operate_id bigint comment '操作人ID',
  154. PRIMARY KEY (id),
  155. UNIQUE KEY IDX_01 (exam_site_id, time_period_id, student_id),
  156. KEY IDX_02 (student_id),
  157. KEY IDX_03 (exam_room_id),
  158. KEY IDX_04 (ticket_number)
  159. ) comment '考生预约记录表';
  160. create table t_student_import_task
  161. (
  162. id bigint not null auto_increment,
  163. create_time bigint not null comment '创建时间',
  164. update_time bigint not null comment '更新时间',
  165. operate_id bigint not null comment '操作人ID',
  166. apply_task_id bigint not null comment '所属预约任务ID',
  167. type varchar(20) not null comment '导入类型',
  168. status varchar(20) not null comment '执行状态',
  169. file_path varchar(200) not null comment '导入文件相对路径',
  170. message text comment '执行结果信息',
  171. PRIMARY KEY (id),
  172. KEY IDX_01 (apply_task_id),
  173. KEY IDX_02 (type),
  174. KEY IDX_03 (status)
  175. ) comment '考生导入任务表';
  176. create table t_operate_log
  177. (
  178. id bigint not null auto_increment,
  179. create_time bigint not null comment '创建时间',
  180. update_time bigint not null comment '更新时间',
  181. operate_id bigint not null comment '操作人ID',
  182. event_type varchar(20) not null comment '事件类型,如:考生取消预约、用户登录等',
  183. content text comment '操作内容(JSON)',
  184. PRIMARY KEY (id),
  185. KEY IDX_01 (event_type),
  186. KEY IDX_02 (operate_id)
  187. ) comment '操作日志表';
  188. -- 基础数据
  189. insert into t_org(id, name, enable, create_time, update_time)
  190. values (1, '广东开放大学', 1, unix_timestamp() * 1000, unix_timestamp() * 1000);
  191. insert into t_system_property(org_id, prop_key, prop_value, create_time, update_time)
  192. values (1, 'CATEGORY_LEVEL', '[{"level":1,"title":"城市"},{"level":2,"title":"教学点"}]', unix_timestamp() * 1000,
  193. unix_timestamp() * 1000);
  194. insert into t_user (org_id, role, name, login_name, password, mobile, category_id, enable, create_time, update_time)
  195. values (1, 'ADMIN', '学校管理员', 'admin', UPPER(SHA2('qmty87863577', 256)), null, null, 1, unix_timestamp() * 1000,
  196. unix_timestamp() * 1000);
  197. -- 城市初始化
  198. INSERT INTO t_category VALUES (1, 1717121654419, 1717121654419, b'1', 1, 0, '4401', '广州市', 1, 0);
  199. INSERT INTO t_category VALUES (2, 1717121654419, 1717121654419, b'1', 1, 0, '4402', '韶关市', 1, 0);
  200. INSERT INTO t_category VALUES (3, 1717121654419, 1717121654419, b'1', 1, 0, '4403', '深圳市', 1, 0);
  201. INSERT INTO t_category VALUES (4, 1717121654419, 1717121654419, b'1', 1, 0, '4404', '珠海市', 1, 0);
  202. INSERT INTO t_category VALUES (5, 1717121654419, 1717121654419, b'1', 1, 0, '4405', '汕头市', 1, 0);
  203. INSERT INTO t_category VALUES (6, 1717121654419, 1717121654419, b'1', 1, 0, '4406', '佛山市', 1, 0);
  204. INSERT INTO t_category VALUES (7, 1717121654419, 1717121654419, b'1', 1, 0, '4407', '江门市', 1, 0);
  205. INSERT INTO t_category VALUES (8, 1717121654419, 1717121654419, b'1', 1, 0, '4408', '湛江市', 1, 0);
  206. INSERT INTO t_category VALUES (9, 1717121654419, 1717121654419, b'1', 1, 0, '4409', '茂名市', 1, 0);
  207. INSERT INTO t_category VALUES (10, 1717121654419, 1717121654419, b'1', 1, 0, '4412', '肇庆市', 1, 0);
  208. INSERT INTO t_category VALUES (11, 1717121654419, 1717121654419, b'1', 1, 0, '4413', '惠州市', 1, 0);
  209. INSERT INTO t_category VALUES (12, 1717121654419, 1717121654419, b'1', 1, 0, '4414', '梅州市', 1, 0);
  210. INSERT INTO t_category VALUES (13, 1717121654419, 1717121654419, b'1', 1, 0, '4415', '汕尾市', 1, 0);
  211. INSERT INTO t_category VALUES (14, 1717121654419, 1717121654419, b'1', 1, 0, '4416', '河源市', 1, 0);
  212. INSERT INTO t_category VALUES (15, 1717121654419, 1717121654419, b'1', 1, 0, '4417', '阳江市', 1, 0);
  213. INSERT INTO t_category VALUES (16, 1717121654419, 1717121654419, b'1', 1, 0, '4418', '清远市', 1, 0);
  214. INSERT INTO t_category VALUES (17, 1717121654419, 1717121654419, b'1', 1, 0, '4419', '东莞市', 1, 0);
  215. INSERT INTO t_category VALUES (18, 1717121654419, 1717121654419, b'1', 1, 0, '4420', '中山市', 1, 0);
  216. INSERT INTO t_category VALUES (19, 1717121654419, 1717121654419, b'1', 1, 0, '4451', '潮州市', 1, 0);
  217. INSERT INTO t_category VALUES (20, 1717121654419, 1717121654419, b'1', 1, 0, '4452', '揭阳市', 1, 0);
  218. INSERT INTO t_category VALUES (21, 1717121654419, 1717121654419, b'1', 1, 0, '4453', '云浮市', 1, 0);