-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpermission.sql
118 lines (108 loc) · 5.71 KB
/
permission.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
Navicat MySQL Data Transfer
Source Server : 本地-xampp
Source Server Version : 100138
Source Host : localhost:3306
Source Database : permission
Target Server Type : MYSQL
Target Server Version : 100138
File Encoding : 65001
Date: 2019-07-20 18:29:39
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for admin_user
-- ----------------------------
DROP TABLE IF EXISTS `admin_user`;
CREATE TABLE `admin_user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(50) CHARACTER SET utf8 NOT NULL COMMENT '用户名',
`password` char(32) CHARACTER SET utf8 NOT NULL COMMENT '密码',
`login_time` datetime DEFAULT NULL COMMENT '登陆时间',
`login_ip` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '0.0.0.0' COMMENT '登陆ip',
`lock` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态,1:正常,2:锁定',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`expired_time` int(11) NOT NULL DEFAULT '0' COMMENT '过期时间',
`activationtime` int(11) DEFAULT NULL COMMENT '激活时间',
`num` int(11) NOT NULL DEFAULT '0' COMMENT '每天上下架次数',
`token` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`user_nickname` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '用户昵称',
`user_avatar` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '用户头像,七牛云的key',
`description` varchar(255) CHARACTER SET utf8 DEFAULT '优秀的管理员' COMMENT '个人简介',
`email` varchar(255) DEFAULT NULL,
`isNotice` tinyint(5) DEFAULT '2' COMMENT '是否开启邮件通知 1 是 2 否',
PRIMARY KEY (`id`),
UNIQUE KEY `username_UNIQUE` (`username`) USING BTREE,
UNIQUE KEY `id_UNIQUE` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='管理员表';
-- ----------------------------
-- Table structure for model_has_permission
-- ----------------------------
DROP TABLE IF EXISTS `model_has_permission`;
CREATE TABLE `model_has_permission` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(16) unsigned NOT NULL COMMENT '用户id',
`permission_id` int(16) unsigned NOT NULL COMMENT '权限id',
PRIMARY KEY (`id`),
UNIQUE KEY `permission_model_unique` (`user_id`,`permission_id`),
KEY `delete_permission` (`permission_id`),
CONSTRAINT `delete_permission` FOREIGN KEY (`permission_id`) REFERENCES `permission` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- ----------------------------
-- Table structure for model_has_role
-- ----------------------------
DROP TABLE IF EXISTS `model_has_role`;
CREATE TABLE `model_has_role` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`role_id` int(16) unsigned NOT NULL COMMENT '角色id',
`user_id` int(16) unsigned NOT NULL COMMENT '权限id',
PRIMARY KEY (`id`),
UNIQUE KEY `user_model_unique` (`role_id`,`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- ----------------------------
-- Table structure for permission
-- ----------------------------
DROP TABLE IF EXISTS `permission`;
CREATE TABLE `permission` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限节点名称(根据它来进行)',
`rule` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '路由地址',
`remark` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '节点备注信息',
`p_id` int(2) NOT NULL DEFAULT '0' COMMENT '用于菜单渲染的节点',
`status` enum('1','0') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1' COMMENT '0 禁用 1 启用',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`method` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '请求方法 array 格式',
`route` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '路由',
`hidden` int(2) NOT NULL DEFAULT '1' COMMENT 'true',
`icon` varchar(165) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=172 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色名称',
`remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `unique_role_name` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- ----------------------------
-- Table structure for role_has_permission
-- ----------------------------
DROP TABLE IF EXISTS `role_has_permission`;
CREATE TABLE `role_has_permission` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`permission_id` int(16) unsigned NOT NULL COMMENT '关联的权限id',
`role_id` int(16) unsigned NOT NULL COMMENT '关联的角色id',
PRIMARY KEY (`id`),
UNIQUE KEY `unique_permission_role` (`permission_id`,`role_id`),
KEY `deleted_to_role` (`role_id`),
CONSTRAINT `deleted_to_permission` FOREIGN KEY (`permission_id`) REFERENCES `permission` (`id`) ON DELETE CASCADE,
CONSTRAINT `deleted_to_role` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色 - 权限的中间表';