login.sql 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. -- ----------------------------
  2. -- Table structure for sys_user
  3. -- ----------------------------
  4. drop table if exists sys_user;
  5. create table sys_user
  6. (
  7. user_id BIGINT not null comment '用户编号',
  8. login_name VARCHAR(50) not null default '' comment '登录账户',
  9. login_pwd VARCHAR(50) not null default '123456' comment '登录密码',
  10. user_type VARCHAR(1) not null comment '角色ID:1管理员,2业委会,3居民,4巡逻检查人员',
  11. staff_name VARCHAR(20) not null comment '用户姓名',
  12. be_active CHAR(1) not null default 'Y' comment '是否活动 Y=活动/N=禁用/D=删除',
  13. create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '建立时间',
  14. update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新日期',
  15. primary key ( user_id ),
  16. UNIQUE INDEX `login_name`(`login_name`) USING BTREE
  17. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '用户资料';
  18. -- insert into sys_user
  19. -- select ur.user_id,'账户','密码',ur.role_id as user_type,uo.nick_name,'Y',now(),now() from sys_uptown_home uh
  20. -- left join sys_user_role ur on ur.property_id = uh.house_id
  21. -- left join sys_user_open uo on uo.user_id = ur.user_id
  22. -- where uh.phone = "电话号码"
  23. drop table if exists sys_user_open;
  24. create table sys_user_open
  25. (
  26. user_id BIGINT not null comment '用户编号',
  27. open_id VARCHAR(100) not null comment 'wx编号',
  28. nick_name VARCHAR(100) null comment '用户昵称',
  29. sex_desc VARCHAR(10) null comment '用户性别',
  30. sex int null comment '用户性别',
  31. city VARCHAR(50) null comment '用户城市',
  32. province VARCHAR(50) null comment '用户省份',
  33. country VARCHAR(50) null comment '用户国家',
  34. head_img_url VARCHAR(200) null comment '用户头像地址',
  35. be_active CHAR(1) not null default 'Y' comment '是否活动 Y=活动/N=禁用/D=删除',
  36. create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '建立时间',
  37. update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新日期',
  38. primary key ( user_id, open_id )
  39. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '用户open';
  40. -- ----------------------------
  41. -- Table structure for sys_user_role
  42. -- ----------------------------
  43. DROP TABLE IF EXISTS sys_user_role;
  44. CREATE TABLE sys_user_role (
  45. ur_id bigint(20) NOT NULL COMMENT '用户角色关系ID',
  46. user_id bigint(20) NOT NULL COMMENT '用户ID',
  47. role_id int(11) NOT NULL COMMENT '角色ID:1居民,2业委会,3商家',
  48. property_id bigint(20) NOT NULL DEFAULT 0 COMMENT '属性ID,居民门牌ID,业委会ID',
  49. user_create bigint(20) NOT NULL DEFAULT 0 COMMENT '新增人',
  50. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  51. user_update bigint(20) NOT NULL DEFAULT 0 COMMENT '修改人',
  52. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  53. PRIMARY KEY (ur_id) USING BTREE
  54. ) ENGINE = InnoDB default charset=utf8mb4 comment = '用户角色关系表';
  55. -- ----------------------------
  56. -- Table structure for sys_owner
  57. -- ----------------------------
  58. DROP TABLE IF EXISTS sys_owner;
  59. CREATE TABLE sys_owner (
  60. owner_id bigint(20) NOT NULL DEFAULT 0 COMMENT '业委会ID',
  61. uptown_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID,下拉选ID',
  62. linkman varchar(10) NOT NULL DEFAULT '' COMMENT '联系人名称',
  63. phone varchar(20) NOT NULL DEFAULT '' COMMENT '联系人电话',
  64. user_create bigint(20) NOT NULL DEFAULT 0 COMMENT '新增人',
  65. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  66. user_update bigint(20) NOT NULL DEFAULT 0 COMMENT '修改人',
  67. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  68. PRIMARY KEY (owner_id) USING BTREE
  69. ) ENGINE = InnoDB default charset=utf8mb4 comment = '业委会表';
  70. -- ----------------------------
  71. -- Table structure for sys_owner_linkman
  72. -- ----------------------------
  73. DROP TABLE IF EXISTS sys_owner_linkman;
  74. CREATE TABLE sys_owner_linkman (
  75. linkman_id bigint(20) NOT NULL DEFAULT 0 COMMENT '业委会联系人ID',
  76. owner_id bigint(20) NOT NULL DEFAULT 0 COMMENT '业委会ID',
  77. linkman varchar(10) NOT NULL DEFAULT '' COMMENT '联系人名称',
  78. phone varchar(20) NOT NULL DEFAULT '' COMMENT '联系人电话',
  79. user_create bigint(20) NOT NULL DEFAULT 0 COMMENT '新增人',
  80. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  81. user_update bigint(20) NOT NULL DEFAULT 0 COMMENT '修改人',
  82. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  83. PRIMARY KEY (owner_id) USING BTREE
  84. ) ENGINE = InnoDB default charset=utf8mb4 comment = '业委会联系人表';
  85. -- ----------------------------
  86. -- Table structure for sys_uptown_home
  87. -- ----------------------------
  88. DROP TABLE IF EXISTS sys_uptown_home;
  89. CREATE TABLE sys_uptown_home (
  90. house_id bigint(20) NOT NULL DEFAULT 0 COMMENT '门牌ID',
  91. linkman varchar(10) NOT NULL DEFAULT '' COMMENT '联系人名称',
  92. phone varchar(20) NOT NULL DEFAULT '' COMMENT '联系人电话',
  93. young int(11) NOT NULL DEFAULT 0 COMMENT '家庭年前人数',
  94. middle int(11) NOT NULL DEFAULT 0 COMMENT '家庭中年人数',
  95. old int(11) NOT NULL DEFAULT 0 COMMENT '家庭老年人数',
  96. remark varchar(100) NOT NULL DEFAULT '' COMMENT '备注',
  97. status int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
  98. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  99. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  100. PRIMARY KEY (house_id) USING BTREE
  101. ) ENGINE = InnoDB default charset=utf8mb4 comment = '小区家庭表';
  102. -- ----------------------------
  103. -- Table structure for sys_area
  104. -- ----------------------------
  105. DROP TABLE IF EXISTS sys_area;
  106. CREATE TABLE sys_area (
  107. area_id bigint(20) NOT NULL DEFAULT 0 COMMENT '地区ID',
  108. province varchar(50) NOT NULL DEFAULT '' COMMENT '省',
  109. city varchar(50) NOT NULL DEFAULT '' COMMENT '市',
  110. area varchar(50) NOT NULL DEFAULT '' COMMENT '区',
  111. status int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
  112. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  113. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  114. PRIMARY KEY (area_id) USING BTREE
  115. ) ENGINE = InnoDB default charset=utf8mb4 comment = '省市区表';
  116. -- ----------------------------
  117. -- Table structure for sys_area_street
  118. -- ----------------------------
  119. DROP TABLE IF EXISTS sys_area_street;
  120. CREATE TABLE sys_area_street (
  121. street_id bigint(20) NOT NULL DEFAULT 0 COMMENT '街道ID',
  122. area_id bigint(20) NOT NULL DEFAULT 0 COMMENT '地区ID',
  123. status int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
  124. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  125. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  126. PRIMARY KEY (street_id) USING BTREE
  127. ) ENGINE = InnoDB default charset=utf8mb4 comment = '区街道表';
  128. -- ----------------------------
  129. -- Table structure for sys_area_com
  130. -- ----------------------------
  131. DROP TABLE IF EXISTS sys_area_com;
  132. CREATE TABLE sys_area_com (
  133. com_id bigint(20) NOT NULL DEFAULT 0 COMMENT '社区ID',
  134. street_id bigint(20) NOT NULL DEFAULT 0 COMMENT '街道ID',
  135. status int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
  136. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  137. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  138. PRIMARY KEY (com_id) USING BTREE
  139. ) ENGINE = InnoDB default charset=utf8mb4 comment = '街道社区表';
  140. -- ----------------------------
  141. -- Table structure for sys_uptown
  142. -- ----------------------------
  143. DROP TABLE IF EXISTS sys_uptown;
  144. CREATE TABLE sys_uptown (
  145. uptown_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID',
  146. uptown_name varchar(20) NOT NULL DEFAULT '' COMMENT '小区名称',
  147. uptown_addr varchar(100) NOT NULL DEFAULT '' COMMENT '小区地址',
  148. longitude varchar(20) NOT NULL DEFAULT '' COMMENT '经度',
  149. latitude varchar(20) NOT NULL DEFAULT '' COMMENT '纬度',
  150. area int(11) NOT NULL DEFAULT '0' COMMENT '区',
  151. status int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
  152. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  153. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  154. PRIMARY KEY (uptown_id) USING BTREE
  155. ) ENGINE = InnoDB default charset=utf8mb4 comment = '小区表';
  156. DROP TABLE IF EXISTS sys_uptown_unit;
  157. CREATE TABLE sys_uptown_unit (
  158. unit_id bigint(20) NOT NULL DEFAULT 0 COMMENT '单元ID',
  159. uptown_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID',
  160. ridgepole varchar(20) NOT NULL DEFAULT '' COMMENT '栋',
  161. unit varchar(20) NOT NULL DEFAULT '' COMMENT '单元',
  162. status int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
  163. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  164. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  165. PRIMARY KEY (unit_id) USING BTREE
  166. ) ENGINE = InnoDB default charset=utf8mb4 comment = '栋,单元信息表';
  167. DROP TABLE IF EXISTS sys_uptown_house;
  168. CREATE TABLE sys_uptown_house (
  169. house_id bigint(20) NOT NULL DEFAULT 0 COMMENT '门牌ID',
  170. unit_id bigint(20) NOT NULL DEFAULT 0 COMMENT '单元ID',
  171. doorplate varchar(20) NOT NULL DEFAULT '' COMMENT '门牌',
  172. status int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
  173. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  174. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  175. PRIMARY KEY (house_id) USING BTREE
  176. ) ENGINE = InnoDB default charset=utf8mb4 comment = '门牌信息表';
  177. DROP TABLE IF EXISTS out_scan;
  178. CREATE TABLE out_scan (
  179. scan_id bigint(20) NOT NULL DEFAULT 0 COMMENT '扫码ID',
  180. user_id bigint(20) NOT NULL DEFAULT 0 COMMENT '人员ID',
  181. uptown_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID,下拉选ID',
  182. door_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区大门ID',
  183. in_type int(11) NOT NULL DEFAULT 0 COMMENT '进出状态:1进,2出',
  184. day_date date NOT NULL DEFAULT '0000-01-01' COMMENT '当天时间',
  185. date datetime(0) NOT NULL DEFAULT '0000-01-01 00:00:00' COMMENT '进出时间',
  186. go_status int(11) NOT NULL DEFAULT 0 COMMENT '通行状态:1允许,-1禁止',
  187. error_info varchar(100) NOT NULL DEFAULT '' COMMENT '错误信息',
  188. user_create bigint(20) NOT NULL DEFAULT 0 COMMENT '新增人',
  189. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  190. user_update bigint(20) NOT NULL DEFAULT 0 COMMENT '修改人',
  191. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  192. PRIMARY KEY (scan_id) USING BTREE
  193. ) ENGINE = InnoDB default charset=utf8mb4 comment = '用户进出扫码信息';
  194. DROP TABLE IF EXISTS out_user;
  195. CREATE TABLE out_user (
  196. tu_id bigint(20) NOT NULL DEFAULT 0 COMMENT '特殊ID',
  197. name varchar(100) NOT NULL DEFAULT '' COMMENT '特殊人员姓名',
  198. phone bigint(20) NOT NULL DEFAULT 0 COMMENT '电话号码',
  199. start_date date NOT NULL DEFAULT '0000-01-01' COMMENT '开始时间',
  200. end_date date NOT NULL DEFAULT '0000-01-01' COMMENT '结束时间',
  201. time int(11) NOT NULL DEFAULT 0 COMMENT '总共时间(天)',
  202. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  203. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  204. PRIMARY KEY (tu_id) USING BTREE,
  205. UNIQUE INDEX phone(phone) USING BTREE
  206. ) ENGINE = InnoDB default charset=utf8mb4 comment = '进出扫码特殊人员';
  207. DROP TABLE IF EXISTS out_scan_estate;
  208. CREATE TABLE out_scan_estate (
  209. se_id bigint(20) NOT NULL DEFAULT 0 COMMENT '扫码ID',
  210. user_id bigint(20) NOT NULL DEFAULT 0 COMMENT '人员ID',
  211. day_date date NOT NULL DEFAULT '0000-01-01' COMMENT '当天时间',
  212. scan_date datetime(0) NOT NULL DEFAULT '0000-01-01 00:00:00' COMMENT '扫码时间',
  213. go_status int(11) NOT NULL DEFAULT 0 COMMENT '通行状态:1允许,-1禁止',
  214. error_info varchar(100) NOT NULL DEFAULT '' COMMENT '错误信息',
  215. user_create bigint(20) NOT NULL DEFAULT 0 COMMENT '新增人',
  216. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  217. user_update bigint(20) NOT NULL DEFAULT 0 COMMENT '修改人',
  218. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  219. PRIMARY KEY (se_id) USING BTREE,
  220. INDEX user_id(user_id) USING BTREE
  221. ) ENGINE = InnoDB default charset=utf8mb4 comment = '校园公共区域巡检扫码信息';
  222. DROP TABLE IF EXISTS out_scan_conf;
  223. CREATE TABLE out_scan_conf (
  224. sc_id bigint(20) NOT NULL DEFAULT 0 COMMENT '扫码配置ID',
  225. uptown_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID,下拉选ID',
  226. go_out_fre int(11) NOT NULL DEFAULT 0 COMMENT '出门频率',
  227. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  228. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  229. PRIMARY KEY (sc_id) USING BTREE
  230. ) ENGINE = InnoDB default charset=utf8mb4 comment = '用户外出扫码配置';
  231. DROP TABLE IF EXISTS sys_uptown_door;
  232. CREATE TABLE sys_uptown_door (
  233. door_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区大门ID',
  234. uptown_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID',
  235. door_name varchar(20) NOT NULL DEFAULT '' COMMENT '大门名称',
  236. in_img varchar(100) NOT NULL DEFAULT '' COMMENT '入口二维码',
  237. out_img varchar(100) NOT NULL DEFAULT '' COMMENT '出口二维码',
  238. status int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
  239. time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
  240. time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  241. PRIMARY KEY (door_id) USING BTREE
  242. ) ENGINE = InnoDB default charset=utf8mb4 comment = '小区大门表';