saas_platform.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. CREATE DATABASE IF NOT EXISTS `saas_platform` DEFAULT CHARACTER SET = utf8mb4;
  2. Use `saas_platform`;
  3. SET NAMES utf8mb4;
  4. SET FOREIGN_KEY_CHECKS = 0;
  5. -- ----------------------------
  6. -- Table structure for saas_account
  7. -- ----------------------------
  8. DROP TABLE IF EXISTS `saas_account`;
  9. CREATE TABLE `saas_account` (
  10. `ID` varchar(64) NOT NULL,
  11. `GROUP_CODE` varchar(20) DEFAULT NULL COMMENT '集团编码',
  12. `TERMINAL` varchar(100) DEFAULT NULL COMMENT '应用ID, PC-电脑端,APP-手机端',
  13. `USERNAME` varchar(50) DEFAULT NULL COMMENT '登录用户名,集团下唯一,业务保证',
  14. `PASSWORD` varchar(128) DEFAULT NULL COMMENT '登录密码',
  15. `PHONE_NUM` varchar(20) DEFAULT NULL COMMENT '手机号',
  16. `MAIL` varchar(50) DEFAULT NULL COMMENT '邮箱',
  17. `HEAD_PORTRAIT` varchar(500) DEFAULT NULL COMMENT '头像,图片URL',
  18. `ACCOUNT_TYPE` varchar(1) DEFAULT '2' COMMENT '账号类型, 0-超级管理员(所有集团),1-单集团管理员(单集团),2-普通账号',
  19. `ACCOUNT_BELONG` varchar(1) DEFAULT NULL COMMENT '账号所属, 0-运维系统账号,1-业务账号',
  20. `ACCOUNT_SOURCE` varchar(20) DEFAULT 'persagy' COMMENT '账号来源, persagy-博锐',
  21. `LAST_LOGIN_TIME` timestamp NULL DEFAULT NULL COMMENT '账号上一次登录时间',
  22. `LAST_LOGIN_IP` varchar(100) DEFAULT NULL COMMENT '账号上一次登录IP',
  23. `VALID_START_TIME` timestamp NULL DEFAULT NULL COMMENT '账号有效期的开始时间',
  24. `VALID_END_TIME` timestamp NULL DEFAULT NULL COMMENT '账号有效期的结束时间',
  25. `VALID_LAST` varchar(1) DEFAULT '1' COMMENT '账号有效期,0-期内有效,1-永久有效',
  26. `CREATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  27. `UPDATE_TIME` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  28. `UPDATE_USER` varchar(64) DEFAULT NULL COMMENT '最后一次操作者ID',
  29. `REMARK` varchar(255) DEFAULT NULL COMMENT '备注',
  30. `VALID` tinyint(4) DEFAULT '1' COMMENT '0-不可用,1-可用',
  31. PRIMARY KEY (`ID`),
  32. KEY `NK_ACCOUNT_GROUP_APP` (`GROUP_CODE`,`APP_ID`),
  33. KEY `NK_ACCOUNT_VALID_NAME` (`VALID`,`USERNAME`),
  34. KEY `NK_ACCOUNT_UPDATE_TIME` (`UPDATE_TIME`)
  35. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '账号信息' ROW_FORMAT = Dynamic;
  36. -- ----------------------------
  37. -- Table structure for saas_group
  38. -- ----------------------------
  39. DROP TABLE IF EXISTS `saas_group`;
  40. CREATE TABLE `saas_group` (
  41. `GROUP_CODE` varchar(20) NOT NULL COMMENT '集团编码',
  42. `GROUP_NAME` varchar(50) DEFAULT NULL COMMENT '集团名称,业务保证唯一性',
  43. `GROUP_ICON` varchar(100) DEFAULT NULL COMMENT '集团图标',
  44. `GROUP_DESC` varchar(100) DEFAULT NULL COMMENT '集团描述',
  45. `DEPLOY_MODEL` varchar(1) DEFAULT NULL COMMENT '集团部署方式,0-公有云,1-私有云',
  46. `SYNC_STATE` varchar(1) DEFAULT '2' COMMENT '数据同步状态,0-数据同步失败,1-数据同步成功,2-未同步',
  47. `SYNC_TIME` timestamp NULL DEFAULT NULL COMMENT '上次数据同步时间',
  48. `CREATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  49. `UPDATE_TIME` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  50. `UPDATE_USER` varchar(64) DEFAULT NULL COMMENT '最后一次操作者ID',
  51. `REMARK` varchar(255) DEFAULT NULL COMMENT '备注',
  52. `VALID` tinyint(4) DEFAULT '1' COMMENT '0-不可用,1-可用',
  53. PRIMARY KEY (`GROUP_CODE`),
  54. KEY `NK_GROUP_VALID_NAME` (`VALID`,`GROUP_NAME`)
  55. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '集团信息' ROW_FORMAT = Dynamic;
  56. -- ----------------------------
  57. -- Table structure for saas_project
  58. -- ----------------------------
  59. DROP TABLE IF EXISTS `saas_project`;
  60. CREATE TABLE `saas_project` (
  61. `ID` varchar(64) NOT NULL,
  62. `GROUP_CODE` varchar(20) NOT NULL COMMENT '集团编码',
  63. `PROJECT_ID` varchar(25) NOT NULL COMMENT '项目ID,集团下唯一,业务保证',
  64. `AREA_ID` varchar(64) NOT NULL COMMENT '项目所属区域,必须为最底层的区域',
  65. `PROJECT_LOCAL_ID` varchar(20) DEFAULT NULL COMMENT '项目本地编码,集团下唯一,业务保证',
  66. `PROJECT_NAME` varchar(50) DEFAULT NULL COMMENT '项目名称,集团下唯一,业务保证',
  67. `PROVINCE_CODE` varchar(30) DEFAULT NULL COMMENT '项目所在省',
  68. `CITY_CODE` varchar(30) DEFAULT NULL COMMENT '项目所在市',
  69. `ZONE_CODE` varchar(30) DEFAULT NULL COMMENT '项目所在区',
  70. `LOCATION` varchar(500) DEFAULT NULL COMMENT '项目详细地址',
  71. `OPEN_TIME` timestamp NULL DEFAULT NULL COMMENT '项目开业时间',
  72. `CREATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  73. `UPDATE_TIME` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  74. `UPDATE_USER` varchar(64) DEFAULT NULL COMMENT '最后一次操作者ID',
  75. `REMARK` varchar(255) DEFAULT NULL COMMENT '备注',
  76. `VALID` tinyint(4) DEFAULT '1' COMMENT '0-不可用,1-可用',
  77. PRIMARY KEY (`ID`),
  78. KEY `NK_PROJECT_GROUP_PROJECT` (`VALID`,`GROUP_CODE`,`PROJECT_ID`) USING BTREE,
  79. KEY `NK_PROJECT_AREA_ID` (`AREA_ID`) USING BTREE,
  80. KEY `NK_PROJECT_PROJECT_NAME` (`PROJECT_NAME`) USING BTREE
  81. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '项目信息' ROW_FORMAT = Dynamic;
  82. -- ----------------------------
  83. -- Table structure for saas_area
  84. -- ----------------------------
  85. DROP TABLE IF EXISTS `saas_area`;
  86. CREATE TABLE `saas_area` (
  87. `ID` varchar(64) NOT NULL,
  88. `GROUP_CODE` varchar(20) NOT NULL COMMENT '集团编码',
  89. `PARENT_ID` varchar(64) DEFAULT NULL COMMENT '上级区域ID',
  90. `AREA_CODE` varchar(50) DEFAULT NULL COMMENT '区域编码',
  91. `AREA_NAME` varchar(50) DEFAULT NULL COMMENT '区域名称',
  92. `AREA_TYPE` varchar(20) DEFAULT NULL COMMENT '区域类型,0-非最底层区域,1-最底层区域',
  93. `CREATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  94. `UPDATE_TIME` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  95. `UPDATE_USER` varchar(64) DEFAULT NULL COMMENT '最后一次操作者ID',
  96. `REMARK` varchar(255) DEFAULT NULL COMMENT '备注',
  97. PRIMARY KEY (`ID`),
  98. KEY `NK_AREA_GROUP_CODE` (`GROUP_CODE`, `AREA_CODE`),
  99. KEY `NK_AREA_AREA_CODE` (`AREA_TYPE`),
  100. KEY `NK_AREA_PARENT_ID` (`PARENT_ID`)
  101. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '区域信息' ROW_FORMAT = Dynamic;
  102. -- ----------------------------
  103. -- Table structure for saas_account_project
  104. -- ----------------------------
  105. DROP TABLE IF EXISTS `saas_account_project`;
  106. CREATE TABLE `saas_account_project` (
  107. `ACCOUNT_ID` varchar(64) NOT NULL COMMENT '账号ID',
  108. `GROUP_CODE` varchar(20) DEFAULT NULL COMMENT '集团编码',
  109. `AREA_ID` varchar(64) DEFAULT NULL COMMENT '区域ID',
  110. `PROJECT_ID` varchar(25) DEFAULT NULL COMMENT '项目ID',
  111. UNIQUE KEY `UK_ACCOUNT_PROJECT_GROUP` (`ACCOUNT_ID`,`GROUP_CODE`,`PROJECT_ID`)
  112. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '账号-集团项目关联信息' ROW_FORMAT = Dynamic;
  113. -- ----------------------------
  114. -- Table structure for saas_account_role
  115. -- ----------------------------
  116. DROP TABLE IF EXISTS `saas_account_role`;
  117. CREATE TABLE `saas_account_role` (
  118. `GROUP_CODE` varchar(20) DEFAULT NULL COMMENT '集团编码',
  119. `ACCOUNT_ID` varchar(64) NOT NULL COMMENT '账号ID',
  120. `ROLE_ID` varchar(64) NOT NULL COMMENT '角色ID',
  121. `CAS_TYPE` varchar(1) DEFAULT NULL COMMENT '关联类型,0-主岗,1-副岗,2-业务超管默认角色',
  122. UNIQUE KEY `UK_ACCOUNT_ACCOUNT_ROLE` (`ACCOUNT_ID`,`GROUP_CODE`,`ROLE_ID`)
  123. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '账号-角色关联信息' ROW_FORMAT = Dynamic;
  124. -- ----------------------------
  125. -- Table structure for saas_role
  126. -- ----------------------------
  127. DROP TABLE IF EXISTS `saas_role`;
  128. CREATE TABLE `saas_role` (
  129. `ID` varchar(64) NOT NULL,
  130. `GROUP_CODE` varchar(20) DEFAULT NULL COMMENT '集团编码',
  131. `ROLE_CODE` varchar(50) DEFAULT NULL COMMENT '角色编码',
  132. `ROLE_NAME` varchar(100) DEFAULT NULL COMMENT '角色名称',
  133. `ROLE_TYPE` varchar(1) DEFAULT '0' COMMENT '角色类型,0-系统角色,1-业务角色, 2-业务超管默认角色',
  134. `CREATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  135. `UPDATE_TIME` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  136. `UPDATE_USER` varchar(64) DEFAULT NULL COMMENT '最后一次操作者ID',
  137. `REMARK` varchar(255) DEFAULT NULL COMMENT '备注',
  138. `VALID` tinyint(4) DEFAULT '1' COMMENT '0-不可用,1-可用',
  139. PRIMARY KEY (`ID`),
  140. KEY `NK_ROLE_GROUP_ROLE_TYPE` (`VALID`, `GROUP_CODE`, `ROLE_TYPE`)
  141. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色信息' ROW_FORMAT = Dynamic;
  142. -- ----------------------------
  143. -- Table structure for saas_menu
  144. -- ----------------------------
  145. DROP TABLE IF EXISTS `saas_menu`;
  146. CREATE TABLE `saas_menu` (
  147. `ID` varchar(64) NOT NULL,
  148. `PARENT_ID` varchar(64) DEFAULT NULL COMMENT '上级菜单ID',
  149. `APP_ID` varchar(64) DEFAULT NULL COMMENT '应用ID, PC-电脑端,APP-手机端',
  150. `MENU_CODE` varchar(50) DEFAULT NULL COMMENT '菜单编码',
  151. `MENU_NAME` varchar(50) DEFAULT NULL COMMENT '菜单名称',
  152. `MENU_URL` varchar(500) DEFAULT NULL COMMENT '菜单URL',
  153. `URL_TYPE` varchar(1) DEFAULT NULL COMMENT 'URL类型,0-相对路径,1-绝对路径',
  154. `MENU_ICON` varchar(100) DEFAULT NULL COMMENT '菜单图标',
  155. `MENU_SORT` int(11) DEFAULT NULL COMMENT '菜单顺序',
  156. `MENU_TYPE` varchar(1) DEFAULT NULL COMMENT '菜单类型,0-系统菜单,1-标准业务菜单,2-IBMS菜单,3-APP菜单',
  157. `CREATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  158. `UPDATE_TIME` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  159. `UPDATE_USER` varchar(64) DEFAULT NULL COMMENT '最后一次操作者ID',
  160. `REMARK` varchar(255) DEFAULT NULL COMMENT '备注',
  161. PRIMARY KEY (`ID`),
  162. KEY `NK_MENU_MENU_CODE` (`MENU_CODE`),
  163. KEY `NK_MENU_PARENT_ID` (`PARENT_ID`),
  164. KEY `NK_MENU_APP_ID` (`APP_ID`),
  165. KEY `NK_MENU_MENU_SORT` (`MENU_SORT`)
  166. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单信息' ROW_FORMAT = Dynamic;
  167. -- ----------------------------
  168. -- Table structure for saas_function
  169. -- ----------------------------
  170. DROP TABLE IF EXISTS `saas_function`;
  171. CREATE TABLE `saas_function` (
  172. `ID` varchar(64) NOT NULL,
  173. `MENU_ID` varchar(64) NOT NULL COMMENT '菜单ID',
  174. `FUN_CODE` varchar(50) DEFAULT NULL COMMENT '功能编码',
  175. `FUN_NAME` varchar(50) DEFAULT NULL COMMENT '功能名称',
  176. `FUN_URL` varchar(500) DEFAULT NULL COMMENT '功能URL',
  177. `FUN_SORT` int(11) DEFAULT NULL COMMENT '功能顺序',
  178. `CREATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  179. `UPDATE_TIME` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  180. `UPDATE_USER` varchar(64) DEFAULT NULL COMMENT '最后一次操作者ID',
  181. `REMARK` varchar(255) DEFAULT NULL COMMENT '备注',
  182. PRIMARY KEY (`ID`),
  183. KEY `NK_FUN_MENU_ID` (`MENU_ID`),
  184. KEY `NK_FUN_FUN_CODE` (`FUN_CODE`),
  185. KEY `NK_FUN_FUN_SORT` (`FUN_SORT`)
  186. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '功能信息' ROW_FORMAT = Dynamic;
  187. -- ----------------------------
  188. -- Table structure for saas_role_menu
  189. -- ----------------------------
  190. DROP TABLE IF EXISTS `saas_role_menu`;
  191. CREATE TABLE `saas_role_menu` (
  192. `GROUP_CODE` varchar(20) DEFAULT NULL COMMENT '集团编码',
  193. `ROLE_ID` varchar(64) NOT NULL COMMENT '角色ID',
  194. `MENU_ID` varchar(64) NOT NULL COMMENT '菜单ID',
  195. `FUNCTION_ID` varchar(64) DEFAULT NULL COMMENT '功能ID',
  196. UNIQUE KEY `UK_FOLE_MENU_GROUP` (`GROUP_CODE`,`ROLE_ID`,`MENU_ID`,`FUNCTION_ID`) USING BTREE
  197. ) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色-菜单功能关联信息' ROW_FORMAT = Dynamic;
  198. SET FOREIGN_KEY_CHECKS = 1;