From 57443e5825e5d09be11e1aa65a49d8525acff21d Mon Sep 17 00:00:00 2001
From: WenG <450292408@qq.com>
Date: Wed, 17 Feb 2021 18:53:45 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A1=A8=E7=B4=A2=E5=BC=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/mybatis/mapper/data-mapper.xml | 4 +-
.../resources/mybatis/mapper/file-mapper.xml | 3 +-
.../mybatis/mapper/permission-mapper.xml | 15 +-
.../resources/templates/permission/list.html | 104 +++++------
.../mybatis/mapper/department-mapper.xml | 2 +-
.../resources/mybatis/mapper/group-mapper.xml | 3 +-
.../menu/startup/ServiceMenuStartUp.java | 164 ++++++++++++++++--
.../resources/mybatis/mapper/menu-mapper.xml | 3 +-
.../mybatis/mapper/position-mapper.xml | 3 +-
.../resources/mybatis/mapper/user-mapper.xml | 2 +-
10 files changed, 222 insertions(+), 81 deletions(-)
diff --git a/module-dictionary/src/main/resources/mybatis/mapper/data-mapper.xml b/module-dictionary/src/main/resources/mybatis/mapper/data-mapper.xml
index 24549cbd..53ca21b5 100644
--- a/module-dictionary/src/main/resources/mybatis/mapper/data-mapper.xml
+++ b/module-dictionary/src/main/resources/mybatis/mapper/data-mapper.xml
@@ -36,8 +36,8 @@
`gmt_modified` datetime DEFAULT NULL,
`is_delete` int(2) DEFAULT '0',
PRIMARY KEY (`id`,`data_id`),
- KEY `is_delete_index` (`is_delete`) USING BTREE,
- KEY `data_id` (`data_id`) USING BTREE
+ UNIQUE KEY `data_id` (`data_id`) USING BTREE,
+ KEY `is_delete_index` (`is_delete`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/module-file/src/main/resources/mybatis/mapper/file-mapper.xml b/module-file/src/main/resources/mybatis/mapper/file-mapper.xml
index ec919816..7a38490c 100644
--- a/module-file/src/main/resources/mybatis/mapper/file-mapper.xml
+++ b/module-file/src/main/resources/mybatis/mapper/file-mapper.xml
@@ -57,7 +57,8 @@
`modifier` char(36) DEFAULT NULL COMMENT '修改人',
`gmt_modified` datetime DEFAULT NULL,
`is_delete` int(2) DEFAULT '0',
- PRIMARY KEY (`id`,`file_id`)
+ PRIMARY KEY (`id`,`file_id`),
+ UNIQUE KEY `file_id` (`file_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/module-permission/src/main/resources/mybatis/mapper/permission-mapper.xml b/module-permission/src/main/resources/mybatis/mapper/permission-mapper.xml
index 53416c8f..89672e51 100644
--- a/module-permission/src/main/resources/mybatis/mapper/permission-mapper.xml
+++ b/module-permission/src/main/resources/mybatis/mapper/permission-mapper.xml
@@ -22,14 +22,16 @@
`permission_title` varchar(255) DEFAULT NULL COMMENT '权限标题',
`permission_type` varchar(255) DEFAULT NULL COMMENT '权限类型',
`permission_url` varchar(255) DEFAULT NULL COMMENT '权限路径',
- `permission_client_id` varchar(255) DEFAULT NULL COMMENT '客户端',
+ `system_tag` varchar(255) DEFAULT NULL COMMENT '系统标识(系统路径),NULL表示本系统',
`is_public` int(11) DEFAULT NULL COMMENT '是否公共',
`creator` char(36) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`modifier` char(36) DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
`is_delete` int(1) DEFAULT '0',
- PRIMARY KEY (`id`,`permission_id`)
+ PRIMARY KEY (`id`,`permission_id`),
+ UNIQUE KEY `permission_id` (`permission_id`),
+ KEY `system_tag` (`system_tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -140,24 +142,15 @@
t1.permission_type,
t1.permission_url,
t1.permission_client_id,
- jt1.client_name permission_client_name,
t1.is_public,
t1.permission_id
FROM
sys_permission t1
- LEFT JOIN
- oauth_client_details jt1
- ON
- jt1.client_id = t1.permission_client_id
- AND
- jt1.is_delete = 0
WHERE
t1.is_delete = 0
AND (
t1.permission_title LIKE CONCAT('%', #{keywords}, '%')
- OR
- jt1.client_name LIKE CONCAT('%', #{keywords}, '%')
)
diff --git a/module-permission/src/main/resources/templates/permission/list.html b/module-permission/src/main/resources/templates/permission/list.html
index 1c02d519..14d8d0d8 100644
--- a/module-permission/src/main/resources/templates/permission/list.html
+++ b/module-permission/src/main/resources/templates/permission/list.html
@@ -77,61 +77,63 @@
pageName: 'page',
limitName: 'rows'
},
- cols: [[
- {type:'checkbox', fixed: 'left'},
- {field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '{{d.LAY_INDEX}}'},
- {field: 'permissionUrl', width: 300, title: '权限路径', align:'center',
- templet: function(row) {
- var rowData = row[this.field];
- if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
- return '-';
+ cols: [
+ [
+ {type:'checkbox', fixed: 'left'},
+ {field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '{{d.LAY_INDEX}}'},
+ {field: 'permissionUrl', width: 300, title: '权限路径', align:'center',
+ templet: function(row) {
+ var rowData = row[this.field];
+ if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
+ return '-';
+ }
+ return rowData;
}
- return rowData;
- }
- },
- {field:'permissionTitle', width:200, title: '权限名称', align:'center'},
- {field: 'permissionType', width: 100, title: '权限类型', align:'center',
- templet: function(row) {
- var rowData = row[this.field];
- if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
- return '-';
+ },
+ {field:'permissionTitle', width:200, title: '权限名称', align:'center'},
+ {field: 'permissionType', width: 100, title: '权限类型', align:'center',
+ templet: function(row) {
+ var rowData = row[this.field];
+ if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
+ return '-';
+ }
+ if(rowData == 'permissionInsert') {
+ return '新增权限';
+ } else if(rowData == 'permissionDelete') {
+ return '删除权限';
+ } else if(rowData == 'permissionUpdate') {
+ return '更新权限';
+ } else if(rowData == 'permissionQuery') {
+ return '查询权限';
+ }
+ return '错误';
}
- if(rowData == 'permissionInsert') {
- return '新增权限';
- } else if(rowData == 'permissionDelete') {
- return '删除权限';
- } else if(rowData == 'permissionUpdate') {
- return '更新权限';
- } else if(rowData == 'permissionQuery') {
- return '查询权限';
+ },
+ {field: 'permissionClientName', width: 180, title: '客户端名称', align:'center',
+ templet: function(row) {
+ var rowData = row[this.field];
+ if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
+ return '-';
+ }
+ return rowData;
}
- return '错误';
- }
- },
- {field: 'permissionClientName', width: 180, title: '客户端名称', align:'center',
- templet: function(row) {
- var rowData = row[this.field];
- if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
- return '-';
+ },
+ {field: 'isPublic', width: 100, title: '公共接口', align:'center',
+ templet: function(row) {
+ var rowData = row[this.field];
+ if(typeof(rowData) === 'undefined' || rowData == null) {
+ return '-';
+ }
+ if(rowData == '0') {
+ return '否';
+ } else if(rowData == '1') {
+ return '是';
+ }
+ return '错误';
}
- return rowData;
- }
- },
- {field: 'isPublic', width: 100, title: '公共接口', align:'center',
- templet: function(row) {
- var rowData = row[this.field];
- if(typeof(rowData) === 'undefined' || rowData == null) {
- return '-';
- }
- if(rowData == '0') {
- return '否';
- } else if(rowData == '1') {
- return '是';
- }
- return '错误';
- }
- },
- ]],
+ },
+ ]
+ ],
page: true,
parseData: function(data) {
return {
diff --git a/service-department/src/main/resources/mybatis/mapper/department-mapper.xml b/service-department/src/main/resources/mybatis/mapper/department-mapper.xml
index ecf0f29e..c5b7b6f6 100644
--- a/service-department/src/main/resources/mybatis/mapper/department-mapper.xml
+++ b/service-department/src/main/resources/mybatis/mapper/department-mapper.xml
@@ -135,7 +135,7 @@
`gmt_modified` datetime DEFAULT NULL,
`is_delete` int(2) DEFAULT '0',
PRIMARY KEY (`id`,`department_id`),
- KEY `department_id_idx` (`department_id`) USING BTREE
+ UNIQUE KEY `department_id` (`department_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/service-group/src/main/resources/mybatis/mapper/group-mapper.xml b/service-group/src/main/resources/mybatis/mapper/group-mapper.xml
index 04ce990f..c9bb165b 100644
--- a/service-group/src/main/resources/mybatis/mapper/group-mapper.xml
+++ b/service-group/src/main/resources/mybatis/mapper/group-mapper.xml
@@ -47,7 +47,8 @@
`modifier` char(36) DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
`is_delete` int(2) DEFAULT '0',
- PRIMARY KEY (`id`,`group_id`)
+ PRIMARY KEY (`id`,`group_id`),
+ UNIQUE KEY `group_id` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java b/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java
index 22d190bc..fe21f05d 100644
--- a/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java
+++ b/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java
@@ -90,6 +90,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
}
initSystemManage(params, menuId);
initUserPermissionManage(params, menuId);
+ initPermissionManager(params, menuId);
}
private void initSystemManage(Map params, String menuParentId) {
@@ -133,8 +134,8 @@ public class ServiceMenuStartUp implements ApplicationRunner {
if (menuDTO == null) {
params.put("menuId", UUIDUtil.getUUID());
params.put("menuParentId", menuParentId);
- params.put("menuName", "菜单管理");
- params.put("menuSummary", "菜单管理");
+ params.put("menuName", "菜单");
+ params.put("menuSummary", "菜单");
params.put("menuUrl", "/route/menu/list-tree");
params.put("menuType", "1");
params.put("menuIcon", "fa-icon-color-white fa fa-list");
@@ -210,7 +211,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
* @param menuParentId
*/
private void initUserPermissionManage(Map params, String menuParentId) {
- LOG.debug("初始化菜单:用户与权限");
+ LOG.debug("初始化菜单:用户管理");
params.remove("menuId");
params.put("menuCode", "00010002");
MenuDTO menuDTO = menuDao.getSimple(params);
@@ -219,8 +220,8 @@ public class ServiceMenuStartUp implements ApplicationRunner {
menuId = UUIDUtil.getUUID();
params.put("menuId", menuId);
params.put("menuParentId", menuParentId);
- params.put("menuName", "用户与权限");
- params.put("menuSummary", "用户与权限");
+ params.put("menuName", "用户管理");
+ params.put("menuSummary", "用户管理");
params.put("menuUrl", "javascript:void(0);");
params.put("menuType", "1");
params.put("menuIcon", "fa-icon-color-white fa fa-users");
@@ -256,7 +257,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
if (menuDTO == null) {
params.put("menuId", menuId);
params.put("menuParentId", menuParentId);
- params.put("menuName", "用户管理");
+ params.put("menuName", "用户");
params.put("menuSummary", "用户管理");
params.put("menuUrl", "/route/user/list");
params.put("menuType", "1");
@@ -287,7 +288,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
if (menuDTO == null) {
params.put("menuId", menuId);
params.put("menuParentId", menuParentId);
- params.put("menuName", "机构管理");
+ params.put("menuName", "机构");
params.put("menuSummary", "机构管理");
params.put("menuUrl", "/route/department/list-tree");
params.put("menuType", "1");
@@ -318,7 +319,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
if (menuDTO == null) {
params.put("menuId", menuId);
params.put("menuParentId", menuParentId);
- params.put("menuName", "用户组管理");
+ params.put("menuName", "用户组");
params.put("menuSummary", "用户组管理");
params.put("menuUrl", "/route/group/list-tree");
params.put("menuType", "1");
@@ -348,7 +349,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
if (menuDTO == null) {
params.put("menuId", menuId);
params.put("menuParentId", menuParentId);
- params.put("menuName", "职位管理");
+ params.put("menuName", "职位");
params.put("menuSummary", "职位管理");
params.put("menuUrl", "/route/position/list-tree");
params.put("menuType", "1");
@@ -360,12 +361,153 @@ public class ServiceMenuStartUp implements ApplicationRunner {
}
}
+ /**
+ * 初始化权限管理
+ *
+ * @param params
+ * @param menuParentId
+ */
private void initPermissionManager(Map params, String menuParentId) {
- if(permissionCheckService == null) {
+ if (permissionCheckService == null) {
return;
}
- LOG.debug("初始化菜单:权限管理");
+ LOG.debug("初始化菜单:角色与权限管理");
+ params.remove("menuId");
+ params.put("menuCode", "00010003");
+ MenuDTO menuDTO = menuDao.getSimple(params);
+ String menuId;
+ if (menuDTO == null) {
+ menuId = UUIDUtil.getUUID();
+ params.put("menuId", menuId);
+ params.put("menuParentId", menuParentId);
+ params.put("menuName", "角色与权限管理");
+ params.put("menuSummary", "角色与权限管理");
+ params.put("menuUrl", "javascript:void(0);");
+ params.put("menuType", "1");
+ params.put("menuIcon", "fa-icon-color-white fa fa-users");
+ params.put("menuOrder", "3");
+ params.put("menuStatus", "0");
+ params.put("openType", "1");
+ menuDao.save(params);
+ } else {
+ menuId = menuDTO.getMenuId();
+ }
+ initSavePermissionManager(params, menuId);
+ initDeletePermissionManager(params, menuId);
+ initUpdatePermissionManager(params, menuId);
+ initQueryPermissionManager(params, menuId);
+ }
+ /**
+ * 新增权限
+ *
+ * @param params
+ * @param menuParentId
+ */
+ private void initSavePermissionManager(Map params, String menuParentId) {
+ LOG.debug("初始化菜单:新增权限");
+ params.remove("menuId");
+ params.put("menuCode", "000100030001");
+ MenuDTO menuDTO = menuDao.getSimple(params);
+ String menuId;
+ if (menuDTO == null) {
+ menuId = UUIDUtil.getUUID();
+ params.put("menuId", menuId);
+ params.put("menuParentId", menuParentId);
+ params.put("menuName", "新增权限");
+ params.put("menuSummary", "新增权限");
+ params.put("menuUrl", "/route/permission/list?permissionType=permissionInsert");
+ params.put("menuType", "1");
+ params.put("menuIcon", "fa-icon-color-white fa fa-users");
+ params.put("menuOrder", "1");
+ params.put("menuStatus", "0");
+ params.put("openType", "1");
+ menuDao.save(params);
+ }
+ }
+
+ /**
+ * 修改权限
+ *
+ * @param params
+ * @param menuParentId
+ */
+ private void initDeletePermissionManager(Map params, String menuParentId) {
+ LOG.debug("初始化菜单:删除权限");
+ params.remove("menuId");
+ params.put("menuCode", "000100030002");
+ MenuDTO menuDTO = menuDao.getSimple(params);
+ String menuId;
+ if (menuDTO == null) {
+ menuId = UUIDUtil.getUUID();
+ params.put("menuId", menuId);
+ params.put("menuParentId", menuParentId);
+ params.put("menuName", "删除权限");
+ params.put("menuSummary", "删除权限");
+ params.put("menuUrl", "/route/permission/list?permissionType=permissionDelete");
+ params.put("menuType", "1");
+ params.put("menuIcon", "fa-icon-color-white fa fa-users");
+ params.put("menuOrder", "2");
+ params.put("menuStatus", "0");
+ params.put("openType", "1");
+ menuDao.save(params);
+ }
+ }
+
+ /**
+ * 修改权限
+ *
+ * @param params
+ * @param menuParentId
+ */
+ private void initUpdatePermissionManager(Map params, String menuParentId) {
+ LOG.debug("初始化菜单:修改权限");
+ params.remove("menuId");
+ params.put("menuCode", "000100030003");
+ MenuDTO menuDTO = menuDao.getSimple(params);
+ String menuId;
+ if (menuDTO == null) {
+ menuId = UUIDUtil.getUUID();
+ params.put("menuId", menuId);
+ params.put("menuParentId", menuParentId);
+ params.put("menuName", "修改权限");
+ params.put("menuSummary", "修改权限");
+ params.put("menuUrl", "/route/permission/list?permissionType=permissionUpdate");
+ params.put("menuType", "1");
+ params.put("menuIcon", "fa-icon-color-white fa fa-users");
+ params.put("menuOrder", "3");
+ params.put("menuStatus", "0");
+ params.put("openType", "1");
+ menuDao.save(params);
+ }
+ }
+
+ /**
+ * 查询权限
+ *
+ * @param params
+ * @param menuParentId
+ */
+ private void initQueryPermissionManager(Map params, String menuParentId) {
+ LOG.debug("初始化菜单:查询权限");
+ params.remove("menuId");
+ params.put("menuCode", "000100030004");
+ MenuDTO menuDTO = menuDao.getSimple(params);
+ String menuId;
+ if (menuDTO == null) {
+ menuId = UUIDUtil.getUUID();
+ params.put("menuId", menuId);
+ params.put("menuParentId", menuParentId);
+ params.put("menuName", "修改权限");
+ params.put("menuSummary", "修改权限");
+ params.put("menuUrl", "/route/permission/list?permissionType=permissionQuery");
+ params.put("menuType", "1");
+ params.put("menuIcon", "fa-icon-color-white fa fa-users");
+ params.put("menuOrder", "4");
+ params.put("menuStatus", "0");
+ params.put("openType", "1");
+ menuDao.save(params);
+ }
}
private void initMenuRole() {
diff --git a/service-menu/src/main/resources/mybatis/mapper/menu-mapper.xml b/service-menu/src/main/resources/mybatis/mapper/menu-mapper.xml
index 46ed6b23..7064fa88 100644
--- a/service-menu/src/main/resources/mybatis/mapper/menu-mapper.xml
+++ b/service-menu/src/main/resources/mybatis/mapper/menu-mapper.xml
@@ -46,7 +46,8 @@
`gmt_modified` datetime DEFAULT NULL,
`modifier` char(36) DEFAULT NULL,
`is_delete` int(2) DEFAULT '0',
- PRIMARY KEY (`id`,`menu_id`)
+ PRIMARY KEY (`id`,`menu_id`),
+ UNIQUE KEY `menu_id` (`menu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/service-position/src/main/resources/mybatis/mapper/position-mapper.xml b/service-position/src/main/resources/mybatis/mapper/position-mapper.xml
index ff889587..351c88f0 100644
--- a/service-position/src/main/resources/mybatis/mapper/position-mapper.xml
+++ b/service-position/src/main/resources/mybatis/mapper/position-mapper.xml
@@ -41,7 +41,8 @@
`modifier` char(36) DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
`is_delete` int(2) DEFAULT '0',
- PRIMARY KEY (`id`,`position_id`)
+ PRIMARY KEY (`id`,`position_id`),
+ UNIQUE KEY `position_id` (`position_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/service-user/src/main/resources/mybatis/mapper/user-mapper.xml b/service-user/src/main/resources/mybatis/mapper/user-mapper.xml
index 08561502..8e2ed477 100644
--- a/service-user/src/main/resources/mybatis/mapper/user-mapper.xml
+++ b/service-user/src/main/resources/mybatis/mapper/user-mapper.xml
@@ -74,7 +74,7 @@
`is_delete` int(2) DEFAULT '0',
PRIMARY KEY (`id`,`user_id`,`user_username`),
UNIQUE KEY `user_username` (`user_username`) USING BTREE,
- KEY `user_id` (`user_id`) USING BTREE,
+ UNIQUE KEY `user_id` (`user_id`) USING BTREE,
KEY `user_name` (`user_name`) USING BTREE,
KEY `user_id_2` (`user_id`,`user_username`,`user_name`) USING BTREE,
KEY `user_id_3` (`user_id`,`user_name`) USING BTREE,