exam_reserve_db.sql 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. PRIMARY KEY (id),
  35. UNIQUE KEY IDX_01 (org_id, login_name),
  36. KEY IDX_02 (role),
  37. KEY IDX_03 (category_id)
  38. ) comment '用户表';
  39. create table t_student
  40. (
  41. id bigint not null auto_increment,
  42. create_time bigint not null comment '创建时间',
  43. update_time bigint not null comment '更新时间',
  44. org_id bigint not null comment '所属机构ID(学校)',
  45. name varchar(50) not null comment '考生姓名',
  46. identity_number varchar(20) not null comment '证件号',
  47. student_code varchar(20) not null comment '学号',
  48. password varchar(64) not null comment '密码',
  49. photo_path varchar(100) comment '头像相对路径',
  50. gender varchar(10) comment '性别',
  51. open_id varchar(50) comment '微信OID',
  52. uid varchar(50) comment '微信UID',
  53. apply_task_id bigint not null comment '所属预约任务ID',
  54. category_id bigint not null comment '所属教学点ID',
  55. apply_number int not null comment '允许预约时段数量',
  56. apply_finished bit(1) not null comment '预约时段是否全部完成',
  57. PRIMARY KEY (id),
  58. UNIQUE KEY IDX_01 (apply_task_id, student_code),
  59. UNIQUE KEY IDX_02 (open_id, uid),
  60. KEY IDX_03 (category_id),
  61. KEY IDX_04 (identity_number)
  62. ) comment '考生表';
  63. create table t_category
  64. (
  65. id bigint not null auto_increment,
  66. create_time bigint not null comment '创建时间',
  67. update_time bigint not null comment '更新时间',
  68. enable bit(1) not null comment '是否启用',
  69. org_id bigint not null comment '所属机构ID(学校)',
  70. parent_id bigint not null default 0 comment '父级ID,顶级值为0',
  71. code varchar(20) not null comment '分类代码',
  72. name varchar(50) not null comment '分类名称',
  73. level int not null comment '层级,第一级值为1',
  74. capacity int null default 0 comment '容量',
  75. PRIMARY KEY (id),
  76. UNIQUE KEY IDX_01 (org_id, code),
  77. KEY IDX_02 (parent_id),
  78. KEY IDX_03 (level)
  79. ) comment '数据分类表';
  80. create table t_exam_site
  81. (
  82. id bigint not null auto_increment,
  83. create_time bigint not null comment '创建时间',
  84. update_time bigint not null comment '更新时间',
  85. enable bit(1) not null comment '是否启用',
  86. code varchar(20) not null comment '考点代码',
  87. name varchar(100) not null comment '考点名称',
  88. category_id bigint not null comment '所属教学点ID',
  89. capacity int comment '机房容量',
  90. address varchar(200) comment '考点地址',
  91. guide longtext comment '考点指引',
  92. PRIMARY KEY (id),
  93. UNIQUE KEY IDX_01 (category_id, code)
  94. ) comment '考点表';
  95. create table t_exam_room
  96. (
  97. id bigint not null auto_increment,
  98. create_time bigint not null comment '创建时间',
  99. update_time bigint not null comment '更新时间',
  100. enable bit(1) not null comment '是否启用',
  101. code varchar(20) not null comment '考场代码',
  102. name varchar(100) not null comment '考场名称',
  103. exam_site_id bigint not null comment '所属考点ID',
  104. address varchar(200) comment '考场地址',
  105. capacity int comment '机房容量',
  106. PRIMARY KEY (id),
  107. UNIQUE KEY IDX_01 (exam_site_id, code)
  108. ) comment '考场表';
  109. create table t_apply_task
  110. (
  111. id bigint not null auto_increment,
  112. create_time bigint not null comment '创建时间',
  113. update_time bigint not null comment '更新时间',
  114. enable bit(1) not null comment '是否启用',
  115. org_id bigint not null comment '所属机构ID(学校)',
  116. name varchar(50) not null comment '任务名称',
  117. allow_apply_days int not null comment '考前多少天,禁止考生自主预约',
  118. allow_apply_cancel_days int not null comment '考前多少天,禁止考生自主取消预约',
  119. self_apply_start_time bigint not null comment '自主预约起始时间,只能预约本教学点下的考点',
  120. self_apply_end_time bigint not null comment '自主预约截止时间,只能预约本教学点下的考点',
  121. open_apply_start_time bigint not null comment '开放式预约起始时间,可以在不同教学点间预约',
  122. open_apply_end_time bigint not null comment '开放式预约截止时间,可以在不同教学点间预约',
  123. notice longtext comment '考试说明',
  124. PRIMARY KEY (id),
  125. KEY IDX_01 (org_id)
  126. ) comment '预约任务表';
  127. create table t_time_period
  128. (
  129. id bigint not null auto_increment,
  130. create_time bigint not null comment '创建时间',
  131. update_time bigint not null comment '更新时间',
  132. apply_task_id bigint not null comment '所属预约任务ID',
  133. start_time bigint not null comment '预约起始时间',
  134. end_time bigint not null comment '预约截止时间',
  135. PRIMARY KEY (id),
  136. KEY IDX_01 (apply_task_id),
  137. KEY IDX_02 (start_time),
  138. KEY IDX_03 (end_time)
  139. ) comment '预约任务的时段表';
  140. create table t_student_apply
  141. (
  142. id bigint not null auto_increment,
  143. create_time bigint not null comment '创建时间',
  144. update_time bigint not null comment '更新时间',
  145. exam_site_id bigint not null comment '预约的考点ID',
  146. time_period_id bigint not null comment '预约时段ID',
  147. student_id bigint not null comment '考生ID',
  148. cancel bit(1) not null comment '是否取消预约',
  149. exam_room_id bigint comment '预约的考场ID',
  150. ticket_number varchar(50) comment '准考证号',
  151. seat_number varchar(20) comment '座位号',
  152. operate_id bigint comment '操作人ID',
  153. PRIMARY KEY (id),
  154. UNIQUE KEY IDX_01 (exam_site_id, time_period_id, student_id),
  155. KEY IDX_02 (student_id),
  156. KEY IDX_03 (exam_room_id),
  157. KEY IDX_04 (ticket_number)
  158. ) comment '考生预约记录表';
  159. create table t_student_import_task
  160. (
  161. id bigint not null auto_increment,
  162. create_time bigint not null comment '创建时间',
  163. update_time bigint not null comment '更新时间',
  164. operate_id bigint not null comment '操作人ID',
  165. apply_task_id bigint not null comment '所属预约任务ID',
  166. type varchar(20) not null comment '导入类型',
  167. status varchar(20) not null comment '执行状态',
  168. file_path varchar(200) not null comment '导入文件相对路径',
  169. message text comment '执行结果信息',
  170. PRIMARY KEY (id),
  171. KEY IDX_01 (apply_task_id),
  172. KEY IDX_02 (type),
  173. KEY IDX_03 (status)
  174. ) comment '考生导入任务表';
  175. create table t_operate_log
  176. (
  177. id bigint not null auto_increment,
  178. create_time bigint not null comment '创建时间',
  179. update_time bigint not null comment '更新时间',
  180. operate_id bigint not null comment '操作人ID',
  181. event_type varchar(20) not null comment '事件类型,如:考生取消预约、用户登录等',
  182. content text comment '操作内容(JSON)',
  183. PRIMARY KEY (id),
  184. KEY IDX_01 (event_type),
  185. KEY IDX_02 (operate_id)
  186. ) comment '操作日志表';
  187. -- 基础数据
  188. insert into t_org(id, name, enable, create_time, update_time)
  189. values (1, '广东开放大学', 1, unix_timestamp() * 1000, unix_timestamp() * 1000);
  190. insert into t_system_property(org_id, prop_key, prop_value, create_time, update_time)
  191. values (1, 'CATEGORY_LEVEL', '[{"level":1,"title":"城市"},{"level":2,"title":"教学点"}]', unix_timestamp() * 1000,
  192. unix_timestamp() * 1000);
  193. insert into t_user (org_id, role, name, login_name, password, mobile, category_id, enable, create_time, update_time)
  194. values (1, 'ADMIN', '学校管理员', 'admin', UPPER(SHA2('123456', 256)), null, null, 1, unix_timestamp() * 1000,
  195. unix_timestamp() * 1000);