数据库

常见问题

默认账号密码

默认后台账号密码: admin / 123456

内置密码生成策略

base64(sha256(sha256("用户密码"+"盐")+"盐")+"|"++"盐");

数据库模型

数据库模型

数据库结构

  1. CREATE TABLE `admin_auth`
  2. (
  3. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  4. `name` varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
  5. `description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述',
  6. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  7. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  8. PRIMARY KEY (`id`) USING BTREE,
  9. KEY `name` (`name`) USING BTREE
  10. ) ENGINE = InnoDB
  11. DEFAULT CHARSET = utf8mb4 COMMENT ='权限';
  12. CREATE TABLE `admin_menu`
  13. (
  14. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  15. `parent_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上级菜单ID',
  16. `name` varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
  17. `url` varchar(255) NOT NULL DEFAULT '' COMMENT '链接',
  18. `icon` varchar(30) NOT NULL DEFAULT '' COMMENT 'icon',
  19. `description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述',
  20. `sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序值 越小越在前',
  21. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  22. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  23. PRIMARY KEY (`id`) USING BTREE
  24. ) ENGINE = InnoDB
  25. DEFAULT CHARSET = utf8mb4 COMMENT ='菜单';
  26. CREATE TABLE `admin_menu_relate`
  27. (
  28. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  29. `admin_auth_id` int(10) unsigned NOT NULL,
  30. `admin_menu_id` int(10) unsigned NOT NULL,
  31. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  32. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  33. PRIMARY KEY (`id`) USING BTREE,
  34. UNIQUE KEY `unique` (`admin_auth_id`, `admin_menu_id`) USING BTREE
  35. ) ENGINE = InnoDB
  36. DEFAULT CHARSET = utf8mb4 COMMENT ='菜单权限关联';
  37. CREATE TABLE `admin_request`
  38. (
  39. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  40. `type` varchar(50) NOT NULL DEFAULT 'default' COMMENT '请求类型',
  41. `name` varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
  42. `action` varchar(100) NOT NULL DEFAULT '' COMMENT 'action',
  43. `call` varchar(100) NOT NULL DEFAULT '' COMMENT '类型配置',
  44. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  45. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  46. PRIMARY KEY (`id`) USING BTREE,
  47. UNIQUE KEY `action` (`action`) USING BTREE
  48. ) ENGINE = InnoDB
  49. DEFAULT CHARSET = utf8mb4 COMMENT ='请求';
  50. CREATE TABLE `admin_request_relate`
  51. (
  52. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  53. `admin_auth_id` int(10) unsigned NOT NULL,
  54. `admin_request_id` int(10) unsigned NOT NULL,
  55. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  56. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  57. PRIMARY KEY (`id`) USING BTREE,
  58. UNIQUE KEY `unique` (`admin_auth_id`, `admin_request_id`) USING BTREE
  59. ) ENGINE = InnoDB
  60. DEFAULT CHARSET = utf8mb4 COMMENT ='请求权限关联';
  61. CREATE TABLE `admin_user`
  62. (
  63. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  64. `username` varchar(100) NOT NULL DEFAULT '' COMMENT '用户名',
  65. `password` varchar(255) NOT NULL DEFAULT '' COMMENT '密码',
  66. `last_login_ip` varchar(15) NOT NULL DEFAULT '' COMMENT '最后登录IP',
  67. `last_login_time` timestamp NULL DEFAULT NULL COMMENT '最后登录时间',
  68. `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态',
  69. `description` varchar(150) NOT NULL DEFAULT '' COMMENT '描述',
  70. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  71. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  72. PRIMARY KEY (`id`) USING BTREE,
  73. UNIQUE KEY `username` (`username`) USING BTREE
  74. ) ENGINE = InnoDB
  75. DEFAULT CHARSET = utf8mb4 COMMENT ='管理员用户';
  76. CREATE TABLE `admin_user_relate`
  77. (
  78. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  79. `admin_user_group_id` int(10) unsigned NOT NULL,
  80. `admin_user_id` int(10) unsigned NOT NULL,
  81. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  82. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  83. PRIMARY KEY (`id`) USING BTREE,
  84. UNIQUE KEY `unique` (`admin_user_group_id`, `admin_user_id`) USING BTREE
  85. ) ENGINE = InnoDB
  86. DEFAULT CHARSET = utf8mb4 COMMENT ='用户组关联';
  87. CREATE TABLE `admin_user_group`
  88. (
  89. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  90. `name` varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
  91. `description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述',
  92. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  93. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  94. PRIMARY KEY (`id`) USING BTREE,
  95. KEY `name` (`name`) USING BTREE
  96. ) ENGINE = InnoDB
  97. DEFAULT CHARSET = utf8mb4 COMMENT ='用户组';
  98. CREATE TABLE `admin_user_group_relate`
  99. (
  100. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  101. `admin_user_group_id` int(10) unsigned NOT NULL,
  102. `admin_auth_id` int(10) unsigned NOT NULL,
  103. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  104. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  105. PRIMARY KEY (`id`) USING BTREE,
  106. UNIQUE KEY `unique` (`admin_user_group_id`, `admin_auth_id`) USING BTREE
  107. ) ENGINE = InnoDB
  108. DEFAULT CHARSET = utf8mb4 COMMENT ='用户组权限关联';
  109. CREATE TABLE `admin_token`
  110. (
  111. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  112. `token` varchar(32) NOT NULL DEFAULT '' COMMENT 'token',
  113. `admin_user_id` int(10) unsigned NOT NULL COMMENT '用户ID',
  114. `expire_time` timestamp NULL DEFAULT NULL COMMENT '过期时间',
  115. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  116. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  117. PRIMARY KEY (`id`) USING BTREE,
  118. UNIQUE KEY `token` (`token`) USING BTREE,
  119. KEY `expire_time` (`expire_time`) USING BTREE
  120. ) ENGINE = InnoDB
  121. DEFAULT CHARSET = utf8mb4 COMMENT ='登录token';
  122. INSERT INTO `admin_auth`(`id`, `name`)
  123. VALUES (1, '系统设置-用户管理'),
  124. (2, '系统设置-权限管理');
  125. INSERT INTO `admin_menu`(`id`, `parent_id`, `name`, `url`, `icon`, `description`, `sort`)
  126. VALUES (1, 0, '系统设置', '', '', '', 1),
  127. (10, 1, '用户管理', '', '', '', 1),
  128. (11, 10, '用户', '/system/user', '', '', 1),
  129. (12, 10, '用户组', '/system/userGroup', '', '', 2),
  130. (20, 1, '权限管理', '', '', '', 2),
  131. (21, 20, '请求', '/system/request', '', '', 1),
  132. (22, 20, '菜单', '/system/menu', '', '', 2),
  133. (23, 20, '权限', '/system/auth', '', '', 4);
  134. INSERT INTO `admin_menu_relate`(`admin_auth_id`, `admin_menu_id`)
  135. VALUES (1, 1),
  136. (1, 10),
  137. (1, 11),
  138. (1, 12),
  139. (2, 20),
  140. (2, 21),
  141. (2, 22),
  142. (2, 23);
  143. INSERT INTO `admin_request`(`id`, `type`, `name`, `action`, `call`)
  144. VALUES (1, 'default', '登录', '/login', 'Baiy.Cadmin.System.Index.login'),
  145. (2, 'default', '退出', '/logout', 'Baiy.Cadmin.System.Index.logout'),
  146. (3, 'default', '初始数据加载', '/load', 'Baiy.Cadmin.System.Index.load'),
  147. (4, 'default', '当前用户编辑', '/current/user/setting', 'Baiy.Cadmin.System.User.currentSetting'),
  148. (10, 'default', '用户管理-用户-列表数据', '/system/user/lists', 'Baiy.Cadmin.System.User.lists'),
  149. (11, 'default', '用户管理-用户-保存', '/system/user/save', 'Baiy.Cadmin.System.User.save'),
  150. (12, 'default', '用户管理-用户-删除', '/system/user/remove', 'Baiy.Cadmin.System.User.remove'),
  151. (20, 'default', '用户管理-用户组-列表数据', '/system/userGroup/lists', 'Baiy.Cadmin.System.UserGroup.lists'),
  152. (21, 'default', '用户管理-用户组-保存', '/system/userGroup/save', 'Baiy.Cadmin.System.UserGroup.save'),
  153. (22, 'default', '用户管理-用户组-删除', '/system/userGroup/remove', 'Baiy.Cadmin.System.UserGroup.remove'),
  154. (23, 'default', '用户管理-用户组-获取用户分组信息', '/system/userGroup/getUser', 'Baiy.Cadmin.System.UserGroup.getUser'),
  155. (24, 'default', '用户管理-用户组-用户分配', '/system/userGroup/assignUser', 'Baiy.Cadmin.System.UserGroup.assignUser'),
  156. (25, 'default', '用户管理-用户组-移除用户分配', '/system/userGroup/removeUser', 'Baiy.Cadmin.System.UserGroup.removeUser'),
  157. (30, 'default', '权限管理-请求-列表数据', '/system/request/lists', 'Baiy.Cadmin.System.Request.lists'),
  158. (31, 'default', '权限管理-请求-保存', '/system/request/save', 'Baiy.Cadmin.System.Request.save'),
  159. (32, 'default', '权限管理-请求-删除', '/system/request/remove', 'Baiy.Cadmin.System.Request.remove'),
  160. (33, 'default', '权限管理-请求-类型映射', '/system/request/type', 'Baiy.Cadmin.System.Request.type'),
  161. (40, 'default', '权限管理-菜单-列表数据', '/system/menu/lists', 'Baiy.Cadmin.System.Menu.lists'),
  162. (41, 'default', '权限管理-菜单-排序', '/system/menu/sort', 'Baiy.Cadmin.System.Menu.sort'),
  163. (42, 'default', '权限管理-菜单-保存', '/system/menu/save', 'Baiy.Cadmin.System.Menu.save'),
  164. (43, 'default', '权限管理-菜单-删除', '/system/menu/remove', 'Baiy.Cadmin.System.Menu.remove'),
  165. (60, 'default', '权限管理-权限-列表数据', '/system/auth/lists', 'Baiy.Cadmin.System.Auth.lists'),
  166. (61, 'default', '权限管理-权限-保存', '/system/auth/save', 'Baiy.Cadmin.System.Auth.save'),
  167. (62, 'default', '权限管理-权限-删除', '/system/auth/remove', 'Baiy.Cadmin.System.Auth.remove'),
  168. (63, 'default', '权限管理-权限-获取请求分配信息', '/system/auth/getRequest', 'Baiy.Cadmin.System.Auth.getRequest'),
  169. (64, 'default', '权限管理-权限-请求分配', '/system/auth/assignRequest', 'Baiy.Cadmin.System.Auth.assignRequest'),
  170. (65, 'default', '权限管理-权限-移除请求分配', '/system/auth/removeRequest', 'Baiy.Cadmin.System.Auth.removeRequest'),
  171. (70, 'default', '权限管理-权限-获取用户组分配信息', '/system/auth/getUserGroup', 'Baiy.Cadmin.System.Auth.getUserGroup'),
  172. (71, 'default', '权限管理-权限-用户组分配', '/system/auth/assignUserGroup', 'Baiy.Cadmin.System.Auth.assignUserGroup'),
  173. (72, 'default', '权限管理-权限-移除用户组分配', '/system/auth/removeUserGroup', 'Baiy.Cadmin.System.Auth.removeUserGroup'),
  174. (73, 'default', '权限管理-权限-获取菜单分配信息', '/system/auth/getMenu', 'Baiy.Cadmin.System.Auth.getMenu'),
  175. (74, 'default', '权限管理-权限-分配菜单', '/system/auth/assignMenu', 'Baiy.Cadmin.System.Auth.assignMenu');
  176. INSERT INTO `admin_request_relate`(`admin_auth_id`, `admin_request_id`)
  177. VALUES (1, 10),
  178. (1, 11),
  179. (1, 12),
  180. (1, 20),
  181. (1, 21),
  182. (1, 22),
  183. (1, 23),
  184. (1, 24),
  185. (1, 25),
  186. (2, 30),
  187. (2, 31),
  188. (2, 32),
  189. (2, 33),
  190. (2, 40),
  191. (2, 41),
  192. (2, 42),
  193. (2, 43),
  194. (2, 60),
  195. (2, 61),
  196. (2, 62),
  197. (2, 63),
  198. (2, 64),
  199. (2, 65),
  200. (2, 70),
  201. (2, 71),
  202. (2, 72),
  203. (2, 73),
  204. (2, 74);
  205. INSERT INTO `admin_user`(`id`, `username`, `password`)
  206. VALUES (1, 'admin',
  207. 'ZjU3NzE5ZWU3OWFlYjQ1MzMyNzI1NTI5NDNlNzZiZjk3ZGVlNWMwZDRkMTU1ZDRiOThlNWUwMjRmOGZlMmZmZnwxanVlYXEyOQ==');
  208. INSERT INTO `admin_user_group`(`id`, `name`)
  209. VALUES (1, '超级管理员');
  210. INSERT INTO `admin_user_relate`(`admin_user_group_id`, `admin_user_id`)
  211. VALUES (1, 1);
  212. INSERT INTO `admin_user_group_relate`(`admin_auth_id`, `admin_user_group_id`)
  213. VALUES (1, 1),
  214. (2, 1);