exam_reserve_db.sql 8.8 KB

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