Commit e8e828df by fengshuonan

删除generator模块

parent 29076e80
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
<groupId>com.stylefeng</groupId> <groupId>com.stylefeng</groupId>
<artifactId>guns-core</artifactId> <artifactId>guns-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.stylefeng</groupId>
<artifactId>guns-generator</artifactId>
</dependency>
<!--spring boot依赖--> <!--spring boot依赖-->
<dependency> <dependency>
...@@ -86,12 +82,12 @@ ...@@ -86,12 +82,12 @@
<!--需要分布式session的话需要放开注释--> <!--需要分布式session的话需要放开注释-->
<!--<dependency>--> <!--<dependency>-->
<!--<groupId>org.springframework.session</groupId>--> <!--<groupId>org.springframework.session</groupId>-->
<!--<artifactId>spring-session-data-redis</artifactId>--> <!--<artifactId>spring-session-data-redis</artifactId>-->
<!--</dependency>--> <!--</dependency>-->
<!--<dependency>--> <!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>--> <!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-data-redis</artifactId>--> <!--<artifactId>spring-boot-starter-data-redis</artifactId>-->
<!--</dependency>--> <!--</dependency>-->
<dependency> <dependency>
......
/* DROP DATABASE IF EXISTS guns;
Navicat MySQL Data Transfer CREATE DATABASE IF NOT EXISTS guns DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
Source Server : localhost USE guns;
Source Server Version : 50721
Source Host : localhost:3306
Source Database : guns
Target Server Type : MYSQL /*
Target Server Version : 50721 Navicat Premium Data Transfer
File Encoding : 65001
Date: 2018-06-26 23:10:40 Source Server : localhost
*/ Source Server Type : MySQL
Source Server Version : 50719
Source Host : localhost:3306
Source Schema : guns
DROP DATABASE IF EXISTS guns; Target Server Type : MySQL
CREATE DATABASE IF NOT EXISTS guns DEFAULT CHARSET utf8 COLLATE utf8_general_ci; Target Server Version : 50719
File Encoding : 65001
USE guns; Date: 08/10/2018 17:19:48
*/
SET FOREIGN_KEY_CHECKS=0; SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_dept -- Table structure for sys_dept
...@@ -39,10 +41,12 @@ CREATE TABLE `sys_dept` ( ...@@ -39,10 +41,12 @@ CREATE TABLE `sys_dept` (
-- ---------------------------- -- ----------------------------
-- Records of sys_dept -- Records of sys_dept
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_dept` VALUES ('24', '1', '0', '[0],', '总公司', '总公司', '', null); BEGIN;
INSERT INTO `sys_dept` VALUES ('25', '2', '24', '[0],[24],', '开发部', '开发部', '', null); INSERT INTO `sys_dept` VALUES (24, 1, 0, '[0],', '总公司', '总公司', '', NULL);
INSERT INTO `sys_dept` VALUES ('26', '3', '24', '[0],[24],', '运营部', '运营部', '', null); INSERT INTO `sys_dept` VALUES (25, 2, 24, '[0],[24],', '开发部', '开发部', '', NULL);
INSERT INTO `sys_dept` VALUES ('27', '4', '24', '[0],[24],', '战略部', '战略部', '', null); INSERT INTO `sys_dept` VALUES (26, 3, 24, '[0],[24],', '运营部', '运营部', '', NULL);
INSERT INTO `sys_dept` VALUES (27, 4, 24, '[0],[24],', '战略部', '战略部', '', NULL);
COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_dict -- Table structure for sys_dict
...@@ -61,16 +65,18 @@ CREATE TABLE `sys_dict` ( ...@@ -61,16 +65,18 @@ CREATE TABLE `sys_dict` (
-- ---------------------------- -- ----------------------------
-- Records of sys_dict -- Records of sys_dict
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_dict` VALUES ('50', '0', '0', '性别', null, 'sys_sex'); BEGIN;
INSERT INTO `sys_dict` VALUES ('51', '1', '50', '男', null, '1'); INSERT INTO `sys_dict` VALUES (50, 0, 0, '性别', NULL, 'sys_sex');
INSERT INTO `sys_dict` VALUES ('52', '2', '50', '女', null, '2'); INSERT INTO `sys_dict` VALUES (51, 1, 50, '男', NULL, '1');
INSERT INTO `sys_dict` VALUES ('53', '0', '0', '状态', null, 'sys_state'); INSERT INTO `sys_dict` VALUES (52, 2, 50, '女', NULL, '2');
INSERT INTO `sys_dict` VALUES ('54', '1', '53', '启用', null, '1'); INSERT INTO `sys_dict` VALUES (53, 0, 0, '状态', NULL, 'sys_state');
INSERT INTO `sys_dict` VALUES ('55', '2', '53', '禁用', null, '2'); INSERT INTO `sys_dict` VALUES (54, 1, 53, '启用', NULL, '1');
INSERT INTO `sys_dict` VALUES ('56', '0', '0', '账号状态', null, 'account_state'); INSERT INTO `sys_dict` VALUES (55, 2, 53, '禁用', NULL, '2');
INSERT INTO `sys_dict` VALUES ('57', '1', '56', '启用', null, '1'); INSERT INTO `sys_dict` VALUES (56, 0, 0, '账号状态', NULL, 'account_state');
INSERT INTO `sys_dict` VALUES ('58', '2', '56', '冻结', null, '2'); INSERT INTO `sys_dict` VALUES (57, 1, 56, '启用', NULL, '1');
INSERT INTO `sys_dict` VALUES ('59', '3', '56', '已删除', null, '3'); INSERT INTO `sys_dict` VALUES (58, 2, 56, '冻结', NULL, '2');
INSERT INTO `sys_dict` VALUES (59, 3, 56, '已删除', NULL, '3');
COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_expense -- Table structure for sys_expense
...@@ -88,10 +94,6 @@ CREATE TABLE `sys_expense` ( ...@@ -88,10 +94,6 @@ CREATE TABLE `sys_expense` (
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COMMENT='报销表'; ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COMMENT='报销表';
-- ---------------------------- -- ----------------------------
-- Records of sys_expense
-- ----------------------------
-- ----------------------------
-- Table structure for sys_login_log -- Table structure for sys_login_log
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sys_login_log`; DROP TABLE IF EXISTS `sys_login_log`;
...@@ -104,11 +106,7 @@ CREATE TABLE `sys_login_log` ( ...@@ -104,11 +106,7 @@ CREATE TABLE `sys_login_log` (
`message` text COMMENT '具体消息', `message` text COMMENT '具体消息',
`ip` varchar(255) DEFAULT NULL COMMENT '登录ip', `ip` varchar(255) DEFAULT NULL COMMENT '登录ip',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=217 DEFAULT CHARSET=utf8 COMMENT='登录记录'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='登录记录';
-- ----------------------------
-- Records of sys_login_log
-- ----------------------------
-- ---------------------------- -- ----------------------------
-- Table structure for sys_menu -- Table structure for sys_menu
...@@ -134,61 +132,62 @@ CREATE TABLE `sys_menu` ( ...@@ -134,61 +132,62 @@ CREATE TABLE `sys_menu` (
-- ---------------------------- -- ----------------------------
-- Records of sys_menu -- Records of sys_menu
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_menu` VALUES ('105', 'system', '0', '[0],', '系统管理', 'fa-user', '#', '4', '1', '1', null, '1', '1'); BEGIN;
INSERT INTO `sys_menu` VALUES ('106', 'mgr', 'system', '[0],[system],', '用户管理', '', '/mgr', '1', '2', '1', null, '1', '0'); INSERT INTO `sys_menu` VALUES (105, 'system', '0', '[0],', '系统管理', 'fa-user', '#', 4, 1, 1, NULL, 1, 1);
INSERT INTO `sys_menu` VALUES ('107', 'mgr_add', 'mgr', '[0],[system],[mgr],', '添加用户', null, '/mgr/add', '1', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (106, 'mgr', 'system', '[0],[system],', '用户管理', '', '/mgr', 1, 2, 1, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('108', 'mgr_edit', 'mgr', '[0],[system],[mgr],', '修改用户', null, '/mgr/edit', '2', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (107, 'mgr_add', 'mgr', '[0],[system],[mgr],', '添加用户', NULL, '/mgr/add', 1, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('109', 'mgr_delete', 'mgr', '[0],[system],[mgr],', '删除用户', null, '/mgr/delete', '3', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (108, 'mgr_edit', 'mgr', '[0],[system],[mgr],', '修改用户', NULL, '/mgr/edit', 2, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('110', 'mgr_reset', 'mgr', '[0],[system],[mgr],', '重置密码', null, '/mgr/reset', '4', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (109, 'mgr_delete', 'mgr', '[0],[system],[mgr],', '删除用户', NULL, '/mgr/delete', 3, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('111', 'mgr_freeze', 'mgr', '[0],[system],[mgr],', '冻结用户', null, '/mgr/freeze', '5', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (110, 'mgr_reset', 'mgr', '[0],[system],[mgr],', '重置密码', NULL, '/mgr/reset', 4, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('112', 'mgr_unfreeze', 'mgr', '[0],[system],[mgr],', '解除冻结用户', null, '/mgr/unfreeze', '6', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (111, 'mgr_freeze', 'mgr', '[0],[system],[mgr],', '冻结用户', NULL, '/mgr/freeze', 5, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('113', 'mgr_setRole', 'mgr', '[0],[system],[mgr],', '分配角色', null, '/mgr/setRole', '7', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (112, 'mgr_unfreeze', 'mgr', '[0],[system],[mgr],', '解除冻结用户', NULL, '/mgr/unfreeze', 6, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('114', 'role', 'system', '[0],[system],', '角色管理', null, '/role', '2', '2', '1', null, '1', '0'); INSERT INTO `sys_menu` VALUES (113, 'mgr_setRole', 'mgr', '[0],[system],[mgr],', '分配角色', NULL, '/mgr/setRole', 7, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('115', 'role_add', 'role', '[0],[system],[role],', '添加角色', null, '/role/add', '1', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (114, 'role', 'system', '[0],[system],', '角色管理', NULL, '/role', 2, 2, 1, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('116', 'role_edit', 'role', '[0],[system],[role],', '修改角色', null, '/role/edit', '2', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (115, 'role_add', 'role', '[0],[system],[role],', '添加角色', NULL, '/role/add', 1, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('117', 'role_remove', 'role', '[0],[system],[role],', '删除角色', null, '/role/remove', '3', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (116, 'role_edit', 'role', '[0],[system],[role],', '修改角色', NULL, '/role/edit', 2, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('118', 'role_setAuthority', 'role', '[0],[system],[role],', '配置权限', null, '/role/setAuthority', '4', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (117, 'role_remove', 'role', '[0],[system],[role],', '删除角色', NULL, '/role/remove', 3, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('119', 'menu', 'system', '[0],[system],', '菜单管理', null, '/menu', '4', '2', '1', null, '1', '0'); INSERT INTO `sys_menu` VALUES (118, 'role_setAuthority', 'role', '[0],[system],[role],', '配置权限', NULL, '/role/setAuthority', 4, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('120', 'menu_add', 'menu', '[0],[system],[menu],', '添加菜单', null, '/menu/add', '1', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (119, 'menu', 'system', '[0],[system],', '菜单管理', NULL, '/menu', 4, 2, 1, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('121', 'menu_edit', 'menu', '[0],[system],[menu],', '修改菜单', null, '/menu/edit', '2', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (120, 'menu_add', 'menu', '[0],[system],[menu],', '添加菜单', NULL, '/menu/add', 1, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('122', 'menu_remove', 'menu', '[0],[system],[menu],', '删除菜单', null, '/menu/remove', '3', '3', '0', null, '1', '0'); INSERT INTO `sys_menu` VALUES (121, 'menu_edit', 'menu', '[0],[system],[menu],', '修改菜单', NULL, '/menu/edit', 2, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('128', 'log', 'system', '[0],[system],', '业务日志', null, '/log', '6', '2', '1', null, '1', '0'); INSERT INTO `sys_menu` VALUES (122, 'menu_remove', 'menu', '[0],[system],[menu],', '删除菜单', NULL, '/menu/remove', 3, 3, 0, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('130', 'druid', 'system', '[0],[system],', '监控管理', null, '/druid', '7', '2', '1', null, '1', null); INSERT INTO `sys_menu` VALUES (128, 'log', 'system', '[0],[system],', '业务日志', NULL, '/log', 6, 2, 1, NULL, 1, 0);
INSERT INTO `sys_menu` VALUES ('131', 'dept', 'system', '[0],[system],', '部门管理', null, '/dept', '3', '2', '1', null, '1', null); INSERT INTO `sys_menu` VALUES (130, 'druid', 'system', '[0],[system],', '监控管理', NULL, '/druid', 7, 2, 1, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('132', 'dict', 'system', '[0],[system],', '字典管理', null, '/dict', '4', '2', '1', null, '1', null); INSERT INTO `sys_menu` VALUES (131, 'dept', 'system', '[0],[system],', '部门管理', NULL, '/dept', 3, 2, 1, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('133', 'loginLog', 'system', '[0],[system],', '登录日志', null, '/loginLog', '6', '2', '1', null, '1', null); INSERT INTO `sys_menu` VALUES (132, 'dict', 'system', '[0],[system],', '字典管理', NULL, '/dict', 4, 2, 1, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('134', 'log_clean', 'log', '[0],[system],[log],', '清空日志', null, '/log/delLog', '3', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (133, 'loginLog', 'system', '[0],[system],', '登录日志', NULL, '/loginLog', 6, 2, 1, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('135', 'dept_add', 'dept', '[0],[system],[dept],', '添加部门', null, '/dept/add', '1', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (134, 'log_clean', 'log', '[0],[system],[log],', '清空日志', NULL, '/log/delLog', 3, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('136', 'dept_update', 'dept', '[0],[system],[dept],', '修改部门', null, '/dept/update', '1', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (135, 'dept_add', 'dept', '[0],[system],[dept],', '添加部门', NULL, '/dept/add', 1, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('137', 'dept_delete', 'dept', '[0],[system],[dept],', '删除部门', null, '/dept/delete', '1', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (136, 'dept_update', 'dept', '[0],[system],[dept],', '修改部门', NULL, '/dept/update', 1, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('138', 'dict_add', 'dict', '[0],[system],[dict],', '添加字典', null, '/dict/add', '1', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (137, 'dept_delete', 'dept', '[0],[system],[dept],', '删除部门', NULL, '/dept/delete', 1, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('139', 'dict_update', 'dict', '[0],[system],[dict],', '修改字典', null, '/dict/update', '1', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (138, 'dict_add', 'dict', '[0],[system],[dict],', '添加字典', NULL, '/dict/add', 1, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('140', 'dict_delete', 'dict', '[0],[system],[dict],', '删除字典', null, '/dict/delete', '1', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (139, 'dict_update', 'dict', '[0],[system],[dict],', '修改字典', NULL, '/dict/update', 1, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('141', 'notice', 'system', '[0],[system],', '通知管理', null, '/notice', '9', '2', '1', null, '1', null); INSERT INTO `sys_menu` VALUES (140, 'dict_delete', 'dict', '[0],[system],[dict],', '删除字典', NULL, '/dict/delete', 1, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('142', 'notice_add', 'notice', '[0],[system],[notice],', '添加通知', null, '/notice/add', '1', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (141, 'notice', 'system', '[0],[system],', '通知管理', NULL, '/notice', 9, 2, 1, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('143', 'notice_update', 'notice', '[0],[system],[notice],', '修改通知', null, '/notice/update', '2', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (142, 'notice_add', 'notice', '[0],[system],[notice],', '添加通知', NULL, '/notice/add', 1, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('144', 'notice_delete', 'notice', '[0],[system],[notice],', '删除通知', null, '/notice/delete', '3', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (143, 'notice_update', 'notice', '[0],[system],[notice],', '修改通知', NULL, '/notice/update', 2, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('145', 'hello', '0', '[0],', '通知', 'fa-rocket', '/notice/hello', '1', '1', '1', null, '1', null); INSERT INTO `sys_menu` VALUES (144, 'notice_delete', 'notice', '[0],[system],[notice],', '删除通知', NULL, '/notice/delete', 3, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('148', 'code', '0', '[0],', '代码生成', 'fa-code', '/code', '3', '1', '1', null, '1', null); INSERT INTO `sys_menu` VALUES (145, 'hello', '0', '[0],', '通知', 'fa-rocket', '/notice/hello', 1, 1, 1, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('149', 'api_mgr', '0', '[0],', '接口文档', 'fa-leaf', '/swagger-ui.html', '2', '1', '1', null, '1', null); INSERT INTO `sys_menu` VALUES (149, 'api_mgr', '0', '[0],', '接口文档', 'fa-leaf', '/swagger-ui.html', 2, 1, 1, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('150', 'to_menu_edit', 'menu', '[0],[system],[menu],', '菜单编辑跳转', '', '/menu/menu_edit', '4', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (150, 'to_menu_edit', 'menu', '[0],[system],[menu],', '菜单编辑跳转', '', '/menu/menu_edit', 4, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('151', 'menu_list', 'menu', '[0],[system],[menu],', '菜单列表', '', '/menu/list', '5', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (151, 'menu_list', 'menu', '[0],[system],[menu],', '菜单列表', '', '/menu/list', 5, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('152', 'to_dept_update', 'dept', '[0],[system],[dept],', '修改部门跳转', '', '/dept/dept_update', '4', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (152, 'to_dept_update', 'dept', '[0],[system],[dept],', '修改部门跳转', '', '/dept/dept_update', 4, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('153', 'dept_list', 'dept', '[0],[system],[dept],', '部门列表', '', '/dept/list', '5', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (153, 'dept_list', 'dept', '[0],[system],[dept],', '部门列表', '', '/dept/list', 5, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('154', 'dept_detail', 'dept', '[0],[system],[dept],', '部门详情', '', '/dept/detail', '6', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (154, 'dept_detail', 'dept', '[0],[system],[dept],', '部门详情', '', '/dept/detail', 6, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('155', 'to_dict_edit', 'dict', '[0],[system],[dict],', '修改菜单跳转', '', '/dict/dict_edit', '4', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (155, 'to_dict_edit', 'dict', '[0],[system],[dict],', '修改菜单跳转', '', '/dict/dict_edit', 4, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('156', 'dict_list', 'dict', '[0],[system],[dict],', '字典列表', '', '/dict/list', '5', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (156, 'dict_list', 'dict', '[0],[system],[dict],', '字典列表', '', '/dict/list', 5, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('157', 'dict_detail', 'dict', '[0],[system],[dict],', '字典详情', '', '/dict/detail', '6', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (157, 'dict_detail', 'dict', '[0],[system],[dict],', '字典详情', '', '/dict/detail', 6, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('158', 'log_list', 'log', '[0],[system],[log],', '日志列表', '', '/log/list', '2', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (158, 'log_list', 'log', '[0],[system],[log],', '日志列表', '', '/log/list', 2, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('159', 'log_detail', 'log', '[0],[system],[log],', '日志详情', '', '/log/detail', '3', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (159, 'log_detail', 'log', '[0],[system],[log],', '日志详情', '', '/log/detail', 3, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('160', 'del_login_log', 'loginLog', '[0],[system],[loginLog],', '清空登录日志', '', '/loginLog/delLoginLog', '1', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (160, 'del_login_log', 'loginLog', '[0],[system],[loginLog],', '清空登录日志', '', '/loginLog/delLoginLog', 1, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('161', 'login_log_list', 'loginLog', '[0],[system],[loginLog],', '登录日志列表', '', '/loginLog/list', '2', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (161, 'login_log_list', 'loginLog', '[0],[system],[loginLog],', '登录日志列表', '', '/loginLog/list', 2, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('162', 'to_role_edit', 'role', '[0],[system],[role],', '修改角色跳转', '', '/role/role_edit', '5', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (162, 'to_role_edit', 'role', '[0],[system],[role],', '修改角色跳转', '', '/role/role_edit', 5, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('163', 'to_role_assign', 'role', '[0],[system],[role],', '角色分配跳转', '', '/role/role_assign', '6', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (163, 'to_role_assign', 'role', '[0],[system],[role],', '角色分配跳转', '', '/role/role_assign', 6, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('164', 'role_list', 'role', '[0],[system],[role],', '角色列表', '', '/role/list', '7', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (164, 'role_list', 'role', '[0],[system],[role],', '角色列表', '', '/role/list', 7, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('165', 'to_assign_role', 'mgr', '[0],[system],[mgr],', '分配角色跳转', '', '/mgr/role_assign', '8', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (165, 'to_assign_role', 'mgr', '[0],[system],[mgr],', '分配角色跳转', '', '/mgr/role_assign', 8, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('166', 'to_user_edit', 'mgr', '[0],[system],[mgr],', '编辑用户跳转', '', '/mgr/user_edit', '9', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (166, 'to_user_edit', 'mgr', '[0],[system],[mgr],', '编辑用户跳转', '', '/mgr/user_edit', 9, 3, 0, NULL, 1, NULL);
INSERT INTO `sys_menu` VALUES ('167', 'mgr_list', 'mgr', '[0],[system],[mgr],', '用户列表', '', '/mgr/list', '10', '3', '0', null, '1', null); INSERT INTO `sys_menu` VALUES (167, 'mgr_list', 'mgr', '[0],[system],[mgr],', '用户列表', '', '/mgr/list', 10, 3, 0, NULL, 1, NULL);
COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_notice -- Table structure for sys_notice
...@@ -207,8 +206,10 @@ CREATE TABLE `sys_notice` ( ...@@ -207,8 +206,10 @@ CREATE TABLE `sys_notice` (
-- ---------------------------- -- ----------------------------
-- Records of sys_notice -- Records of sys_notice
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_notice` VALUES ('6', '世界', '10', '欢迎使用Guns管理系统', '2017-01-11 08:53:20', '1'); BEGIN;
INSERT INTO `sys_notice` VALUES ('8', '你好', null, '你好', '2017-05-10 19:28:57', '1'); INSERT INTO `sys_notice` VALUES (6, '世界', 10, '欢迎使用Guns管理系统', '2017-01-11 08:53:20', 1);
INSERT INTO `sys_notice` VALUES (8, '你好', NULL, '你好', '2017-05-10 19:28:57', 1);
COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_operation_log -- Table structure for sys_operation_log
...@@ -225,11 +226,7 @@ CREATE TABLE `sys_operation_log` ( ...@@ -225,11 +226,7 @@ CREATE TABLE `sys_operation_log` (
`succeed` varchar(255) DEFAULT NULL COMMENT '是否成功', `succeed` varchar(255) DEFAULT NULL COMMENT '是否成功',
`message` text COMMENT '备注', `message` text COMMENT '备注',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=554 DEFAULT CHARSET=utf8 COMMENT='操作日志'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='操作日志';
-- ----------------------------
-- Records of sys_operation_log
-- ----------------------------
-- ---------------------------- -- ----------------------------
-- Table structure for sys_relation -- Table structure for sys_relation
...@@ -245,81 +242,82 @@ CREATE TABLE `sys_relation` ( ...@@ -245,81 +242,82 @@ CREATE TABLE `sys_relation` (
-- ---------------------------- -- ----------------------------
-- Records of sys_relation -- Records of sys_relation
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_relation` VALUES ('3377', '105', '5'); BEGIN;
INSERT INTO `sys_relation` VALUES ('3378', '106', '5'); INSERT INTO `sys_relation` VALUES (3377, 105, 5);
INSERT INTO `sys_relation` VALUES ('3379', '107', '5'); INSERT INTO `sys_relation` VALUES (3378, 106, 5);
INSERT INTO `sys_relation` VALUES ('3380', '108', '5'); INSERT INTO `sys_relation` VALUES (3379, 107, 5);
INSERT INTO `sys_relation` VALUES ('3381', '109', '5'); INSERT INTO `sys_relation` VALUES (3380, 108, 5);
INSERT INTO `sys_relation` VALUES ('3382', '110', '5'); INSERT INTO `sys_relation` VALUES (3381, 109, 5);
INSERT INTO `sys_relation` VALUES ('3383', '111', '5'); INSERT INTO `sys_relation` VALUES (3382, 110, 5);
INSERT INTO `sys_relation` VALUES ('3384', '112', '5'); INSERT INTO `sys_relation` VALUES (3383, 111, 5);
INSERT INTO `sys_relation` VALUES ('3385', '113', '5'); INSERT INTO `sys_relation` VALUES (3384, 112, 5);
INSERT INTO `sys_relation` VALUES ('3386', '114', '5'); INSERT INTO `sys_relation` VALUES (3385, 113, 5);
INSERT INTO `sys_relation` VALUES ('3387', '115', '5'); INSERT INTO `sys_relation` VALUES (3386, 114, 5);
INSERT INTO `sys_relation` VALUES ('3388', '116', '5'); INSERT INTO `sys_relation` VALUES (3387, 115, 5);
INSERT INTO `sys_relation` VALUES ('3389', '117', '5'); INSERT INTO `sys_relation` VALUES (3388, 116, 5);
INSERT INTO `sys_relation` VALUES ('3390', '118', '5'); INSERT INTO `sys_relation` VALUES (3389, 117, 5);
INSERT INTO `sys_relation` VALUES ('3391', '119', '5'); INSERT INTO `sys_relation` VALUES (3390, 118, 5);
INSERT INTO `sys_relation` VALUES ('3392', '120', '5'); INSERT INTO `sys_relation` VALUES (3391, 119, 5);
INSERT INTO `sys_relation` VALUES ('3393', '121', '5'); INSERT INTO `sys_relation` VALUES (3392, 120, 5);
INSERT INTO `sys_relation` VALUES ('3394', '122', '5'); INSERT INTO `sys_relation` VALUES (3393, 121, 5);
INSERT INTO `sys_relation` VALUES ('3395', '150', '5'); INSERT INTO `sys_relation` VALUES (3394, 122, 5);
INSERT INTO `sys_relation` VALUES ('3396', '151', '5'); INSERT INTO `sys_relation` VALUES (3395, 150, 5);
INSERT INTO `sys_relation` VALUES ('3737', '105', '1'); INSERT INTO `sys_relation` VALUES (3396, 151, 5);
INSERT INTO `sys_relation` VALUES ('3738', '106', '1'); INSERT INTO `sys_relation` VALUES (3737, 105, 1);
INSERT INTO `sys_relation` VALUES ('3739', '107', '1'); INSERT INTO `sys_relation` VALUES (3738, 106, 1);
INSERT INTO `sys_relation` VALUES ('3740', '108', '1'); INSERT INTO `sys_relation` VALUES (3739, 107, 1);
INSERT INTO `sys_relation` VALUES ('3741', '109', '1'); INSERT INTO `sys_relation` VALUES (3740, 108, 1);
INSERT INTO `sys_relation` VALUES ('3742', '110', '1'); INSERT INTO `sys_relation` VALUES (3741, 109, 1);
INSERT INTO `sys_relation` VALUES ('3743', '111', '1'); INSERT INTO `sys_relation` VALUES (3742, 110, 1);
INSERT INTO `sys_relation` VALUES ('3744', '112', '1'); INSERT INTO `sys_relation` VALUES (3743, 111, 1);
INSERT INTO `sys_relation` VALUES ('3745', '113', '1'); INSERT INTO `sys_relation` VALUES (3744, 112, 1);
INSERT INTO `sys_relation` VALUES ('3746', '165', '1'); INSERT INTO `sys_relation` VALUES (3745, 113, 1);
INSERT INTO `sys_relation` VALUES ('3747', '166', '1'); INSERT INTO `sys_relation` VALUES (3746, 165, 1);
INSERT INTO `sys_relation` VALUES ('3748', '167', '1'); INSERT INTO `sys_relation` VALUES (3747, 166, 1);
INSERT INTO `sys_relation` VALUES ('3749', '114', '1'); INSERT INTO `sys_relation` VALUES (3748, 167, 1);
INSERT INTO `sys_relation` VALUES ('3750', '115', '1'); INSERT INTO `sys_relation` VALUES (3749, 114, 1);
INSERT INTO `sys_relation` VALUES ('3751', '116', '1'); INSERT INTO `sys_relation` VALUES (3750, 115, 1);
INSERT INTO `sys_relation` VALUES ('3752', '117', '1'); INSERT INTO `sys_relation` VALUES (3751, 116, 1);
INSERT INTO `sys_relation` VALUES ('3753', '118', '1'); INSERT INTO `sys_relation` VALUES (3752, 117, 1);
INSERT INTO `sys_relation` VALUES ('3754', '162', '1'); INSERT INTO `sys_relation` VALUES (3753, 118, 1);
INSERT INTO `sys_relation` VALUES ('3755', '163', '1'); INSERT INTO `sys_relation` VALUES (3754, 162, 1);
INSERT INTO `sys_relation` VALUES ('3756', '164', '1'); INSERT INTO `sys_relation` VALUES (3755, 163, 1);
INSERT INTO `sys_relation` VALUES ('3757', '119', '1'); INSERT INTO `sys_relation` VALUES (3756, 164, 1);
INSERT INTO `sys_relation` VALUES ('3758', '120', '1'); INSERT INTO `sys_relation` VALUES (3757, 119, 1);
INSERT INTO `sys_relation` VALUES ('3759', '121', '1'); INSERT INTO `sys_relation` VALUES (3758, 120, 1);
INSERT INTO `sys_relation` VALUES ('3760', '122', '1'); INSERT INTO `sys_relation` VALUES (3759, 121, 1);
INSERT INTO `sys_relation` VALUES ('3761', '150', '1'); INSERT INTO `sys_relation` VALUES (3760, 122, 1);
INSERT INTO `sys_relation` VALUES ('3762', '151', '1'); INSERT INTO `sys_relation` VALUES (3761, 150, 1);
INSERT INTO `sys_relation` VALUES ('3763', '128', '1'); INSERT INTO `sys_relation` VALUES (3762, 151, 1);
INSERT INTO `sys_relation` VALUES ('3764', '134', '1'); INSERT INTO `sys_relation` VALUES (3763, 128, 1);
INSERT INTO `sys_relation` VALUES ('3765', '158', '1'); INSERT INTO `sys_relation` VALUES (3764, 134, 1);
INSERT INTO `sys_relation` VALUES ('3766', '159', '1'); INSERT INTO `sys_relation` VALUES (3765, 158, 1);
INSERT INTO `sys_relation` VALUES ('3767', '130', '1'); INSERT INTO `sys_relation` VALUES (3766, 159, 1);
INSERT INTO `sys_relation` VALUES ('3768', '131', '1'); INSERT INTO `sys_relation` VALUES (3767, 130, 1);
INSERT INTO `sys_relation` VALUES ('3769', '135', '1'); INSERT INTO `sys_relation` VALUES (3768, 131, 1);
INSERT INTO `sys_relation` VALUES ('3770', '136', '1'); INSERT INTO `sys_relation` VALUES (3769, 135, 1);
INSERT INTO `sys_relation` VALUES ('3771', '137', '1'); INSERT INTO `sys_relation` VALUES (3770, 136, 1);
INSERT INTO `sys_relation` VALUES ('3772', '152', '1'); INSERT INTO `sys_relation` VALUES (3771, 137, 1);
INSERT INTO `sys_relation` VALUES ('3773', '153', '1'); INSERT INTO `sys_relation` VALUES (3772, 152, 1);
INSERT INTO `sys_relation` VALUES ('3774', '154', '1'); INSERT INTO `sys_relation` VALUES (3773, 153, 1);
INSERT INTO `sys_relation` VALUES ('3775', '132', '1'); INSERT INTO `sys_relation` VALUES (3774, 154, 1);
INSERT INTO `sys_relation` VALUES ('3776', '138', '1'); INSERT INTO `sys_relation` VALUES (3775, 132, 1);
INSERT INTO `sys_relation` VALUES ('3777', '139', '1'); INSERT INTO `sys_relation` VALUES (3776, 138, 1);
INSERT INTO `sys_relation` VALUES ('3778', '140', '1'); INSERT INTO `sys_relation` VALUES (3777, 139, 1);
INSERT INTO `sys_relation` VALUES ('3779', '155', '1'); INSERT INTO `sys_relation` VALUES (3778, 140, 1);
INSERT INTO `sys_relation` VALUES ('3780', '156', '1'); INSERT INTO `sys_relation` VALUES (3779, 155, 1);
INSERT INTO `sys_relation` VALUES ('3781', '157', '1'); INSERT INTO `sys_relation` VALUES (3780, 156, 1);
INSERT INTO `sys_relation` VALUES ('3782', '133', '1'); INSERT INTO `sys_relation` VALUES (3781, 157, 1);
INSERT INTO `sys_relation` VALUES ('3783', '160', '1'); INSERT INTO `sys_relation` VALUES (3782, 133, 1);
INSERT INTO `sys_relation` VALUES ('3784', '161', '1'); INSERT INTO `sys_relation` VALUES (3783, 160, 1);
INSERT INTO `sys_relation` VALUES ('3785', '141', '1'); INSERT INTO `sys_relation` VALUES (3784, 161, 1);
INSERT INTO `sys_relation` VALUES ('3786', '142', '1'); INSERT INTO `sys_relation` VALUES (3785, 141, 1);
INSERT INTO `sys_relation` VALUES ('3787', '143', '1'); INSERT INTO `sys_relation` VALUES (3786, 142, 1);
INSERT INTO `sys_relation` VALUES ('3788', '144', '1'); INSERT INTO `sys_relation` VALUES (3787, 143, 1);
INSERT INTO `sys_relation` VALUES ('3789', '145', '1'); INSERT INTO `sys_relation` VALUES (3788, 144, 1);
INSERT INTO `sys_relation` VALUES ('3790', '148', '1'); INSERT INTO `sys_relation` VALUES (3789, 145, 1);
INSERT INTO `sys_relation` VALUES ('3791', '149', '1'); INSERT INTO `sys_relation` VALUES (3791, 149, 1);
COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_role -- Table structure for sys_role
...@@ -339,8 +337,10 @@ CREATE TABLE `sys_role` ( ...@@ -339,8 +337,10 @@ CREATE TABLE `sys_role` (
-- ---------------------------- -- ----------------------------
-- Records of sys_role -- Records of sys_role
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_role` VALUES ('1', '1', '0', '超级管理员', '24', 'administrator', '1'); BEGIN;
INSERT INTO `sys_role` VALUES ('5', '2', '1', '临时', '26', 'temp', null); INSERT INTO `sys_role` VALUES (1, 1, 0, '超级管理员', 24, 'administrator', 1);
INSERT INTO `sys_role` VALUES (5, 2, 1, '临时', 26, 'temp', NULL);
COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_user -- Table structure for sys_user
...@@ -368,12 +368,16 @@ CREATE TABLE `sys_user` ( ...@@ -368,12 +368,16 @@ CREATE TABLE `sys_user` (
-- ---------------------------- -- ----------------------------
-- Records of sys_user -- Records of sys_user
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_user` VALUES ('1', 'girl.gif', 'admin', 'ecfadcde9305f8891bcfe5a1e28c253e', '8pgby', '张三', '2017-05-05 00:00:00', '2', 'sn93@qq.com', '18200000000', '1', '27', '1', '2016-01-29 08:49:53', '25'); BEGIN;
INSERT INTO `sys_user` VALUES ('44', null, 'test', '45abb7879f6a8268f1ef600e6038ac73', 'ssts3', 'test', '2017-05-01 00:00:00', '1', 'abc@123.com', '', '5', '26', '3', '2017-05-16 20:33:37', null); INSERT INTO `sys_user` VALUES (1, 'girl.gif', 'admin', 'ecfadcde9305f8891bcfe5a1e28c253e', '8pgby', '张三', '2017-05-05 00:00:00', 2, 'sn93@qq.com', '18200000000', '1', 27, 1, '2016-01-29 08:49:53', 25);
INSERT INTO `sys_user` VALUES ('45', null, 'boss', '71887a5ad666a18f709e1d4e693d5a35', '1f7bf', '老板', '2017-12-04 00:00:00', '1', '', '', '1', '24', '1', '2017-12-04 22:24:02', null); INSERT INTO `sys_user` VALUES (44, NULL, 'test', '45abb7879f6a8268f1ef600e6038ac73', 'ssts3', 'test', '2017-05-01 00:00:00', 1, 'abc@123.com', '', '5', 26, 3, '2017-05-16 20:33:37', NULL);
INSERT INTO `sys_user` VALUES ('46', null, 'manager', 'b53cac62e7175637d4beb3b16b2f7915', 'j3cs9', '经理', '2017-12-04 00:00:00', '1', '', '', '1', '24', '1', '2017-12-04 22:24:24', null); INSERT INTO `sys_user` VALUES (45, NULL, 'boss', '71887a5ad666a18f709e1d4e693d5a35', '1f7bf', '老板', '2017-12-04 00:00:00', 1, '', '', '1', 24, 1, '2017-12-04 22:24:02', NULL);
INSERT INTO `sys_user` VALUES (46, NULL, 'manager', 'b53cac62e7175637d4beb3b16b2f7915', 'j3cs9', '经理', '2017-12-04 00:00:00', 1, '', '', '1', 24, 1, '2017-12-04 22:24:24', NULL);
COMMIT;
-- ----------------------------
-- Table structure for test
-- ----------------------------
DROP TABLE IF EXISTS `test`; DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` ( CREATE TABLE `test` (
`aaa` int(11) NOT NULL AUTO_INCREMENT, `aaa` int(11) NOT NULL AUTO_INCREMENT,
...@@ -381,4 +385,4 @@ CREATE TABLE `test` ( ...@@ -381,4 +385,4 @@ CREATE TABLE `test` (
PRIMARY KEY (`aaa`) USING BTREE PRIMARY KEY (`aaa`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;
\ No newline at end of file
package com.stylefeng.guns.modular.code.controller;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.config.properties.DruidProperties;
import com.stylefeng.guns.generator.action.config.WebGeneratorConfig;
import com.stylefeng.guns.generator.action.model.GenQo;
import com.stylefeng.guns.modular.code.factory.DefaultTemplateFactory;
import com.stylefeng.guns.modular.code.service.TableService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 代码生成控制器
*
* @author fengshuonan
* @Date 2017年11月30日16:39:19
*/
@Controller
@RequestMapping("/code")
public class CodeController extends BaseController {
private static String PREFIX = "/code";
@Autowired
private TableService tableService;
@Autowired
private DruidProperties druidProperties;
/**
* 跳转到代码生成主页
*/
@RequestMapping("")
public String blackboard(Model model) {
model.addAttribute("tables", tableService.getAllTables());
model.addAttribute("params", DefaultTemplateFactory.getDefaultParams());
model.addAttribute("templates", DefaultTemplateFactory.getDefaultTemplates());
return PREFIX + "/code.html";
}
/**
* 生成代码
*/
@ApiOperation("生成代码")
@RequestMapping(value = "/generate", method = RequestMethod.POST)
@ResponseBody
public Object generate(GenQo genQo) {
genQo.setUrl(druidProperties.getUrl());
genQo.setUserName(druidProperties.getUsername());
genQo.setPassword(druidProperties.getPassword());
WebGeneratorConfig webGeneratorConfig = new WebGeneratorConfig(genQo);
webGeneratorConfig.doMpGeneration();
webGeneratorConfig.doGunsGeneration();
return SUCCESS_TIP;
}
}
package com.stylefeng.guns.modular.code.factory;
import com.stylefeng.guns.GunsApplication;
import com.stylefeng.guns.core.CoreFlag;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.generator.action.model.GenQo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 模板种类构建器
*
* @author fengshuonan
* @date 2017-12-04-下午2:59
*/
public class DefaultTemplateFactory {
/**
* 获取所有的模板种类
*/
public static List<Map<String,Object>> getDefaultTemplates(){
ArrayList<Map<String, Object>> templates = new ArrayList<>();
templates.add(create("controllerSwitch","controller-控制器模板"));
templates.add(create("entitySwitch","entity-实体模板"));
templates.add(create("serviceSwitch","service-service模板"));
templates.add(create("daoSwitch","dao-dao模板"));
templates.add(create("indexPageSwitch","indexPage-首页模板"));
templates.add(create("addPageSwitch","addPage-添加页面模板"));
templates.add(create("editPageSwitch","editPage-编辑页面模板"));
templates.add(create("jsSwitch","indexJs-主页js模板"));
templates.add(create("infoJsSwitch","infoJs-详情页js模板"));
templates.add(create("sqlSwitch","sql-sql语句模板"));
return templates;
}
/**
* 获取默认的参数
*/
public static GenQo getDefaultParams(){
GenQo genQo = new GenQo();
genQo.setProjectPath(ToolUtil.getWebRootPath(null));
genQo.setAuthor("stylefeng");
genQo.setProjectPackage(GunsApplication.class.getPackage().getName());
genQo.setCorePackage(CoreFlag.class.getPackage().getName());
genQo.setIgnoreTabelPrefix("sys_");
genQo.setModuleName("system");
genQo.setParentMenuName("系统管理");
return genQo;
}
private static Map<String,Object> create(String key,String desc){
HashMap<String, Object> template = new HashMap<>();
template.put("key",key);
template.put("desc",desc);
return template;
}
}
package com.stylefeng.guns.modular.code.service;
import com.baomidou.mybatisplus.mapper.SqlRunner;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 获取数据库所有的表
*
* @author fengshuonan
* @date 2017-12-04-下午1:37
*/
@Service
public class TableService {
@Value("${spring.datasource.db-name}")
private String dbName;
/**
* 获取当前数据库所有的表信息
*/
public List<Map<String, Object>> getAllTables() {
String sql = "select TABLE_NAME as tableName,TABLE_COMMENT as tableComment from information_schema.`TABLES` where TABLE_SCHEMA = '" + dbName + "'";
return SqlRunner.db().selectList(sql);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>guns-generator</artifactId>
<packaging>jar</packaging>
<name>guns-generator</name>
<description>代码生成器</description>
<parent>
<groupId>com.stylefeng</groupId>
<artifactId>guns-parent</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.stylefeng</groupId>
<artifactId>guns-core</artifactId>
</dependency>
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetl</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generate</artifactId>
</dependency>
</dependencies>
</project>
package com.stylefeng.guns.generator.action;
import com.stylefeng.guns.generator.action.config.GunsGeneratorConfig;
/**
* 代码生成器,可以生成实体,dao,service,controller,html,js
*
* @author stylefeng
* @Date 2017/5/21 12:38
*/
public class GunsCodeGenerator {
public static void main(String[] args) {
/**
* Mybatis-Plus的代码生成器:
* mp的代码生成器可以生成实体,mapper,mapper对应的xml,service
*/
GunsGeneratorConfig gunsGeneratorConfig = new GunsGeneratorConfig();
gunsGeneratorConfig.doMpGeneration();
/**
* guns的生成器:
* guns的代码生成器可以生成controller,html页面,页面对应的js
*/
gunsGeneratorConfig.doGunsGeneration();
}
}
\ No newline at end of file
package com.stylefeng.guns.generator.action.config;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.stylefeng.guns.core.util.FileUtil;
import com.stylefeng.guns.generator.engine.SimpleTemplateEngine;
import com.stylefeng.guns.generator.engine.base.GunsTemplateEngine;
import com.stylefeng.guns.generator.engine.config.ContextConfig;
import com.stylefeng.guns.generator.engine.config.SqlConfig;
import java.io.File;
import java.util.List;
/**
* 代码生成的抽象配置
*
* @author fengshuonan
* @date 2017-10-28-下午8:22
*/
public abstract class AbstractGeneratorConfig {
/**
* mybatis-plus代码生成器配置
*/
GlobalConfig globalConfig = new GlobalConfig();
DataSourceConfig dataSourceConfig = new DataSourceConfig();
StrategyConfig strategyConfig = new StrategyConfig();
PackageConfig packageConfig = new PackageConfig();
TableInfo tableInfo = null;
/**
* Guns代码生成器配置
*/
ContextConfig contextConfig = new ContextConfig();
SqlConfig sqlConfig = new SqlConfig();
protected abstract void config();
public void init() {
config();
packageConfig.setService(contextConfig.getProPackage() + ".modular." + contextConfig.getModuleName() + ".service");
packageConfig.setServiceImpl(contextConfig.getProPackage() + ".modular." + contextConfig.getModuleName() + ".service.impl");
//controller没用掉,生成之后会自动删掉
packageConfig.setController("TTT");
if (!contextConfig.getEntitySwitch()) {
packageConfig.setEntity("TTT");
}
if (!contextConfig.getDaoSwitch()) {
packageConfig.setMapper("TTT");
packageConfig.setXml("TTT");
}
if (!contextConfig.getServiceSwitch()) {
packageConfig.setService("TTT");
packageConfig.setServiceImpl("TTT");
}
}
/**
* 删除不必要的代码
*/
public void destory() {
String outputDir = globalConfig.getOutputDir() + "/TTT";
FileUtil.deleteDir(new File(outputDir));
}
public AbstractGeneratorConfig() {
}
public void doMpGeneration() {
init();
AutoGenerator autoGenerator = new AutoGenerator();
autoGenerator.setGlobalConfig(globalConfig);
autoGenerator.setDataSource(dataSourceConfig);
autoGenerator.setStrategy(strategyConfig);
autoGenerator.setPackageInfo(packageConfig);
autoGenerator.execute();
destory();
//获取table信息,用于guns代码生成
List<TableInfo> tableInfoList = autoGenerator.getConfig().getTableInfoList();
if (tableInfoList != null && tableInfoList.size() > 0) {
this.tableInfo = tableInfoList.get(0);
}
}
public void doGunsGeneration() {
GunsTemplateEngine GunsTemplateEngine = new SimpleTemplateEngine();
GunsTemplateEngine.setContextConfig(contextConfig);
sqlConfig.setConnection(dataSourceConfig.getConn());
GunsTemplateEngine.setSqlConfig(sqlConfig);
GunsTemplateEngine.setTableInfo(tableInfo);
GunsTemplateEngine.start();
}
}
package com.stylefeng.guns.generator.action.config;
import com.baomidou.mybatisplus.generator.config.rules.DbType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
/**
* 默认的代码生成的配置
*
* @author fengshuonan
* @date 2017-10-28-下午8:27
*/
public class GunsGeneratorConfig extends AbstractGeneratorConfig {
protected void globalConfig() {
globalConfig.setOutputDir("D:\\ttt");//写自己项目的绝对路径,注意具体到java目录
globalConfig.setFileOverride(true);
globalConfig.setEnableCache(false);
globalConfig.setBaseResultMap(true);
globalConfig.setBaseColumnList(true);
globalConfig.setOpen(false);
globalConfig.setAuthor("stylefeng");
}
protected void dataSourceConfig() {
dataSourceConfig.setDbType(DbType.MYSQL);
dataSourceConfig.setDriverName("com.mysql.jdbc.Driver");
dataSourceConfig.setUsername("root");
dataSourceConfig.setPassword("root");
dataSourceConfig.setUrl("jdbc:mysql://127.0.0.1:3306/guns?characterEncoding=utf8");
}
protected void strategyConfig() {
strategyConfig.setTablePrefix(new String[]{"sys_"});// 此处可以修改为您的表前缀
strategyConfig.setNaming(NamingStrategy.underline_to_camel);
}
protected void packageConfig() {
packageConfig.setParent(null);
packageConfig.setEntity("com.stylefeng.guns.admin.common.persistence.model");
packageConfig.setMapper("com.stylefeng.guns.admin.common.persistence.dao");
packageConfig.setXml("com.stylefeng.guns.admin.common.persistence.dao.mapping");
}
protected void contextConfig() {
contextConfig.setProPackage("com.stylefeng.guns.admin");
contextConfig.setCoreBasePackage("com.stylefeng.guns.core");
contextConfig.setBizChName("字典管理");
contextConfig.setBizEnName("sysDict");
contextConfig.setModuleName("system");
contextConfig.setProjectPath("D:\\ideaSpace\\guns\\guns-admin");//写自己项目的绝对路径
contextConfig.setEntityName("SysDict");
sqlConfig.setParentMenuName(null);//这里写已有菜单的名称,当做父节点
/**
* mybatis-plus 生成器开关
*/
contextConfig.setEntitySwitch(true);
contextConfig.setDaoSwitch(true);
contextConfig.setServiceSwitch(true);
/**
* guns 生成器开关
*/
contextConfig.setControllerSwitch(true);
contextConfig.setIndexPageSwitch(true);
contextConfig.setAddPageSwitch(true);
contextConfig.setEditPageSwitch(true);
contextConfig.setJsSwitch(true);
contextConfig.setInfoJsSwitch(true);
contextConfig.setSqlSwitch(true);
}
@Override
protected void config() {
globalConfig();
dataSourceConfig();
strategyConfig();
packageConfig();
contextConfig();
}
}
package com.stylefeng.guns.generator.action.config;
import com.baomidou.mybatisplus.generator.config.rules.DbType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.stylefeng.guns.core.support.StrKit;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.generator.action.model.GenQo;
import java.io.File;
/**
* 默认的代码生成的配置
*
* @author fengshuonan
* @date 2017-10-28-下午8:27
*/
public class WebGeneratorConfig extends AbstractGeneratorConfig {
private GenQo genQo;
public WebGeneratorConfig(GenQo genQo) {
this.genQo = genQo;
}
@Override
protected void config() {
/**
* 数据库配置
*/
dataSourceConfig.setDbType(DbType.MYSQL);
dataSourceConfig.setDriverName("com.mysql.cj.jdbc.Driver");
dataSourceConfig.setUsername(genQo.getUserName());
dataSourceConfig.setPassword(genQo.getPassword());
dataSourceConfig.setUrl(genQo.getUrl());
/**
* 全局配置
*/
globalConfig.setOutputDir(genQo.getProjectPath() + File.separator + "src" + File.separator + "main" + File.separator + "java");
globalConfig.setFileOverride(true);
globalConfig.setEnableCache(false);
globalConfig.setBaseResultMap(true);
globalConfig.setBaseColumnList(true);
globalConfig.setOpen(false);
globalConfig.setAuthor(genQo.getAuthor());
contextConfig.setProPackage(genQo.getProjectPackage());
contextConfig.setCoreBasePackage(genQo.getCorePackage());
/**
* 生成策略
*/
if (genQo.getIgnoreTabelPrefix() != null) {
strategyConfig.setTablePrefix(new String[]{genQo.getIgnoreTabelPrefix()});
}
strategyConfig.setInclude(new String[]{genQo.getTableName()});
strategyConfig.setNaming(NamingStrategy.underline_to_camel);
packageConfig.setParent(null);
packageConfig.setEntity(genQo.getProjectPackage() + ".modular.system.model");
packageConfig.setMapper(genQo.getProjectPackage() + ".modular.system.dao");
packageConfig.setXml(genQo.getProjectPackage() + ".modular.system.dao.mapping");
/**
* 业务代码配置
*/
contextConfig.setBizChName(genQo.getBizName());
contextConfig.setModuleName(genQo.getModuleName());
contextConfig.setProjectPath(genQo.getProjectPath());//写自己项目的绝对路径
if(ToolUtil.isEmpty(genQo.getIgnoreTabelPrefix())){
String entityName = StrKit.toCamelCase(genQo.getTableName());
contextConfig.setEntityName(StrKit.firstCharToUpperCase(entityName));
contextConfig.setBizEnName(StrKit.firstCharToLowerCase(entityName));
}else{
String entiyName = StrKit.toCamelCase(StrKit.removePrefix(genQo.getTableName(), genQo.getIgnoreTabelPrefix()));
contextConfig.setEntityName(StrKit.firstCharToUpperCase(entiyName));
contextConfig.setBizEnName(StrKit.firstCharToLowerCase(entiyName));
}
sqlConfig.setParentMenuName(genQo.getParentMenuName());//这里写已有菜单的名称,当做父节点
/**
* mybatis-plus 生成器开关
*/
contextConfig.setEntitySwitch(genQo.getEntitySwitch());
contextConfig.setDaoSwitch(genQo.getDaoSwitch());
contextConfig.setServiceSwitch(genQo.getServiceSwitch());
/**
* guns 生成器开关
*/
contextConfig.setControllerSwitch(genQo.getControllerSwitch());
contextConfig.setIndexPageSwitch(genQo.getIndexPageSwitch());
contextConfig.setAddPageSwitch(genQo.getAddPageSwitch());
contextConfig.setEditPageSwitch(genQo.getEditPageSwitch());
contextConfig.setJsSwitch(genQo.getJsSwitch());
contextConfig.setInfoJsSwitch(genQo.getInfoJsSwitch());
contextConfig.setSqlSwitch(genQo.getSqlSwitch());
}
}
package com.stylefeng.guns.generator.action.model;
/**
* 代码生成的查询参数
*
* @author fengshuonan
* @date 2017-11-30-下午2:05
*/
public class GenQo {
/**
* 数据库账号
*/
private String userName;
/**
* 数据库密码
*/
private String password;
/**
* 数据库url
*/
private String url;
/**
* 项目地址
*/
private String projectPath;
/**
* 作者
*/
private String author;
/**
* 项目的包
*/
private String projectPackage;
/**
* 核心模块的包
*/
private String corePackage;
/**
* 表名称
*/
private String tableName;
/**
* 忽略的表前缀
*/
private String ignoreTabelPrefix;
/**
* 业务名称
*/
private String bizName;
/**
* 模块名
*/
private String moduleName;
/**
* 父级菜单名称
*/
private String parentMenuName;
/**
* 是否生成控制器代码开关
*/
private Boolean controllerSwitch = false;
/**
* 主页
*/
private Boolean indexPageSwitch = false;
/**
* 添加页面
*/
private Boolean addPageSwitch = false;
/**
* 编辑页面
*/
private Boolean editPageSwitch = false;
/**
* 主页的js
*/
private Boolean jsSwitch = false;
/**
* 详情页面js
*/
private Boolean infoJsSwitch = false;
/**
* dao的开关
*/
private Boolean daoSwitch = false;
/**
* service
*/
private Boolean serviceSwitch = false;
/**
* 生成实体的开关
*/
private Boolean entitySwitch = false;
/**
* 生成sql的开关
*/
private Boolean sqlSwitch = false;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getProjectPath() {
return projectPath;
}
public void setProjectPath(String projectPath) {
this.projectPath = projectPath;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getCorePackage() {
return corePackage;
}
public void setCorePackage(String corePackage) {
this.corePackage = corePackage;
}
public String getProjectPackage() {
return projectPackage;
}
public void setProjectPackage(String projectPackage) {
this.projectPackage = projectPackage;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getIgnoreTabelPrefix() {
return ignoreTabelPrefix;
}
public void setIgnoreTabelPrefix(String ignoreTabelPrefix) {
this.ignoreTabelPrefix = ignoreTabelPrefix;
}
public String getBizName() {
return bizName;
}
public void setBizName(String bizName) {
this.bizName = bizName;
}
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
public Boolean getControllerSwitch() {
return controllerSwitch;
}
public void setControllerSwitch(Boolean controllerSwitch) {
this.controllerSwitch = controllerSwitch;
}
public Boolean getIndexPageSwitch() {
return indexPageSwitch;
}
public void setIndexPageSwitch(Boolean indexPageSwitch) {
this.indexPageSwitch = indexPageSwitch;
}
public Boolean getAddPageSwitch() {
return addPageSwitch;
}
public void setAddPageSwitch(Boolean addPageSwitch) {
this.addPageSwitch = addPageSwitch;
}
public Boolean getEditPageSwitch() {
return editPageSwitch;
}
public void setEditPageSwitch(Boolean editPageSwitch) {
this.editPageSwitch = editPageSwitch;
}
public Boolean getJsSwitch() {
return jsSwitch;
}
public void setJsSwitch(Boolean jsSwitch) {
this.jsSwitch = jsSwitch;
}
public Boolean getInfoJsSwitch() {
return infoJsSwitch;
}
public void setInfoJsSwitch(Boolean infoJsSwitch) {
this.infoJsSwitch = infoJsSwitch;
}
public Boolean getDaoSwitch() {
return daoSwitch;
}
public void setDaoSwitch(Boolean daoSwitch) {
this.daoSwitch = daoSwitch;
}
public Boolean getServiceSwitch() {
return serviceSwitch;
}
public void setServiceSwitch(Boolean serviceSwitch) {
this.serviceSwitch = serviceSwitch;
}
public Boolean getEntitySwitch() {
return entitySwitch;
}
public void setEntitySwitch(Boolean entitySwitch) {
this.entitySwitch = entitySwitch;
}
public Boolean getSqlSwitch() {
return sqlSwitch;
}
public void setSqlSwitch(Boolean sqlSwitch) {
this.sqlSwitch = sqlSwitch;
}
public String getParentMenuName() {
return parentMenuName;
}
public void setParentMenuName(String parentMenuName) {
this.parentMenuName = parentMenuName;
}
}
package com.stylefeng.guns.generator.engine;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.generator.engine.base.GunsTemplateEngine;
/**
* 通用的模板生成引擎
*
* @author fengshuonan
* @date 2017-05-09 20:32
*/
public class SimpleTemplateEngine extends GunsTemplateEngine {
@Override
protected void generatePageEditHtml() {
String path = ToolUtil.format(super.getContextConfig().getProjectPath() + getPageConfig().getPageEditPathTemplate(),
super.getContextConfig().getBizEnName(), super.getContextConfig().getBizEnName());
generateFile(super.getContextConfig().getTemplatePrefixPath() + "/page_edit.html.btl", path);
System.out.println("生成编辑页面成功!");
}
@Override
protected void generatePageAddHtml() {
String path = ToolUtil.format(super.getContextConfig().getProjectPath() + getPageConfig().getPageAddPathTemplate(),
super.getContextConfig().getBizEnName(), super.getContextConfig().getBizEnName());
generateFile(super.getContextConfig().getTemplatePrefixPath() + "/page_add.html.btl", path);
System.out.println("生成添加页面成功!");
}
@Override
protected void generatePageInfoJs() {
String path = ToolUtil.format(super.getContextConfig().getProjectPath() + getPageConfig().getPageInfoJsPathTemplate(),
super.getContextConfig().getBizEnName(), super.getContextConfig().getBizEnName());
generateFile(super.getContextConfig().getTemplatePrefixPath() + "/page_info.js.btl", path);
System.out.println("生成页面详情js成功!");
}
@Override
protected void generatePageJs() {
String path = ToolUtil.format(super.getContextConfig().getProjectPath() + getPageConfig().getPageJsPathTemplate(),
super.getContextConfig().getBizEnName(), super.getContextConfig().getBizEnName());
generateFile(super.getContextConfig().getTemplatePrefixPath() + "/page.js.btl", path);
System.out.println("生成页面js成功!");
}
@Override
protected void generatePageHtml() {
String path = ToolUtil.format(super.getContextConfig().getProjectPath() + getPageConfig().getPagePathTemplate(),
super.getContextConfig().getBizEnName(), super.getContextConfig().getBizEnName());
generateFile(super.getContextConfig().getTemplatePrefixPath() + "/page.html.btl", path);
System.out.println("生成页面成功!");
}
@Override
protected void generateController() {
String controllerPath = ToolUtil.format(super.getContextConfig().getProjectPath() + super.getControllerConfig().getControllerPathTemplate(),
ToolUtil.firstLetterToUpper(super.getContextConfig().getBizEnName()));
generateFile(super.getContextConfig().getTemplatePrefixPath() + "/Controller.java.btl", controllerPath);
System.out.println("生成控制器成功!");
}
@Override
protected void generateSqls() {
String path = ToolUtil.format(super.getContextConfig().getProjectPath() + super.sqlConfig.getSqlPathTemplate(),
ToolUtil.firstLetterToUpper(super.getContextConfig().getBizEnName()));
generateFile(super.getContextConfig().getTemplatePrefixPath() + "/menu_sql.sql.btl", path);
System.out.println("生成sql成功!");
}
}
package com.stylefeng.guns.generator.engine.base;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.stylefeng.guns.generator.engine.config.*;
/**
* 模板生成父类
*
* @author fengshuonan
* @date 2017-05-08 20:17
*/
public class AbstractTemplateEngine {
protected ContextConfig contextConfig; //全局配置
protected ControllerConfig controllerConfig; //控制器的配置
protected PageConfig pageConfig; //页面的控制器
protected DaoConfig daoConfig; //Dao配置
protected ServiceConfig serviceConfig; //Service配置
protected SqlConfig sqlConfig; //sql配置
protected TableInfo tableInfo; //表的信息
public void initConfig() {
if (this.contextConfig == null) {
this.contextConfig = new ContextConfig();
}
if (this.controllerConfig == null) {
this.controllerConfig = new ControllerConfig();
}
if (this.pageConfig == null) {
this.pageConfig = new PageConfig();
}
if (this.daoConfig == null) {
this.daoConfig = new DaoConfig();
}
if (this.serviceConfig == null) {
this.serviceConfig = new ServiceConfig();
}
if (this.sqlConfig == null) {
this.sqlConfig = new SqlConfig();
}
this.contextConfig.init();
this.controllerConfig.setContextConfig(this.contextConfig);
this.controllerConfig.init();
this.serviceConfig.setContextConfig(this.contextConfig);
this.serviceConfig.init();
this.daoConfig.setContextConfig(this.contextConfig);
this.daoConfig.init();
this.pageConfig.setContextConfig(this.contextConfig);
this.pageConfig.init();
this.sqlConfig.setContextConfig(this.contextConfig);
this.sqlConfig.init();
}
public PageConfig getPageConfig() {
return pageConfig;
}
public void setPageConfig(PageConfig pageConfig) {
this.pageConfig = pageConfig;
}
public ContextConfig getContextConfig() {
return contextConfig;
}
public void setContextConfig(ContextConfig contextConfig) {
this.contextConfig = contextConfig;
}
public ControllerConfig getControllerConfig() {
return controllerConfig;
}
public void setControllerConfig(ControllerConfig controllerConfig) {
this.controllerConfig = controllerConfig;
}
public DaoConfig getDaoConfig() {
return daoConfig;
}
public void setDaoConfig(DaoConfig daoConfig) {
this.daoConfig = daoConfig;
}
public ServiceConfig getServiceConfig() {
return serviceConfig;
}
public void setServiceConfig(ServiceConfig serviceConfig) {
this.serviceConfig = serviceConfig;
}
public SqlConfig getSqlConfig() {
return sqlConfig;
}
public void setSqlConfig(SqlConfig sqlConfig) {
this.sqlConfig = sqlConfig;
}
public TableInfo getTableInfo() {
return tableInfo;
}
public void setTableInfo(TableInfo tableInfo) {
this.tableInfo = tableInfo;
}
}
package com.stylefeng.guns.generator.engine.base;
import com.stylefeng.guns.core.util.ToolUtil;
import com.sun.javafx.PlatformUtil;
import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.core.resource.ClasspathResourceLoader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
/**
* ADI项目模板生成 引擎
*
* @author fengshuonan
* @date 2017-05-07 22:15
*/
public abstract class GunsTemplateEngine extends AbstractTemplateEngine {
private GroupTemplate groupTemplate;
public GunsTemplateEngine() {
initBeetlEngine();
}
protected void initBeetlEngine() {
Properties properties = new Properties();
properties.put("RESOURCE.root", "");
properties.put("DELIMITER_STATEMENT_START", "<%");
properties.put("DELIMITER_STATEMENT_END", "%>");
properties.put("HTML_TAG_FLAG", "##");
Configuration cfg = null;
try {
cfg = new Configuration(properties);
} catch (IOException e) {
e.printStackTrace();
}
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();
groupTemplate = new GroupTemplate(resourceLoader, cfg);
groupTemplate.registerFunctionPackage("tool", new ToolUtil());
}
protected void configTemplate(Template template) {
template.binding("controller", super.controllerConfig);
template.binding("context", super.contextConfig);
template.binding("dao", super.daoConfig);
template.binding("service", super.serviceConfig);
template.binding("sqls", super.sqlConfig);
template.binding("table", super.tableInfo);
}
protected void generateFile(String template, String filePath) {
Template pageTemplate = groupTemplate.getTemplate(template);
configTemplate(pageTemplate);
if (PlatformUtil.isWindows()) {
filePath = filePath.replaceAll("/+|\\\\+", "\\\\");
} else {
filePath = filePath.replaceAll("/+|\\\\+", "/");
}
File file = new File(filePath);
File parentFile = file.getParentFile();
if (!parentFile.exists()) {
parentFile.mkdirs();
}
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(file);
pageTemplate.renderTo(fileOutputStream);
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
try {
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void start() {
//配置之间的相互依赖
super.initConfig();
//生成模板
if (super.contextConfig.getControllerSwitch()) {
generateController();
}
if (super.contextConfig.getIndexPageSwitch()) {
generatePageHtml();
}
if (super.contextConfig.getAddPageSwitch()) {
generatePageAddHtml();
}
if (super.contextConfig.getEditPageSwitch()) {
generatePageEditHtml();
}
if (super.contextConfig.getJsSwitch()) {
generatePageJs();
}
if (super.contextConfig.getInfoJsSwitch()) {
generatePageInfoJs();
}
if (super.contextConfig.getSqlSwitch()) {
generateSqls();
}
}
protected abstract void generatePageEditHtml();
protected abstract void generatePageAddHtml();
protected abstract void generatePageInfoJs();
protected abstract void generatePageJs();
protected abstract void generatePageHtml();
protected abstract void generateController();
protected abstract void generateSqls();
}
package com.stylefeng.guns.generator.engine.config;
import com.stylefeng.guns.core.util.ToolUtil;
/**
* 全局配置
*
* @author fengshuonan
* @date 2017-05-08 20:21
*/
public class ContextConfig {
private String templatePrefixPath = "gunsTemplate/advanced";
private String projectPath = "D:\\ideaSpace\\guns";//模板输出的项目目录
private String bizChName; //业务名称
private String bizEnName; //业务英文名称
private String bizEnBigName;//业务英文名称(大写)
private String moduleName = "system"; //模块名称
private String proPackage = "com.stylefeng.guns.admin";
private String coreBasePackage = "com.stylefeng.guns.core";
private String modelPackageName = "com.stylefeng.guns.modular.system.model"; //model的包名
private String modelMapperPackageName = "com.stylefeng.guns.modular.system.dao"; //model的dao
private String entityName; //实体的名称
private Boolean controllerSwitch = true; //是否生成控制器代码开关
private Boolean indexPageSwitch = true; //主页
private Boolean addPageSwitch = true; //添加页面
private Boolean editPageSwitch = true; //编辑页面
private Boolean jsSwitch = true; //js
private Boolean infoJsSwitch = true; //详情页面js
private Boolean daoSwitch = true; //dao
private Boolean serviceSwitch = true; //service
private Boolean entitySwitch = true; //生成实体的开关
private Boolean sqlSwitch = true; //生成sql的开关
public void init() {
if (entityName == null) {
entityName = bizEnBigName;
}
modelPackageName = proPackage + "." + "modular.system.model";
modelMapperPackageName = proPackage + "." + "modular.system.dao";
}
public String getBizEnBigName() {
return bizEnBigName;
}
public void setBizEnBigName(String bizEnBigName) {
this.bizEnBigName = bizEnBigName;
}
public String getBizChName() {
return bizChName;
}
public void setBizChName(String bizChName) {
this.bizChName = bizChName;
}
public String getBizEnName() {
return bizEnName;
}
public void setBizEnName(String bizEnName) {
this.bizEnName = bizEnName;
this.bizEnBigName = ToolUtil.firstLetterToUpper(this.bizEnName);
}
public String getProjectPath() {
return projectPath;
}
public void setProjectPath(String projectPath) {
this.projectPath = projectPath;
}
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
public Boolean getControllerSwitch() {
return controllerSwitch;
}
public void setControllerSwitch(Boolean controllerSwitch) {
this.controllerSwitch = controllerSwitch;
}
public Boolean getIndexPageSwitch() {
return indexPageSwitch;
}
public void setIndexPageSwitch(Boolean indexPageSwitch) {
this.indexPageSwitch = indexPageSwitch;
}
public Boolean getAddPageSwitch() {
return addPageSwitch;
}
public void setAddPageSwitch(Boolean addPageSwitch) {
this.addPageSwitch = addPageSwitch;
}
public Boolean getEditPageSwitch() {
return editPageSwitch;
}
public void setEditPageSwitch(Boolean editPageSwitch) {
this.editPageSwitch = editPageSwitch;
}
public Boolean getJsSwitch() {
return jsSwitch;
}
public void setJsSwitch(Boolean jsSwitch) {
this.jsSwitch = jsSwitch;
}
public Boolean getInfoJsSwitch() {
return infoJsSwitch;
}
public void setInfoJsSwitch(Boolean infoJsSwitch) {
this.infoJsSwitch = infoJsSwitch;
}
public Boolean getDaoSwitch() {
return daoSwitch;
}
public void setDaoSwitch(Boolean daoSwitch) {
this.daoSwitch = daoSwitch;
}
public Boolean getServiceSwitch() {
return serviceSwitch;
}
public void setServiceSwitch(Boolean serviceSwitch) {
this.serviceSwitch = serviceSwitch;
}
public String getTemplatePrefixPath() {
return templatePrefixPath;
}
public void setTemplatePrefixPath(String templatePrefixPath) {
this.templatePrefixPath = templatePrefixPath;
}
public String getModelPackageName() {
return modelPackageName;
}
public void setModelPackageName(String modelPackageName) {
this.modelPackageName = modelPackageName;
}
public String getEntityName() {
return entityName;
}
public void setEntityName(String entityName) {
this.entityName = entityName;
}
public String getModelMapperPackageName() {
return modelMapperPackageName;
}
public void setModelMapperPackageName(String modelMapperPackageName) {
this.modelMapperPackageName = modelMapperPackageName;
}
public Boolean getEntitySwitch() {
return entitySwitch;
}
public void setEntitySwitch(Boolean entitySwitch) {
this.entitySwitch = entitySwitch;
}
public Boolean getSqlSwitch() {
return sqlSwitch;
}
public void setSqlSwitch(Boolean sqlSwitch) {
this.sqlSwitch = sqlSwitch;
}
public String getProPackage() {
return proPackage;
}
public void setProPackage(String proPackage) {
this.proPackage = proPackage;
}
public String getCoreBasePackage() {
return coreBasePackage;
}
public void setCoreBasePackage(String coreBasePackage) {
this.coreBasePackage = coreBasePackage;
}
}
package com.stylefeng.guns.generator.engine.config;
import java.util.ArrayList;
import java.util.List;
/**
* 控制器模板生成的配置
*
* @author fengshuonan
* @date 2017-05-07 22:12
*/
public class ControllerConfig {
private ContextConfig contextConfig;
private String controllerPathTemplate;
private String packageName;//包名称
private List<String> imports;//所引入的包
public void init() {
ArrayList<String> imports = new ArrayList<>();
imports.add(contextConfig.getCoreBasePackage() + ".base.controller.BaseController");
imports.add("org.springframework.stereotype.Controller");
imports.add("org.springframework.web.bind.annotation.RequestMapping");
imports.add("org.springframework.web.bind.annotation.ResponseBody");
imports.add("org.springframework.ui.Model");
imports.add("org.springframework.web.bind.annotation.PathVariable");
imports.add("org.springframework.beans.factory.annotation.Autowired");
imports.add(contextConfig.getProPackage() + ".core.log.LogObjectHolder");
imports.add("org.springframework.web.bind.annotation.RequestParam");
imports.add(contextConfig.getModelPackageName() + "." + contextConfig.getEntityName());
imports.add(contextConfig.getProPackage() + ".modular." + contextConfig.getModuleName() + ".service" + ".I" + contextConfig.getEntityName() + "Service");
this.imports = imports;
this.packageName = contextConfig.getProPackage() + ".modular." + contextConfig.getModuleName() + ".controller";
this.controllerPathTemplate = "\\src\\main\\java\\"+contextConfig.getProPackage().replaceAll("\\.","\\\\")+"\\modular\\" + contextConfig.getModuleName() + "\\controller\\{}Controller.java";
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public List<String> getImports() {
return imports;
}
public void setImports(List<String> imports) {
this.imports = imports;
}
public String getControllerPathTemplate() {
return controllerPathTemplate;
}
public void setControllerPathTemplate(String controllerPathTemplate) {
this.controllerPathTemplate = controllerPathTemplate;
}
public ContextConfig getContextConfig() {
return contextConfig;
}
public void setContextConfig(ContextConfig contextConfig) {
this.contextConfig = contextConfig;
}
}
package com.stylefeng.guns.generator.engine.config;
/**
* Dao模板生成的配置
*
* @author fengshuonan
* @date 2017-05-07 22:12
*/
public class DaoConfig {
private ContextConfig contextConfig;
private String daoPathTemplate;
private String xmlPathTemplate;
private String packageName;
public void init() {
this.daoPathTemplate = "\\src\\main\\java\\" + contextConfig.getProPackage().replaceAll("\\.", "\\\\") + "\\modular\\" + contextConfig.getModuleName() + "\\dao\\{}Dao.java";
this.xmlPathTemplate = "\\src\\main\\java\\" + contextConfig.getProPackage().replaceAll("\\.", "\\\\") + "\\modular\\" + contextConfig.getModuleName() + "\\dao\\mapping\\{}Dao.xml";
this.packageName = contextConfig.getProPackage() + ".modular." + contextConfig.getModuleName() + ".dao";
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getDaoPathTemplate() {
return daoPathTemplate;
}
public void setDaoPathTemplate(String daoPathTemplate) {
this.daoPathTemplate = daoPathTemplate;
}
public String getXmlPathTemplate() {
return xmlPathTemplate;
}
public void setXmlPathTemplate(String xmlPathTemplate) {
this.xmlPathTemplate = xmlPathTemplate;
}
public ContextConfig getContextConfig() {
return contextConfig;
}
public void setContextConfig(ContextConfig contextConfig) {
this.contextConfig = contextConfig;
}
}
package com.stylefeng.guns.generator.engine.config;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable;
/**
* <p>
* 菜单表
* </p>
*
* @author stylefeng
* @since 2017-07-11
*/
public class Menu extends Model<Menu> {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 菜单编号
*/
private String code;
/**
* 菜单父编号
*/
private String pcode;
/**
* 当前菜单的所有父菜单编号
*/
private String pcodes;
/**
* 菜单名称
*/
private String name;
/**
* 菜单图标
*/
private String icon;
/**
* url地址
*/
private String url;
/**
* 菜单排序号
*/
private Integer num;
/**
* 菜单层级
*/
private Integer levels;
/**
* 是否是菜单(1:是 0:不是)
*/
private Integer ismenu;
/**
* 备注
*/
private String tips;
/**
* 菜单状态 : 1:启用 0:不启用
*/
private Integer status;
/**
* 是否打开: 1:打开 0:不打开
*/
private Integer isopen;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getPcode() {
return pcode;
}
public void setPcode(String pcode) {
this.pcode = pcode;
}
public String getPcodes() {
return pcodes;
}
public void setPcodes(String pcodes) {
this.pcodes = pcodes;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public Integer getLevels() {
return levels;
}
public void setLevels(Integer levels) {
this.levels = levels;
}
public Integer getIsmenu() {
return ismenu;
}
public void setIsmenu(Integer ismenu) {
this.ismenu = ismenu;
}
public String getTips() {
return tips;
}
public void setTips(String tips) {
this.tips = tips;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getIsopen() {
return isopen;
}
public void setIsopen(Integer isopen) {
this.isopen = isopen;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "Menu{" +
"id=" + id +
", code=" + code +
", pcode=" + pcode +
", pcodes=" + pcodes +
", name=" + name +
", icon=" + icon +
", url=" + url +
", num=" + num +
", levels=" + levels +
", ismenu=" + ismenu +
", tips=" + tips +
", status=" + status +
", isopen=" + isopen +
"}";
}
}
package com.stylefeng.guns.generator.engine.config;
/**
* 页面 模板生成的配置
*
* @author fengshuonan
* @date 2017-05-07 22:12
*/
public class PageConfig {
private ContextConfig contextConfig;
private String pagePathTemplate;
private String pageAddPathTemplate;
private String pageEditPathTemplate;
private String pageJsPathTemplate;
private String pageInfoJsPathTemplate;
public void init() {
pagePathTemplate = "\\src\\main\\webapp\\WEB-INF\\view\\" + contextConfig.getModuleName() + "\\{}\\{}.html";
pageAddPathTemplate = "\\src\\main\\webapp\\WEB-INF\\view\\" + contextConfig.getModuleName() + "\\{}\\{}_add.html";
pageEditPathTemplate = "\\src\\main\\webapp\\WEB-INF\\view\\" + contextConfig.getModuleName() + "\\{}\\{}_edit.html";
pageJsPathTemplate = "\\src\\main\\webapp\\static\\modular\\" + contextConfig.getModuleName() + "\\{}\\{}.js";
pageInfoJsPathTemplate = "\\src\\main\\webapp\\static\\modular\\" + contextConfig.getModuleName() + "\\{}\\{}_info.js";
}
public String getPagePathTemplate() {
return pagePathTemplate;
}
public void setPagePathTemplate(String pagePathTemplate) {
this.pagePathTemplate = pagePathTemplate;
}
public String getPageJsPathTemplate() {
return pageJsPathTemplate;
}
public void setPageJsPathTemplate(String pageJsPathTemplate) {
this.pageJsPathTemplate = pageJsPathTemplate;
}
public String getPageAddPathTemplate() {
return pageAddPathTemplate;
}
public void setPageAddPathTemplate(String pageAddPathTemplate) {
this.pageAddPathTemplate = pageAddPathTemplate;
}
public String getPageEditPathTemplate() {
return pageEditPathTemplate;
}
public void setPageEditPathTemplate(String pageEditPathTemplate) {
this.pageEditPathTemplate = pageEditPathTemplate;
}
public String getPageInfoJsPathTemplate() {
return pageInfoJsPathTemplate;
}
public void setPageInfoJsPathTemplate(String pageInfoJsPathTemplate) {
this.pageInfoJsPathTemplate = pageInfoJsPathTemplate;
}
public ContextConfig getContextConfig() {
return contextConfig;
}
public void setContextConfig(ContextConfig contextConfig) {
this.contextConfig = contextConfig;
}
}
package com.stylefeng.guns.generator.engine.config;
import java.util.ArrayList;
import java.util.List;
/**
* Service模板生成的配置
*
* @author fengshuonan
* @date 2017-05-07 22:12
*/
public class ServiceConfig {
private ContextConfig contextConfig;
private String servicePathTemplate;
private String serviceImplPathTemplate;
private String packageName;
private List<String> serviceInterfaceImports;
private List<String> serviceImplImports;
public void init() {
ArrayList<String> imports = new ArrayList<>();
imports.add("org.springframework.stereotype.Service");
imports.add("com.baomidou.mybatisplus.service.impl.ServiceImpl");
imports.add(contextConfig.getModelPackageName() + "." + contextConfig.getEntityName());
imports.add(contextConfig.getModelMapperPackageName() + "." + contextConfig.getEntityName() + "Mapper");
imports.add(contextConfig.getProPackage() + ".modular." + contextConfig.getModuleName() + ".service.I" + contextConfig.getBizEnBigName() + "Service");
this.serviceImplImports = imports;
ArrayList<String> interfaceImports = new ArrayList<>();
interfaceImports.add("com.baomidou.mybatisplus.service.IService");
interfaceImports.add(contextConfig.getModelPackageName() + "." + contextConfig.getEntityName());
this.serviceInterfaceImports = interfaceImports;
this.servicePathTemplate = "\\src\\main\\java\\" + contextConfig.getProPackage().replaceAll("\\.", "\\\\") + "\\modular\\" + contextConfig.getModuleName() + "\\service\\I{}Service.java";
this.serviceImplPathTemplate = "\\src\\main\\java\\" + contextConfig.getProPackage().replaceAll("\\.", "\\\\") + "\\modular\\" + contextConfig.getModuleName() + "\\service\\impl\\{}ServiceImpl.java";
this.packageName = contextConfig.getProPackage() + ".modular." + contextConfig.getModuleName() + ".service";
}
public String getServicePathTemplate() {
return servicePathTemplate;
}
public void setServicePathTemplate(String servicePathTemplate) {
this.servicePathTemplate = servicePathTemplate;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getServiceImplPathTemplate() {
return serviceImplPathTemplate;
}
public void setServiceImplPathTemplate(String serviceImplPathTemplate) {
this.serviceImplPathTemplate = serviceImplPathTemplate;
}
public List<String> getServiceImplImports() {
return serviceImplImports;
}
public void setServiceImplImports(List<String> serviceImplImports) {
this.serviceImplImports = serviceImplImports;
}
public ContextConfig getContextConfig() {
return contextConfig;
}
public void setContextConfig(ContextConfig contextConfig) {
this.contextConfig = contextConfig;
}
public List<String> getServiceInterfaceImports() {
return serviceInterfaceImports;
}
public void setServiceInterfaceImports(List<String> serviceInterfaceImports) {
this.serviceInterfaceImports = serviceInterfaceImports;
}
}
package com.stylefeng.guns.generator.engine.config;
import com.baomidou.mybatisplus.toolkit.IdWorker;
import com.stylefeng.guns.core.constant.IsMenu;
import com.stylefeng.guns.core.util.ToolUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* 全局配置
*
* @author fengshuonan
* @date 2017-05-08 20:21
*/
public class SqlConfig {
private String sqlPathTemplate;
private ContextConfig contextConfig;
private Connection connection;
private String parentMenuName;
private List<Menu> menus = new ArrayList<>(6);
public void init() {
this.sqlPathTemplate = "\\src\\main\\java\\{}.sql";
if (parentMenuName == null) {
return;
}
//根据父菜单查询数据库中的pcode和pcodes
String[] pcodeAndPcodes = getPcodeAndPcodes();
if (pcodeAndPcodes == null) {
System.err.println("父级菜单名称输入有误!!!!");
return;
}
//业务菜单
Menu menu = new Menu();
menu.setId(IdWorker.getId());
menu.setCode(contextConfig.getBizEnName());
menu.setPcode(pcodeAndPcodes[0]);
menu.setPcodes(pcodeAndPcodes[1] + "[" + pcodeAndPcodes[0] + "],");
menu.setName(contextConfig.getBizChName());
menu.setIcon("");
menu.setUrl("/" + contextConfig.getBizEnName());
menu.setNum(99);
if (parentMenuName.equals("顶级")) {
menu.setLevels(1);
} else {
menu.setLevels(2);
}
menu.setIsmenu(IsMenu.YES.getCode());
menu.setStatus(1);
menu.setIsopen(0);
menus.add(menu);
//列表
Menu list = createSubMenu(menu);
list.setCode(contextConfig.getBizEnName() + "_list");
list.setName(contextConfig.getBizChName() + "列表");
list.setUrl("/" + contextConfig.getBizEnName() + "/list");
menus.add(list);
//添加
Menu add = createSubMenu(menu);
add.setCode(contextConfig.getBizEnName() + "_add");
add.setName(contextConfig.getBizChName() + "添加");
add.setUrl("/" + contextConfig.getBizEnName() + "/add");
menus.add(add);
//更新
Menu update = createSubMenu(menu);
update.setCode(contextConfig.getBizEnName() + "_update");
update.setName(contextConfig.getBizChName() + "更新");
update.setUrl("/" + contextConfig.getBizEnName() + "/update");
menus.add(update);
//删除
Menu delete = createSubMenu(menu);
delete.setCode(contextConfig.getBizEnName() + "_delete");
delete.setName(contextConfig.getBizChName() + "删除");
delete.setUrl("/" + contextConfig.getBizEnName() + "/delete");
menus.add(delete);
//详情
Menu detail = createSubMenu(menu);
detail.setCode(contextConfig.getBizEnName() + "_detail");
detail.setName(contextConfig.getBizChName() + "详情");
detail.setUrl("/" + contextConfig.getBizEnName() + "/detail");
menus.add(detail);
}
private Menu createSubMenu(Menu parentMenu) {
Menu menu = new Menu();
menu.setId(IdWorker.getId());
menu.setPcode(parentMenu.getCode());
menu.setPcodes(parentMenu.getPcodes() + "[" + parentMenu.getCode() + "],");
menu.setIcon("");
menu.setNum(99);
menu.setLevels(parentMenu.getLevels() + 1);
menu.setIsmenu(IsMenu.NO.getCode());
menu.setStatus(1);
menu.setIsopen(0);
return menu;
}
public String[] getPcodeAndPcodes() {
if (parentMenuName.equals("顶级")) {
return new String[]{"0", ""};
}
PreparedStatement preparedStatement = null;
try {
preparedStatement = connection.prepareStatement("select * from sys_menu where name like ?");
preparedStatement.setString(1, "%" + parentMenuName + "%");
ResultSet results = preparedStatement.executeQuery();
while (results.next()) {
String pcode = results.getString("code");
String pcodes = results.getString("pcodes");
if (ToolUtil.isNotEmpty(pcode) && ToolUtil.isNotEmpty(pcodes)) {
String[] strings = {pcode, pcodes};
return strings;
} else {
return null;
}
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 释放资源
try {
if (preparedStatement != null) {
preparedStatement.close();
}
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
public ContextConfig getContextConfig() {
return contextConfig;
}
public void setContextConfig(ContextConfig contextConfig) {
this.contextConfig = contextConfig;
}
public String getParentMenuName() {
return parentMenuName;
}
public void setParentMenuName(String parentMenuName) {
this.parentMenuName = parentMenuName;
}
public Connection getConnection() {
return connection;
}
public void setConnection(Connection connection) {
this.connection = connection;
}
public String getSqlPathTemplate() {
return sqlPathTemplate;
}
public void setSqlPathTemplate(String sqlPathTemplate) {
this.sqlPathTemplate = sqlPathTemplate;
}
public List<Menu> getMenus() {
return menus;
}
public void setMenus(List<Menu> menus) {
this.menus = menus;
}
}
package ${controller.packageName};
<% for(import in controller.imports!){ %>
import ${import};
<% } %>
/**
* ${context.bizChName}控制器
*
* @author fengshuonan
* @Date ${tool.currentTime()}
*/
@Controller
@RequestMapping("/${context.bizEnName}")
public class ${context.bizEnBigName}Controller extends BaseController {
private String PREFIX = "/${context.moduleName}/${context.bizEnName}/";
@Autowired
private I${context.entityName}Service ${context.bizEnName}Service;
/**
* 跳转到${context.bizChName}首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "${context.bizEnName}.html";
}
/**
* 跳转到添加${context.bizChName}
*/
@RequestMapping("/${context.bizEnName}_add")
public String ${context.bizEnName}Add() {
return PREFIX + "${context.bizEnName}_add.html";
}
/**
* 跳转到修改${context.bizChName}
*/
@RequestMapping("/${context.bizEnName}_update/{${context.bizEnName}Id}")
public String ${context.bizEnName}Update(@PathVariable Integer ${context.bizEnName}Id, Model model) {
${context.entityName} ${context.bizEnName} = ${context.bizEnName}Service.selectById(${context.bizEnName}Id);
model.addAttribute("item",${context.bizEnName});
LogObjectHolder.me().set(${context.bizEnName});
return PREFIX + "${context.bizEnName}_edit.html";
}
/**
* 获取${context.bizChName}列表
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(String condition) {
return ${context.bizEnName}Service.selectList(null);
}
/**
* 新增${context.bizChName}
*/
@RequestMapping(value = "/add")
@ResponseBody
public Object add(${context.entityName} ${context.bizEnName}) {
${context.bizEnName}Service.insert(${context.bizEnName});
return SUCCESS_TIP;
}
/**
* 删除${context.bizChName}
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete(@RequestParam Integer ${context.bizEnName}Id) {
${context.bizEnName}Service.deleteById(${context.bizEnName}Id);
return SUCCESS_TIP;
}
/**
* 修改${context.bizChName}
*/
@RequestMapping(value = "/update")
@ResponseBody
public Object update(${context.entityName} ${context.bizEnName}) {
${context.bizEnName}Service.updateById(${context.bizEnName});
return SUCCESS_TIP;
}
/**
* ${context.bizChName}详情
*/
@RequestMapping(value = "/detail/{${context.bizEnName}Id}")
@ResponseBody
public Object detail(@PathVariable("${context.bizEnName}Id") Integer ${context.bizEnName}Id) {
return ${context.bizEnName}Service.selectById(${context.bizEnName}Id);
}
}
<% for(menu in sqls.menus!){ %>
INSERT INTO `guns`.`sys_menu` (`id`, `code`, `pcode`, `pcodes`, `name`, `icon`, `url`, `num`, `levels`, `ismenu`, `tips`, `status`, `isopen`) VALUES ('${menu.id}', '${menu.code}', '${menu.pcode}', '${menu.pcodes}', '${menu.name}', '${menu.icon}', '${menu.url}', '${menu.num}', '${menu.levels}', '${menu.ismenu}', NULL, '${menu.status}', '${menu.isopen}');
<% } %>
\ No newline at end of file
@layout("/common/_container.html"){
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>${context.bizChName}管理</h5>
</div>
<div class="ibox-content">
<div class="row row-lg">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<#NameCon id="condition" name="名称" />
</div>
<div class="col-sm-3">
<#button name="搜索" icon="fa-search" clickFun="${context.bizEnBigName}.search()"/>
</div>
</div>
<div class="hidden-xs" id="${context.bizEnBigName}TableToolbar" role="group">
@if(shiro.hasPermission("/${context.bizEnName}/add")){
<#button name="添加" icon="fa-plus" clickFun="${context.bizEnBigName}.openAdd${context.bizEnBigName}()"/>
@}
@if(shiro.hasPermission("/${context.bizEnName}/update")){
<#button name="修改" icon="fa-edit" clickFun="${context.bizEnBigName}.open${context.bizEnBigName}Detail()" space="true"/>
@}
@if(shiro.hasPermission("/${context.bizEnName}/delete")){
<#button name="删除" icon="fa-remove" clickFun="${context.bizEnBigName}.delete()" space="true"/>
@}
</div>
<#table id="${context.bizEnBigName}Table"/>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="\${ctxPath}/static/modular/${context.moduleName}/${context.bizEnName}/${context.bizEnName}.js"></script>
@}
/**
* ${context.bizChName}管理初始化
*/
var ${context.bizEnBigName} = {
id: "${context.bizEnBigName}Table", //表格id
seItem: null, //选中的条目
table: null,
layerIndex: -1
};
/**
* 初始化表格的列
*/
${context.bizEnBigName}.initColumn = function () {
return [
{field: 'selectItem', radio: true},
<% for(item in table.fields!){ %>
<% if(itemLP.last != true){ %>
{title: '${item.comment}', field: '${item.propertyName}', visible: true, align: 'center', valign: 'middle'},
<% }else{ %>
{title: '${item.comment}', field: '${item.propertyName}', visible: true, align: 'center', valign: 'middle'}
<% }} %>
];
};
/**
* 检查是否选中
*/
${context.bizEnBigName}.check = function () {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if(selected.length == 0){
Feng.info("请先选中表格中的某一记录!");
return false;
}else{
${context.bizEnBigName}.seItem = selected[0];
return true;
}
};
/**
* 点击添加${context.bizChName}
*/
${context.bizEnBigName}.openAdd${context.bizEnBigName} = function () {
var index = layer.open({
type: 2,
title: '添加${context.bizChName}',
area: ['800px', '420px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/${context.bizEnName}/${context.bizEnName}_add'
});
this.layerIndex = index;
};
/**
* 打开查看${context.bizChName}详情
*/
${context.bizEnBigName}.open${context.bizEnBigName}Detail = function () {
if (this.check()) {
var index = layer.open({
type: 2,
title: '${context.bizChName}详情',
area: ['800px', '420px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/${context.bizEnName}/${context.bizEnName}_update/' + ${context.bizEnBigName}.seItem.id
});
this.layerIndex = index;
}
};
/**
* 删除${context.bizChName}
*/
${context.bizEnBigName}.delete = function () {
if (this.check()) {
var ajax = new $ax(Feng.ctxPath + "/${context.bizEnName}/delete", function (data) {
Feng.success("删除成功!");
${context.bizEnBigName}.table.refresh();
}, function (data) {
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("${context.bizEnName}Id",this.seItem.id);
ajax.start();
}
};
/**
* 查询${context.bizChName}列表
*/
${context.bizEnBigName}.search = function () {
var queryData = {};
queryData['condition'] = $("#condition").val();
${context.bizEnBigName}.table.refresh({query: queryData});
};
$(function () {
var defaultColunms = ${context.bizEnBigName}.initColumn();
var table = new BSTable(${context.bizEnBigName}.id, "/${context.bizEnName}/list", defaultColunms);
table.setPaginationType("client");
${context.bizEnBigName}.table = table.init();
});
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-horizontal">
<div class="row">
<div class="col-sm-6 b-r">
<% var leftSize = tool.toInt((table.fields.~size + 1) / 2); %>
<% var rightSize = tool.toInt(table.fields.~size - leftSize); %>
<% for(var i=0;i<leftSize;i++){ %>
<% if(i != (leftSize-1) ){ %>
<#input id="${table.fields[i].propertyName}" name="${table.fields[i].comment}" underline="true"/>
<% }else{ %>
<#input id="${table.fields[i].propertyName}" name="${table.fields[i].comment}"/>
<% } %>
<% } %>
</div>
<div class="col-sm-6">
<% for(var i=leftSize;i<table.fields.~size;i++){ %>
<% if(i != (rightSize-1) ){ %>
<#input id="${table.fields[i].propertyName}" name="${table.fields[i].comment}" underline="true"/>
<% }else{ %>
<#input id="${table.fields[i].propertyName}" name="${table.fields[i].comment}"/>
<% } %>
<% } %>
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="${context.bizEnBigName}InfoDlg.addSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="${context.bizEnBigName}InfoDlg.close()"/>
</div>
</div>
</div>
</div>
</div>
<script src="\${ctxPath}/static/modular/${context.moduleName}/${context.bizEnName}/${context.bizEnName}_info.js"></script>
@}
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-horizontal">
<div class="row">
<div class="col-sm-6 b-r">
<% var leftSize = tool.toInt((table.fields.~size + 1) / 2); %>
<% var rightSize = tool.toInt(table.fields.~size - leftSize); %>
<% for(var i=0;i<leftSize;i++){ %>
<% if(i != (leftSize-1) ){ %>
<#input id="${table.fields[i].propertyName}" name="${table.fields[i].comment}" value="\${item.${table.fields[i].propertyName}}" underline="true"/>
<% }else{ %>
<#input id="${table.fields[i].propertyName}" name="${table.fields[i].comment}" value="\${item.${table.fields[i].propertyName}}" />
<% } %>
<% } %>
</div>
<div class="col-sm-6">
<% for(var i=leftSize;i<table.fields.~size;i++){ %>
<% if(i != (table.fields.~size-1) ){ %>
<#input id="${table.fields[i].propertyName}" name="${table.fields[i].comment}" value="\${item.${table.fields[i].propertyName}}" underline="true"/>
<% }else{ %>
<#input id="${table.fields[i].propertyName}" name="${table.fields[i].comment}" value="\${item.${table.fields[i].propertyName}}" />
<% } %>
<% } %>
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="${context.bizEnBigName}InfoDlg.editSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="${context.bizEnBigName}InfoDlg.close()"/>
</div>
</div>
</div>
</div>
</div>
<script src="\${ctxPath}/static/modular/${context.moduleName}/${context.bizEnName}/${context.bizEnName}_info.js"></script>
@}
/**
* 初始化${context.bizChName}详情对话框
*/
var ${context.bizEnBigName}InfoDlg = {
${context.bizEnName}InfoData : {}
};
/**
* 清除数据
*/
${context.bizEnBigName}InfoDlg.clearData = function() {
this.${context.bizEnName}InfoData = {};
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
${context.bizEnBigName}InfoDlg.set = function(key, val) {
this.${context.bizEnName}InfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
return this;
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
${context.bizEnBigName}InfoDlg.get = function(key) {
return $("#" + key).val();
}
/**
* 关闭此对话框
*/
${context.bizEnBigName}InfoDlg.close = function() {
parent.layer.close(window.parent.${context.bizEnBigName}.layerIndex);
}
/**
* 收集数据
*/
${context.bizEnBigName}InfoDlg.collectData = function() {
this
<% for(item in table.fields!){ %>
<% if(itemLP.last != true){ %>
.set('${item.propertyName}')
<% }else{ %>
.set('${item.propertyName}');
<% }} %>
}
/**
* 提交添加
*/
${context.bizEnBigName}InfoDlg.addSubmit = function() {
this.clearData();
this.collectData();
//提交信息
var ajax = new $ax(Feng.ctxPath + "/${context.bizEnName}/add", function(data){
Feng.success("添加成功!");
window.parent.${context.bizEnBigName}.table.refresh();
${context.bizEnBigName}InfoDlg.close();
},function(data){
Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(this.${context.bizEnName}InfoData);
ajax.start();
}
/**
* 提交修改
*/
${context.bizEnBigName}InfoDlg.editSubmit = function() {
this.clearData();
this.collectData();
//提交信息
var ajax = new $ax(Feng.ctxPath + "/${context.bizEnName}/update", function(data){
Feng.success("修改成功!");
window.parent.${context.bizEnBigName}.table.refresh();
${context.bizEnBigName}InfoDlg.close();
},function(data){
Feng.error("修改失败!" + data.responseJSON.message + "!");
});
ajax.set(this.${context.bizEnName}InfoData);
ajax.start();
}
$(function() {
});
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<modules> <modules>
<module>guns-admin</module> <module>guns-admin</module>
<module>guns-core</module> <module>guns-core</module>
<module>guns-generator</module>
</modules> </modules>
<parent> <parent>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment