总结一下Generator的使用,首先要设计好数据表,然后修改generator.xml中的配制,接着直接运行命令就可以了。
第一步:数据库设计:
生成数据表代码:
1 /*
2 Navicat MySQL Data Transfer
3
4 Source Server : localhost_3306
5 Source Server Version : 50722
6 Source Host : localhost:3306
7 Source Database : test1
8
9 Target Server Type : MYSQL
10 Target Server Version : 50722
11 File Encoding : 65001
12
13 Date: 2019-04-12 17:03:56
14 */
15
16 SET FOREIGN_KEY_CHECKS=0;
17
18 -- ----------------------------
19 -- Table structure for permission
20 -- ----------------------------
21 DROP TABLE IF EXISTS `permission`;
22 CREATE TABLE `permission` (
23 `pid` int(11) NOT NULL AUTO_INCREMENT,
24 `name` varchar(255) NOT NULL DEFAULT '',
25 `url` varchar(255) DEFAULT '',
26 PRIMARY KEY (`pid`)
27 ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
28
29 -- ----------------------------
30 -- Records of permission
31 -- ----------------------------
32 INSERT INTO `permission` VALUES ('1', 'add', '');
33 INSERT INTO `permission` VALUES ('2', 'delete', '');
34 INSERT INTO `permission` VALUES ('3', 'edit', '');
35 INSERT INTO `permission` VALUES ('4', 'query', '');
36
37 -- ----------------------------
38 -- Table structure for permission_role
39 -- ----------------------------
40 DROP TABLE IF EXISTS `permission_role`;
41 CREATE TABLE `permission_role` (
42 `rid` int(11) NOT NULL,
43 `pid` int(11) NOT NULL,
44 KEY `idx_rid` (`rid`),
45 KEY `idx_pid` (`pid`)
46 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
47
48 -- ----------------------------
49 -- Records of permission_role
50 -- ----------------------------
51 INSERT INTO `permission_role` VALUES ('1', '1');
52 INSERT INTO `permission_role` VALUES ('1', '2');
53 INSERT INTO `permission_role` VALUES ('1', '3');
54 INSERT INTO `permission_role` VALUES ('1', '4');
55 INSERT INTO `permission_role` VALUES ('2', '1');
56 INSERT INTO `permission_role` VALUES ('2', '4');
57
58 -- ----------------------------
59 -- Table structure for role
60 -- ----------------------------
61 DROP TABLE IF EXISTS `role`;
62 CREATE TABLE `role` (
63 `rid` int(11) NOT NULL AUTO_INCREMENT,
64 `rname` varchar(255) NOT NULL DEFAULT '',
65 PRIMARY KEY (`rid`)
66 ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
67
68 -- ----------------------------
69 -- Records of role
70 -- ----------------------------
71 INSERT INTO `role` VALUES ('1', 'admin');
72 INSERT INTO `role` VALUES ('2', 'customer');
73
74 -- ----------------------------
75 -- Table structure for sys_acl
76 -- ----------------------------
77 DROP TABLE IF EXISTS `sys_acl`;
78 CREATE TABLE `sys_acl` (
79 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '权限id',
80 `code` varchar(20) NOT NULL DEFAULT '' COMMENT '权限码',
81 `name` varchar(20) NOT NULL DEFAULT '' COMMENT '权限名称',
82 `acl_module_id` int(11) NOT NULL DEFAULT '0' COMMENT '权限所在的权限模块id',
83 `url` varchar(100) NOT NULL DEFAULT '' COMMENT '请求的url, 可以填正则表达式',
84 `type` int(11) NOT NULL DEFAULT '3' COMMENT '类型,1:菜单,2:按钮,3:其他',
85 `status` int(11) NOT NULL DEFAULT '1' COMMENT '状态,1:正常,0:冻结',
86 `seq` int(11) NOT NULL DEFAULT '0' COMMENT '权限在当前模块下的顺序,由小到大',
87 `remark` varchar(200) DEFAULT '' COMMENT '备注',
88 `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
89 `operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新时间',
90 `operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一个更新者的ip地址',
91 PRIMARY KEY (`id`)
92 ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4;
93
94 -- ----------------------------
95 -- Records of sys_acl
96 -- ----------------------------
97 INSERT INTO `sys_acl` VALUES ('1', '20171015095130_26', '进入产品管理界面', '1', '/sys/product/product.page', '1', '1', '1', '', 'Admin', '2017-10-15 09:51:30', '0:0:0:0:0:0:0:1');
98 INSERT INTO `sys_acl` VALUES ('2', '20171015095322_14', '查询产品列表', '1', '/sys/product/page.json', '2', '1', '2', '', 'Admin', '2017-10-15 09:53:22', '0:0:0:0:0:0:0:1');
99 INSERT INTO `sys_acl` VALUES ('3', '20171015095350_69', '产品上架', '1', '/sys/product/online.json', '2', '1', '3', '', 'Admin', '2017-10-15 09:53:51', '0:0:0:0:0:0:0:1');
100 INSERT INTO `sys_acl` VALUES ('4', '20171015095420_7', '产品下架', '1', '/sys/product/offline.json', '2', '1', '4', '', 'Admin', '2017-10-15 10:11:28', '0:0:0:0:0:0:0:1');
101 INSERT INTO `sys_acl` VALUES ('5', '20171015212626_63', '进入订单页', '2', '/sys/order/order.page', '1', '1', '1', '', 'Admin', '2017-10-15 21:26:27', '0:0:0:0:0:0:0:1');
102 INSERT INTO `sys_acl` VALUES ('6', '20171015212657_12', '查询订单列表', '2', '/sys/order/list.json', '2', '1', '2', '', 'Admin', '2017-10-15 21:26:57', '0:0:0:0:0:0:0:1');
103 INSERT INTO `sys_acl` VALUES ('7', '20171015212907_36', '进入权限管理页', '7', '/sys/aclModule/acl.page', '1', '1', '1', '', 'Admin', '2017-10-15 21:29:07', '0:0:0:0:0:0:0:1');
104 INSERT INTO `sys_acl` VALUES ('8', '20171015212938_27', '进入角色管理页', '8', '/sys/role/role.page', '1', '1', '1', '', 'Admin', '2017-10-16 17:49:38', '0:0:0:0:0:0:0:1');
105 INSERT INTO `sys_acl` VALUES ('9', '20171015213009_0', '进入用户管理页', '9', '/sys/dept/dept.page', '1', '1', '1', '', 'Admin', '2017-10-15 21:30:09', '0:0:0:0:0:0:0:1');
106 INSERT INTO `sys_acl` VALUES ('10', '20171016230429_8', '进入权限更新记录页面', '11', '/sys/log/log.page', '1', '1', '1', '', 'Admin', '2017-10-16 23:04:49', '0:0:0:0:0:0:0:1');
107
108 -- ----------------------------
109 -- Table structure for sys_acl_module
110 -- ----------------------------
111 DROP TABLE IF EXISTS `sys_acl_module`;
112 CREATE TABLE `sys_acl_module` (
113 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '权限模块id',
114 `name` varchar(20) NOT NULL DEFAULT '' COMMENT '权限模块名称',
115 `parent_id` int(11) NOT NULL DEFAULT '0' COMMENT '上级权限模块id',
116 `level` varchar(200) NOT NULL DEFAULT '' COMMENT '权限模块层级',
117 `seq` int(11) NOT NULL DEFAULT '0' COMMENT '权限模块在当前层级下的顺序,由小到大',
118 `status` int(11) NOT NULL DEFAULT '1' COMMENT '状态,1:正常,0:冻结',
119 `remark` varchar(200) DEFAULT '' COMMENT '备注',
120 `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
121 `operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次操作时间',
122 `operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新操作者的ip地址',
123 PRIMARY KEY (`id`)
124 ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
125
126 -- ----------------------------
127 -- Records of sys_acl_module
128 -- ----------------------------
129 INSERT INTO `sys_acl_module` VALUES ('1', '产品管理', '0', '0', '1', '1', 'product', 'Admin', '2017-10-14 21:13:15', '0:0:0:0:0:0:0:1');
130 INSERT INTO `sys_acl_module` VALUES ('2', '订单管理', '0', '0', '2', '1', '', 'Admin', '2017-10-14 20:17:11', '0:0:0:0:0:0:0:1');
131 INSERT INTO `sys_acl_module` VALUES ('3', '公告管理', '0', '0', '3', '1', '', 'Admin', '2017-10-14 20:17:21', '0:0:0:0:0:0:0:1');
132 INSERT INTO `sys_acl_module` VALUES ('4', '出售中产品管理', '1', '0.1', '1', '1', '', 'Admin', '2017-10-14 21:13:39', '0:0:0:0:0:0:0:1');
133 INSERT INTO `sys_acl_module` VALUES ('5', '下架产品管理', '1', '0.1', '2', '1', '', 'Admin', '2017-10-14 20:18:02', '0:0:0:0:0:0:0:1');
134 INSERT INTO `sys_acl_module` VALUES ('6', '权限管理', '0', '0', '4', '1', '', 'Admin', '2017-10-15 21:27:37', '0:0:0:0:0:0:0:1');
135 INSERT INTO `sys_acl_module` VALUES ('7', '权限管理', '6', '0.6', '1', '1', '', 'Admin', '2017-10-15 21:27:57', '0:0:0:0:0:0:0:1');
136 INSERT INTO `sys_acl_module` VALUES ('8', '角色管理', '6', '0.6', '2', '1', '', 'Admin', '2017-10-15 21:28:22', '0:0:0:0:0:0:0:1');
137 INSERT INTO `sys_acl_module` VALUES ('9', '用户管理', '6', '0.6', '2', '1', '', 'Admin', '2017-10-15 21:28:36', '0:0:0:0:0:0:0:1');
138 INSERT INTO `sys_acl_module` VALUES ('10', '运维管理', '0', '0', '6', '1', '', 'Admin', '2017-10-16 23:03:37', '0:0:0:0:0:0:0:1');
139 INSERT INTO `sys_acl_module` VALUES ('11', '权限更新记录管理', '6', '0.6', '4', '1', '', 'Admin', '2017-10-16 23:04:07', '0:0:0:0:0:0:0:1');
140
141 -- ----------------------------
142 -- Table structure for sys_dept
143 -- ----------------------------
144 DROP TABLE IF EXISTS `sys_dept`;
145 CREATE TABLE `sys_dept` (
146 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '部门id',
147 `name` varchar(20) NOT NULL DEFAULT '' COMMENT '部门名称',
148 `parent_id` int(11) NOT NULL DEFAULT '0' COMMENT '上级部门id',
149 `level` varchar(200) NOT NULL DEFAULT '' COMMENT '部门层级',
150 `seq` int(11) NOT NULL DEFAULT '0' COMMENT '部门在当前层级下的顺序,由小到大',
151 `remark` varchar(200) DEFAULT '' COMMENT '备注',
152 `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
153 `operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次操作时间',
154 `operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新操作者的ip地址',
155 PRIMARY KEY (`id`)
156 ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4;
157
158 -- ----------------------------
159 -- Records of sys_dept
160 -- ----------------------------
161 INSERT INTO `sys_dept` VALUES ('1', '技术部', '0', '0', '1', '技术部', 'system', '2017-10-11 07:21:40', '127.0.0.1');
162 INSERT INTO `sys_dept` VALUES ('2', '后端开发', '1', '0.1', '1', '后端', 'system-update', '2017-10-12 07:56:16', '127.0.0.1');
163 INSERT INTO `sys_dept` VALUES ('3', '前端开发', '1', '0.1', '2', '', 'system-update', '2017-10-14 11:29:45', '127.0.0.1');
164 INSERT INTO `sys_dept` VALUES ('4', 'UI设计', '1', '0.1', '3', '', 'system', '2017-10-12 07:55:43', '127.0.0.1');
165 INSERT INTO `sys_dept` VALUES ('11', '产品部', '0', '0', '2', '', 'Admin', '2017-10-16 22:52:29', '0:0:0:0:0:0:0:1');
166 INSERT INTO `sys_dept` VALUES ('12', '客服部', '0', '0', '4', '', 'Admin', '2017-10-17 00:22:55', '0:0:0:0:0:0:0:1');
167
168 -- ----------------------------
169 -- Table structure for sys_log
170 -- ----------------------------
171 DROP TABLE IF EXISTS `sys_log`;
172 CREATE TABLE `sys_log` (
173 `id` int(11) NOT NULL AUTO_INCREMENT,
174 `type` int(11) NOT NULL DEFAULT '0' COMMENT '权限更新的类型,1:部门,2:用户,3:权限模块,4:权限,5:角色,6:角色用户关系,7:角色权限关系',
175 `target_id` int(11) NOT NULL COMMENT '基于type后指定的对象id,比如用户、权限、角色等表的主键',
176 `old_value` text COMMENT '旧值',
177 `new_value` text COMMENT '新值',
178 `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
179 `operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新的时间',
180 `operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip地址',
181 `status` int(11) NOT NULL DEFAULT '0' COMMENT '当前是否复原过,0:没有,1:复原过',
182 PRIMARY KEY (`id`)
183 ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4;
184
185 -- ----------------------------
186 -- Records of sys_log
187 -- ----------------------------
188 INSERT INTO `sys_log` VALUES ('2', '1', '12', '', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":3,\"operator\":\"Admin\",\"operateTime\":1508166002610,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:00:03', '0:0:0:0:0:0:0:1', '1');
189 INSERT INTO `sys_log` VALUES ('3', '1', '12', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":3,\"operator\":\"Admin\",\"operateTime\":1508166003000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508166009313,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:00:09', '0:0:0:0:0:0:0:1', '1');
190 INSERT INTO `sys_log` VALUES ('4', '2', '4', '', '{\"id\":4,\"username\":\"Kate\",\"telephone\":\"13144445555\",\"mail\":\"kate@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":1,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166166297,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:02:46', '0:0:0:0:0:0:0:1', '1');
191 INSERT INTO `sys_log` VALUES ('5', '2', '4', '{\"id\":4,\"username\":\"Kate\",\"telephone\":\"13144445555\",\"mail\":\"kate@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":1,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166166000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":4,\"username\":\"Kate\",\"telephone\":\"13144445555\",\"mail\":\"kate@qq.com\",\"deptId\":1,\"status\":1,\"remark\":\"sss\",\"operator\":\"Admin\",\"operateTime\":1508166171320,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:02:51', '0:0:0:0:0:0:0:1', '1');
192 INSERT INTO `sys_log` VALUES ('6', '3', '10', '', '{\"id\":10,\"name\":\"运维管理\",\"parentId\":0,\"level\":\"0\",\"seq\":5,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166212527,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:03:33', '0:0:0:0:0:0:0:1', '1');
193 INSERT INTO `sys_log` VALUES ('7', '3', '10', '{\"id\":10,\"name\":\"运维管理\",\"parentId\":0,\"level\":\"0\",\"seq\":5,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166213000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":10,\"name\":\"运维管理\",\"parentId\":0,\"level\":\"0\",\"seq\":6,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166217376,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:03:37', '0:0:0:0:0:0:0:1', '1');
194 INSERT INTO `sys_log` VALUES ('8', '3', '11', '', '{\"id\":11,\"name\":\"权限更新记录管理\",\"parentId\":6,\"level\":\"0.6\",\"seq\":4,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166246805,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:04:07', '0:0:0:0:0:0:0:1', '1');
195 INSERT INTO `sys_log` VALUES ('9', '4', '10', '', '{\"id\":10,\"code\":\"20171016230429_8\",\"name\":\"进入权限更新记录页面\",\"aclModuleId\":1,\"url\":\"/sys/log/log.page\",\"type\":1,\"status\":1,\"seq\":1,\"operator\":\"Admin\",\"operateTime\":1508166269419,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:04:29', '0:0:0:0:0:0:0:1', '1');
196 INSERT INTO `sys_log` VALUES ('10', '4', '10', '{\"id\":10,\"code\":\"20171016230429_8\",\"name\":\"进入权限更新记录页面\",\"aclModuleId\":1,\"url\":\"/sys/log/log.page\",\"type\":1,\"status\":1,\"seq\":1,\"operator\":\"Admin\",\"operateTime\":1508166269000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":10,\"name\":\"进入权限更新记录页面\",\"aclModuleId\":11,\"url\":\"/sys/log/log.page\",\"type\":1,\"status\":1,\"seq\":1,\"operator\":\"Admin\",\"operateTime\":1508166288589,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:04:49', '0:0:0:0:0:0:0:1', '1');
197 INSERT INTO `sys_log` VALUES ('11', '5', '5', '', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166301130,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:05:01', '0:0:0:0:0:0:0:1', '1');
198 INSERT INTO `sys_log` VALUES ('12', '5', '5', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166301000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508166307317,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:05:07', '0:0:0:0:0:0:0:1', '1');
199 INSERT INTO `sys_log` VALUES ('13', '6', '4', '[7,8,9]', '[7,8,9,10]', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1', '1');
200 INSERT INTO `sys_log` VALUES ('14', '7', '4', '[1]', '[1,4]', 'Admin', '2017-10-16 23:34:44', '0:0:0:0:0:0:0:1', '1');
201 INSERT INTO `sys_log` VALUES ('15', '2', '5', '', '{\"id\":5,\"username\":\"服务员A\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170918338,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:21:58', '0:0:0:0:0:0:0:1', '1');
202 INSERT INTO `sys_log` VALUES ('16', '2', '5', '{\"id\":5,\"username\":\"服务员A\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170918000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"username\":\"服务员B\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170924698,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:22:05', '0:0:0:0:0:0:0:1', '1');
203 INSERT INTO `sys_log` VALUES ('17', '2', '5', '{\"id\":5,\"username\":\"服务员B\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170925000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"username\":\"服务员A\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170934791,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:22:15', '0:0:0:0:0:0:0:1', '1');
204 INSERT INTO `sys_log` VALUES ('18', '1', '12', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508166009000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":12,\"name\":\"客服部A\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508170966051,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:22:46', '0:0:0:0:0:0:0:1', '1');
205 INSERT INTO `sys_log` VALUES ('19', '1', '12', '{\"id\":12,\"name\":\"客服部A\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508170966000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508170975242,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:22:55', '0:0:0:0:0:0:0:1', '1');
206 INSERT INTO `sys_log` VALUES ('20', '5', '5', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508166307000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"name\":\"运维管理员A\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508170997531,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:23:18', '0:0:0:0:0:0:0:1', '1');
207 INSERT INTO `sys_log` VALUES ('21', '5', '5', '{\"id\":5,\"name\":\"运维管理员A\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508170998000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508171007651,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:23:28', '0:0:0:0:0:0:0:1', '1');
208 INSERT INTO `sys_log` VALUES ('22', '7', '4', '[1,4]', '[1,4,2,3,5]', 'Admin', '2017-10-17 00:23:53', '0:0:0:0:0:0:0:1', '1');
209 INSERT INTO `sys_log` VALUES ('23', '7', '4', '[1,4,2,3,5]', '[1,4]', 'Admin', '2017-10-17 00:24:04', '0:0:0:0:0:0:0:1', '1');
210 INSERT INTO `sys_log` VALUES ('24', '6', '5', '[]', '[7,8,9,10]', 'Admin', '2017-10-17 00:24:23', '0:0:0:0:0:0:0:1', '1');
211 INSERT INTO `sys_log` VALUES ('25', '6', '5', '[7,8,9,10]', '[]', 'Admin', '2017-10-17 00:24:34', '0:0:0:0:0:0:0:1', '1');
212
213 -- ----------------------------
214 -- Table structure for sys_role
215 -- ----------------------------
216 DROP TABLE IF EXISTS `sys_role`;
217 CREATE TABLE `sys_role` (
218 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '角色id',
219 `name` varchar(20) NOT NULL,
220 `type` int(11) NOT NULL DEFAULT '1' COMMENT '角色的类型,1:管理员角色,2:其他',
221 `status` int(11) NOT NULL DEFAULT '1' COMMENT '状态,1:可用,0:冻结',
222 `remark` varchar(200) DEFAULT '' COMMENT '备注',
223 `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
224 `operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新的时间',
225 `operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip地址',
226 PRIMARY KEY (`id`)
227 ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
228
229 -- ----------------------------
230 -- Records of sys_role
231 -- ----------------------------
232 INSERT INTO `sys_role` VALUES ('1', '产品管理员', '1', '1', '', 'Admin', '2017-10-15 12:42:47', '0:0:0:0:0:0:0:1');
233 INSERT INTO `sys_role` VALUES ('2', '订单管理员', '1', '1', '', 'Admin', '2017-10-15 12:18:59', '0:0:0:0:0:0:0:1');
234 INSERT INTO `sys_role` VALUES ('3', '公告管理员', '1', '1', '', 'Admin', '2017-10-15 12:19:10', '0:0:0:0:0:0:0:1');
235 INSERT INTO `sys_role` VALUES ('4', '权限管理员', '1', '1', '', 'Admin', '2017-10-15 21:30:36', '0:0:0:0:0:0:0:1');
236 INSERT INTO `sys_role` VALUES ('5', '运维管理员', '1', '1', '运维', 'Admin', '2017-10-17 00:23:28', '0:0:0:0:0:0:0:1');
237
238 -- ----------------------------
239 -- Table structure for sys_role_acl
240 -- ----------------------------
241 DROP TABLE IF EXISTS `sys_role_acl`;
242 CREATE TABLE `sys_role_acl` (
243 `id` int(11) NOT NULL AUTO_INCREMENT,
244 `role_id` int(11) NOT NULL COMMENT '角色id',
245 `acl_id` int(11) NOT NULL COMMENT '权限id',
246 `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
247 `operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新的时间',
248 `operate_ip` varchar(200) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip',
249 PRIMARY KEY (`id`)
250 ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4;
251
252 -- ----------------------------
253 -- Records of sys_role_acl
254 -- ----------------------------
255 INSERT INTO `sys_role_acl` VALUES ('9', '4', '7', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1');
256 INSERT INTO `sys_role_acl` VALUES ('10', '4', '8', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1');
257 INSERT INTO `sys_role_acl` VALUES ('11', '4', '9', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1');
258 INSERT INTO `sys_role_acl` VALUES ('12', '4', '10', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1');
259
260 -- ----------------------------
261 -- Table structure for sys_role_user
262 -- ----------------------------
263 DROP TABLE IF EXISTS `sys_role_user`;
264 CREATE TABLE `sys_role_user` (
265 `id` int(11) NOT NULL AUTO_INCREMENT,
266 `role_id` int(11) NOT NULL COMMENT '角色id',
267 `user_id` int(11) NOT NULL COMMENT '用户id',
268 `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
269 `operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新的时间',
270 `operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip地址',
271 PRIMARY KEY (`id`)
272 ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4;
273
274 -- ----------------------------
275 -- Records of sys_role_user
276 -- ----------------------------
277 INSERT INTO `sys_role_user` VALUES ('16', '4', '1', 'Admin', '2017-10-17 00:24:04', '0:0:0:0:0:0:0:1');
278 INSERT INTO `sys_role_user` VALUES ('17', '4', '4', 'Admin', '2017-10-17 00:24:04', '0:0:0:0:0:0:0:1');
279
280 -- ----------------------------
281 -- Table structure for sys_user
282 -- ----------------------------
283 DROP TABLE IF EXISTS `sys_user`;
284 CREATE TABLE `sys_user` (
285 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户id',
286 `username` varchar(20) NOT NULL DEFAULT '' COMMENT '用户名称',
287 `telephone` varchar(13) NOT NULL DEFAULT '' COMMENT '手机号',
288 `mail` varchar(20) NOT NULL DEFAULT '' COMMENT '邮箱',
289 `password` varchar(40) NOT NULL DEFAULT '' COMMENT '加密后的密码',
290 `dept_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户所在部门的id',
291 `status` int(11) NOT NULL DEFAULT '1' COMMENT '状态,1:正常,0:冻结状态,2:删除',
292 `remark` varchar(200) DEFAULT '' COMMENT '备注',
293 `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
294 `operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新时间',
295 `operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip地址',
296 PRIMARY KEY (`id`)
297 ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
298
299 -- ----------------------------
300 -- Records of sys_user
301 -- ----------------------------
302 INSERT INTO `sys_user` VALUES ('1', 'Admin', '18612344321', 'admin@qq.com', '25D55AD283AA400AF464C76D713C07AD', '1', '1', 'admin', 'system', '2017-10-13 08:46:16', '127.0.0.1');
303 INSERT INTO `sys_user` VALUES ('2', 'Jimin', '13188889999', 'jimin@qq.com', '25D55AD283AA400AF464C76D713C07AD', '1', '1', 'jimin.zheng', 'Admin', '2017-10-14 14:45:19', '127.0.0.1');
304 INSERT INTO `sys_user` VALUES ('3', 'Jimmy', '13812344311', 'jimmy@qq.com', '25D55AD283AA400AF464C76D713C07AD', '2', '1', '', 'Admin', '2017-10-16 12:57:35', '0:0:0:0:0:0:0:1');
305 INSERT INTO `sys_user` VALUES ('4', 'Kate', '13144445555', 'kate@qq.com', '25D55AD283AA400AF464C76D713C07AD', '1', '1', 'sss', 'Admin', '2017-10-16 23:02:51', '0:0:0:0:0:0:0:1');
306 INSERT INTO `sys_user` VALUES ('5', '服务员A', '18677778888', 'service@qq.com', '25D55AD283AA400AF464C76D713C07AD', '12', '1', '', 'Admin', '2017-10-17 00:22:15', '0:0:0:0:0:0:0:1');
307
308 -- ----------------------------
309 -- Table structure for user
310 -- ----------------------------
311 DROP TABLE IF EXISTS `user`;
312 CREATE TABLE `user` (
313 `uid` int(11) NOT NULL AUTO_INCREMENT,
314 `username` varchar(255) NOT NULL DEFAULT '',
315 `password` varchar(255) NOT NULL DEFAULT '',
316 PRIMARY KEY (`uid`)
317 ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
318
319 -- ----------------------------
320 -- Records of user
321 -- ----------------------------
322 INSERT INTO `user` VALUES ('1', 'admin', '123');
323 INSERT INTO `user` VALUES ('2', 'demo', '123');
324
325 -- ----------------------------
326 -- Table structure for user_role
327 -- ----------------------------
328 DROP TABLE IF EXISTS `user_role`;
329 CREATE TABLE `user_role` (
330 `uid` int(11) NOT NULL,
331 `rid` int(11) NOT NULL,
332 KEY `idx_uid` (`uid`),
333 KEY `idx_rid` (`rid`)
334 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
335
336 -- ----------------------------
337 -- Records of user_role
338 -- ----------------------------
339 INSERT INTO `user_role` VALUES ('1', '1');
340 INSERT INTO `user_role` VALUES ('2', '2');
View Code
第二步:把Generator工具包导入到项目中
数据库设计好以后,接下来开始导入Generator工具包到项目中。下载地址generator包我放到自己的csdn中,下载地址javascript:void(0)
第三步:修改generator.xml
1.数据库驱动包位置
2.数据库链接URL、用户名、密码(案例mysql,数据库)
1 <!-- 数据库链接URL、用户名、密码 -->
2 <jdbcConnection driverClass="com.mysql.jdbc.Driver" cnotallow="jdbc:mysql://localhost:3306/test1?characterEncoding=utf8" userId="root" password="123456"> <!-- 2 -->
3 </jdbcConnection>
View Code
3.生成模型的包名和位置
1 <!-- 生成模型的包名和位置 --> <!-- 3 -->
2 <javaModelGenerator targetPackage="com.mmall.model" targetProject="D:/IDEAProject/CYL/generator/src">
3 <property name="enableSubPackages" value="true" />
4 <property name="trimStrings" value="true" />
5 </javaModelGenerator>
View Code
4.生成的映射文件包名和位置
1 <!-- 生成的映射文件包名和位置 --> <!-- 4 -->
2 <sqlMapGenerator targetPackage="com.mmall.mapper" targetProject="D:/IDEAProject/CYL/generator/src">
3 <property name="enableSubPackages" value="true" />
4 </sqlMapGenerator>
View Code
5.生成DAO的包名和位置
1 <!-- 生成DAO的包名和位置 --> <!-- 5 -->
2 <javaClientGenerator type="XMLMAPPER" targetPackage="com.mmall.dao" targetProject="D:/IDEAProject/CYL/generator/src">
3 <property name="enableSubPackages" value="true" />
View Code
6.要生成那些表(更改tableName和domainObjectName(注意:tableName与domainObjectName的对应关系)
1 <!-- 要生成那些表(更改tableName和domainObjectName就可以) --><!-- 6 -->
2 <table tableName="sys_user" domainObjectName="SysUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
3 <table tableName="sys_dept" domainObjectName="SysDept" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
4 <table tableName="sys_acl" domainObjectName="SysAcl" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
5 <table tableName="sys_acl_module" domainObjectName="SysAclModule" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
6 <table tableName="sys_role" domainObjectName="SysRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
7 <table tableName="sys_role_acl" domainObjectName="SysRoleAcl" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
8 <table tableName="sys_role_user" domainObjectName="SysRoleUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
9 <table tableName="sys_log" domainObjectName="SysLog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
View Code
第四步:生成核心代码
打开IDEA的Terminal,输入命令如下图所示
生成核心代码,将会出现你做配制的路径下。