diff --git a/README.md b/README.md index dcbda4338..8a9e6e268 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ eladmin-qt和eladmin-qd只是命名方式的区别,无其他区别 - + diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java b/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java index 701a3590c..0f4ecf19e 100644 --- a/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java +++ b/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java @@ -7,10 +7,10 @@ import me.zhengjie.utils.ThrowableUtil; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.AccessDeniedException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import java.nio.file.AccessDeniedException; import static org.springframework.http.HttpStatus.*; /** diff --git a/eladmin-common/src/main/java/me/zhengjie/redis/RedisConfig.java b/eladmin-common/src/main/java/me/zhengjie/redis/RedisConfig.java index f21c4e73c..96b176d47 100644 --- a/eladmin-common/src/main/java/me/zhengjie/redis/RedisConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/redis/RedisConfig.java @@ -94,10 +94,9 @@ public RedisTemplate redisTemplate(RedisConnectionFactory redisC // 全局开启AutoType,不建议使用 // ParserConfig.getGlobalInstance().setAutoTypeSupport(true); // 建议使用这种方式,小范围指定白名单 + ParserConfig.getGlobalInstance().addAccept("me.zhengjie.domain"); ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.system.service.dto"); - ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.test.service.dto"); ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.system.domain"); - ParserConfig.getGlobalInstance().addAccept("me.zhengjie.domain"); ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.quartz.domain"); ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.monitor.domain"); ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.security.security"); diff --git a/eladmin-common/src/main/java/me/zhengjie/swagger2/SwaggerConfig.java b/eladmin-common/src/main/java/me/zhengjie/swagger2/SwaggerConfig.java index 114be5b6d..791a262f0 100644 --- a/eladmin-common/src/main/java/me/zhengjie/swagger2/SwaggerConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/swagger2/SwaggerConfig.java @@ -2,7 +2,6 @@ import com.google.common.base.Predicates; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ParameterBuilder; @@ -13,25 +12,17 @@ import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; - import java.util.ArrayList; import java.util.List; /** * api页面 /swagger-ui.html - * 如controller在不同的包中,@ComponentScan(basePackages = {"me.aurora.app.rest","..."}) * @author jie * @date 2018-11-23 */ @Configuration @EnableSwagger2 -@ComponentScan(basePackages = { - "me.zhengjie.rest", - "me.zhengjie.modules.system.rest", - "me.zhengjie.modules.monitor.rest", - "me.zhengjie.modules.monitor.rest", - "me.zhengjie.modules.quartz.rest"}) public class SwaggerConfig { @Bean diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java index 5d3be1547..223767594 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java @@ -1,7 +1,6 @@ package me.zhengjie.utils; import org.springframework.util.DigestUtils; - import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java index 50c229e22..ec60f3d12 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java @@ -2,7 +2,6 @@ import cn.hutool.core.util.IdUtil; import org.springframework.web.multipart.MultipartFile; - import java.io.File; import java.io.IOException; import java.text.DecimalFormat; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/ListSortUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/ListSortUtil.java deleted file mode 100644 index cdd970976..000000000 --- a/eladmin-common/src/main/java/me/zhengjie/utils/ListSortUtil.java +++ /dev/null @@ -1,51 +0,0 @@ -package me.zhengjie.utils; - -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -/** - * List按照指定字段排序工具类 - * @author jie - * @date 2018/08/23 20:03:12 - * @param - */ -public class ListSortUtil { - - /** - * @param targetList 目标排序List - * @param sortField 排序字段(实体类属性名) - * @param sortMode 排序方式(asc or desc) - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void sort(List targetList, final String sortField, final String sortMode) { - - Collections.sort(targetList, new Comparator() { - - @Override - public int compare(Object obj1, Object obj2) { - int retVal = 0; - try { - //首字母转大写 - String newStr=sortField.substring(0, 1).toUpperCase()+sortField.replaceFirst("\\w",""); - String methodStr="get"+newStr; - - Method method1 = ((T)obj1).getClass().getMethod(methodStr, new Class[0]); - Method method2 = ((T)obj2).getClass().getMethod(methodStr, new Class[0]); - if (sortMode != null && "desc".equals(sortMode)) { - // 倒序 - retVal = method2.invoke(((T) obj2), new Object[0]).toString().compareTo(method1.invoke(((T) obj1), new Object[0]).toString()); - } else { - // 正序 - retVal = method1.invoke(((T) obj1), new Object[0]).toString().compareTo(method2.invoke(((T) obj2), new Object[0]).toString()); - } - } catch (Exception e) { - throw new RuntimeException(); - } - return retVal; - } - }); - } - -} \ No newline at end of file diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml index d54e6316d..967a6ba84 100644 --- a/eladmin-system/pom.xml +++ b/eladmin-system/pom.xml @@ -21,6 +21,12 @@ me.zhengjie eladmin-generator 1.5 + + + me.zhengjie + eladmin-common + + diff --git a/eladmin-system/sql/eladmin.sql b/eladmin-system/sql/eladmin.sql index 4721f554e..a37de3fbb 100644 --- a/eladmin-system/sql/eladmin.sql +++ b/eladmin-system/sql/eladmin.sql @@ -1,17 +1,17 @@ /* - Navicat MySQL Data Transfer + Navicat Premium Data Transfer - Source Server : 本地 + Source Server : localhost Source Server Type : MySQL - Source Server Version : 50559 + Source Server Version : 50562 Source Host : localhost:3306 Source Schema : eladmin Target Server Type : MySQL - Target Server Version : 50559 + Target Server Version : 50562 File Encoding : 65001 - Date: 20/01/2019 19:17:08 + Date: 27/02/2019 13:15:23 */ SET NAMES utf8mb4; @@ -39,7 +39,7 @@ CREATE TABLE `alipay_config` ( -- ---------------------------- -- Records of alipay_config -- ---------------------------- -INSERT INTO `alipay_config` VALUES (1, '2016091700532697', 'utf-8', 'JSON', 'https://openapi.alipaydev.com/gateway.do', 'http://api.auauz.net/api/aliPay/notify', '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', 'http://api.auauz.ne/api/aliPay/return', 'RSA2', '2088102176044281'); +INSERT INTO `alipay_config` VALUES (1, '2016091700532697', 'utf-8', 'JSON', 'https://openapi.alipaydev.com/gateway.do', 'http://api.auauz.net/api/aliPay/notify', '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', 'http://api.auauz.net/api/aliPay/return', 'RSA2', '2088102176044281'); -- ---------------------------- -- Table structure for email_config @@ -73,25 +73,7 @@ CREATE TABLE `gen_config` ( -- ---------------------------- -- Records of gen_config -- ---------------------------- -INSERT INTO `gen_config` VALUES (1, 'jie', b'0', 'eladmin-system', 'me.zhengjie.modules.test', 'E:\\workspace\\my-workspace\\eladmin-qt\\src\\views\\system\\test', 'E:\\workspace\\my-workspace\\eladmin-qt\\src\\api'); - --- ---------------------------- --- Table structure for log --- ---------------------------- -DROP TABLE IF EXISTS `log`; -CREATE TABLE `log` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', - `create_time` datetime NULL DEFAULT NULL COMMENT '创建日期', - `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '描述', - `exception_detail` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '异常详情', - `log_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '日志类型', - `method` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '方法名称', - `params` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '参数', - `request_ip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求ip', - `time` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '耗时', - `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作用户', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 6327 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +INSERT INTO `gen_config` VALUES (1, 'jie', '0', 'eladmin-system', 'me.zhengjie.modules.test', 'E:\\workspace\\my-workspace\\eladmin-qt\\src\\views\\system\\test', 'E:\\workspace\\my-workspace\\eladmin-qt\\src\\api'); -- ---------------------------- -- Table structure for menu @@ -100,121 +82,46 @@ DROP TABLE IF EXISTS `menu`; CREATE TABLE `menu` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `create_time` datetime NULL DEFAULT NULL COMMENT '创建日期', + `i_frame` bit(1) NULL DEFAULT NULL COMMENT '是否外链', `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '菜单名称', `component` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '组件', `pid` bigint(20) NOT NULL COMMENT '上级菜单ID', `sort` bigint(20) NOT NULL COMMENT '排序', `icon` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图标', `path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '链接地址', - `i_frame` bit(1) NULL DEFAULT NULL COMMENT '是否外链', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 36 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 33 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of menu -- ---------------------------- -INSERT INTO `menu` VALUES (1, '2018-12-18 15:11:29', '系统管理', NULL, 0, 1, 'system', 'system', b'0'); -INSERT INTO `menu` VALUES (2, '2018-12-18 15:14:44', '用户管理', 'system/user/index', 1, 2, 'peoples', 'user', b'0'); -INSERT INTO `menu` VALUES (3, '2018-12-18 15:16:07', '角色管理', 'system/role/index', 1, 3, 'role', 'role', b'0'); -INSERT INTO `menu` VALUES (4, '2018-12-18 15:16:45', '权限管理', 'system/permission/index', 1, 4, 'permission', 'permission', b'0'); -INSERT INTO `menu` VALUES (5, '2018-12-18 15:17:28', '菜单管理', 'system/menu/index', 1, 5, 'menu', 'menu', b'0'); -INSERT INTO `menu` VALUES (6, '2018-12-18 15:17:48', '系统监控', NULL, 0, 10, 'monitor', 'monitor', b'0'); -INSERT INTO `menu` VALUES (7, '2018-12-18 15:18:26', '操作日志', 'monitor/log/index', 6, 11, 'log', 'logs', b'0'); -INSERT INTO `menu` VALUES (8, '2018-12-18 15:19:01', '系统缓存', 'monitor/redis/index', 6, 13, 'redis', 'redis', b'0'); -INSERT INTO `menu` VALUES (9, '2018-12-18 15:19:34', 'SQL监控', NULL, 6, 14, 'sqlMonitor', 'http://localhost:8000/druid', b'1'); -INSERT INTO `menu` VALUES (10, '2018-12-19 13:38:16', '组件管理', NULL, 0, 50, 'zujian', 'components', b'0'); -INSERT INTO `menu` VALUES (11, '2018-12-19 13:38:49', '图标库', 'components/IconSelect', 10, 51, 'icon', 'icon', b'0'); -INSERT INTO `menu` VALUES (12, '2018-12-24 20:37:35', '实时控制台', 'monitor/log/msg', 6, 15, 'codeConsole', 'msg', b'0'); -INSERT INTO `menu` VALUES (13, '2018-12-27 10:11:26', '三方工具', '', 0, 30, 'tools', 'tools', b'0'); -INSERT INTO `menu` VALUES (14, '2018-12-27 10:13:09', '邮件工具', 'tools/email/index', 13, 31, 'email', 'email', b'0'); -INSERT INTO `menu` VALUES (15, '2018-12-27 11:58:25', '富文本', 'components/Editor', 10, 52, 'fwb', 'tinymce', b'0'); -INSERT INTO `menu` VALUES (16, '2018-12-28 09:36:53', 'SM.MS图床', 'tools/picture/index', 13, 32, 'image', 'pictures', b'0'); -INSERT INTO `menu` VALUES (17, '2018-12-28 15:09:49', '项目地址', '', 0, 0, 'github', 'https://github.com/elunez/eladmin', b'1'); -INSERT INTO `menu` VALUES (18, '2018-12-31 11:12:15', '七牛云存储', 'tools/qiniu/index', 13, 33, 'qiniu', 'qiniu', b'0'); -INSERT INTO `menu` VALUES (19, '2018-12-31 14:52:38', '支付宝工具', 'tools/aliPay/index', 13, 34, 'alipay', 'aliPay', b'0'); -INSERT INTO `menu` VALUES (21, '2019-01-04 16:22:03', '多级菜单', '', 0, 900, 'menu', 'nested', b'0'); -INSERT INTO `menu` VALUES (22, '2019-01-04 16:23:29', '二级菜单1', 'nested/menu1/index', 21, 999, 'menu', 'menu1', b'0'); -INSERT INTO `menu` VALUES (23, '2019-01-04 16:23:57', '二级菜单2', 'nested/menu2/index', 21, 999, 'menu', 'menu2', b'0'); -INSERT INTO `menu` VALUES (24, '2019-01-04 16:24:48', '三级菜单1', 'nested/menu1/menu1-1', 22, 999, 'menu', 'menu1-1', b'0'); -INSERT INTO `menu` VALUES (27, '2019-01-07 17:27:32', '三级菜单2', 'nested/menu1/menu1-2', 22, 999, 'menu', 'menu1-2', b'0'); -INSERT INTO `menu` VALUES (28, '2019-01-07 20:34:40', '定时任务', 'system/timing/index', 1, 6, 'timing', 'timing', b'0'); -INSERT INTO `menu` VALUES (30, '2019-01-11 15:45:55', '代码生成', 'generator/index', 1, 8, 'dev', 'generator', b'0'); -INSERT INTO `menu` VALUES (32, '2019-01-13 13:49:03', '异常日志', 'monitor/log/errorLog', 6, 12, 'error', 'errorLog', b'0'); - --- ---------------------------- --- Table structure for menus_roles --- ---------------------------- -DROP TABLE IF EXISTS `menus_roles`; -CREATE TABLE `menus_roles` ( - `menu_id` bigint(20) NOT NULL COMMENT '菜单ID', - `role_id` bigint(20) NOT NULL COMMENT '角色ID', - PRIMARY KEY (`menu_id`, `role_id`) USING BTREE, - INDEX `FKcngg2qadojhi3a651a5adkvbq`(`role_id`) USING BTREE, - CONSTRAINT `FKcngg2qadojhi3a651a5adkvbq` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, - CONSTRAINT `FKq1knxf8ykt26we8k331naabjx` FOREIGN KEY (`menu_id`) REFERENCES `menu` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; - --- ---------------------------- --- Records of menus_roles --- ---------------------------- -INSERT INTO `menus_roles` VALUES (1, 1); -INSERT INTO `menus_roles` VALUES (2, 1); -INSERT INTO `menus_roles` VALUES (3, 1); -INSERT INTO `menus_roles` VALUES (4, 1); -INSERT INTO `menus_roles` VALUES (5, 1); -INSERT INTO `menus_roles` VALUES (6, 1); -INSERT INTO `menus_roles` VALUES (7, 1); -INSERT INTO `menus_roles` VALUES (8, 1); -INSERT INTO `menus_roles` VALUES (9, 1); -INSERT INTO `menus_roles` VALUES (10, 1); -INSERT INTO `menus_roles` VALUES (11, 1); -INSERT INTO `menus_roles` VALUES (12, 1); -INSERT INTO `menus_roles` VALUES (13, 1); -INSERT INTO `menus_roles` VALUES (14, 1); -INSERT INTO `menus_roles` VALUES (15, 1); -INSERT INTO `menus_roles` VALUES (16, 1); -INSERT INTO `menus_roles` VALUES (17, 1); -INSERT INTO `menus_roles` VALUES (18, 1); -INSERT INTO `menus_roles` VALUES (19, 1); -INSERT INTO `menus_roles` VALUES (21, 1); -INSERT INTO `menus_roles` VALUES (22, 1); -INSERT INTO `menus_roles` VALUES (23, 1); -INSERT INTO `menus_roles` VALUES (24, 1); -INSERT INTO `menus_roles` VALUES (27, 1); -INSERT INTO `menus_roles` VALUES (28, 1); -INSERT INTO `menus_roles` VALUES (30, 1); -INSERT INTO `menus_roles` VALUES (32, 1); -INSERT INTO `menus_roles` VALUES (1, 2); -INSERT INTO `menus_roles` VALUES (2, 2); -INSERT INTO `menus_roles` VALUES (3, 2); -INSERT INTO `menus_roles` VALUES (4, 2); -INSERT INTO `menus_roles` VALUES (5, 2); -INSERT INTO `menus_roles` VALUES (6, 2); -INSERT INTO `menus_roles` VALUES (9, 2); -INSERT INTO `menus_roles` VALUES (12, 2); -INSERT INTO `menus_roles` VALUES (13, 2); -INSERT INTO `menus_roles` VALUES (14, 2); -INSERT INTO `menus_roles` VALUES (16, 2); -INSERT INTO `menus_roles` VALUES (17, 2); -INSERT INTO `menus_roles` VALUES (18, 2); -INSERT INTO `menus_roles` VALUES (19, 2); -INSERT INTO `menus_roles` VALUES (21, 2); -INSERT INTO `menus_roles` VALUES (22, 2); -INSERT INTO `menus_roles` VALUES (23, 2); -INSERT INTO `menus_roles` VALUES (24, 2); -INSERT INTO `menus_roles` VALUES (27, 2); -INSERT INTO `menus_roles` VALUES (28, 2); - --- ---------------------------- --- Table structure for my_test --- ---------------------------- -DROP TABLE IF EXISTS `my_test`; -CREATE TABLE `my_test` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', - `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称', - `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +INSERT INTO `menu` VALUES (1, '2018-12-18 15:11:29', b'0', '系统管理', NULL, 0, 1, 'system', 'system'); +INSERT INTO `menu` VALUES (2, '2018-12-18 15:14:44', b'0', '用户管理', 'system/user/index', 1, 2, 'peoples', 'user'); +INSERT INTO `menu` VALUES (3, '2018-12-18 15:16:07', b'0', '角色管理', 'system/role/index', 1, 3, 'role', 'role'); +INSERT INTO `menu` VALUES (4, '2018-12-18 15:16:45', b'0', '权限管理', 'system/permission/index', 1, 4, 'permission', 'permission'); +INSERT INTO `menu` VALUES (5, '2018-12-18 15:17:28', b'0', '菜单管理', 'system/menu/index', 1, 5, 'menu', 'menu'); +INSERT INTO `menu` VALUES (6, '2018-12-18 15:17:48', b'0', '系统监控', NULL, 0, 10, 'monitor', 'monitor'); +INSERT INTO `menu` VALUES (7, '2018-12-18 15:18:26', b'0', '操作日志', 'monitor/log/index', 6, 11, 'log', 'logs'); +INSERT INTO `menu` VALUES (8, '2018-12-18 15:19:01', b'0', '系统缓存', 'monitor/redis/index', 6, 13, 'redis', 'redis'); +INSERT INTO `menu` VALUES (9, '2018-12-18 15:19:34', b'1', 'SQL监控', NULL, 6, 14, 'sqlMonitor', 'http://api.auauz.net/druid'); +INSERT INTO `menu` VALUES (10, '2018-12-19 13:38:16', b'0', '组件管理', NULL, 0, 50, 'zujian', 'components'); +INSERT INTO `menu` VALUES (11, '2018-12-19 13:38:49', b'0', '图标库', 'components/IconSelect', 10, 51, 'icon', 'icon'); +INSERT INTO `menu` VALUES (12, '2018-12-24 20:37:35', b'0', '实时控制台', 'monitor/log/msg', 6, 15, 'codeConsole', 'msg'); +INSERT INTO `menu` VALUES (13, '2018-12-27 10:11:26', b'0', '三方工具', '', 0, 30, 'tools', 'tools'); +INSERT INTO `menu` VALUES (14, '2018-12-27 10:13:09', b'0', '邮件工具', 'tools/email/index', 13, 31, 'email', 'email'); +INSERT INTO `menu` VALUES (15, '2018-12-27 11:58:25', b'0', '富文本', 'components/Editor', 10, 52, 'fwb', 'tinymce'); +INSERT INTO `menu` VALUES (16, '2018-12-28 09:36:53', b'0', 'SM.MS图床', 'tools/picture/index', 13, 32, 'image', 'pictures'); +INSERT INTO `menu` VALUES (17, '2018-12-28 15:09:49', b'1', '项目地址', '', 0, 0, 'github', 'https://github.com/elunez/eladmin'); +INSERT INTO `menu` VALUES (18, '2018-12-31 11:12:15', b'0', '七牛云存储', 'tools/qiniu/index', 13, 33, 'qiniu', 'qiniu'); +INSERT INTO `menu` VALUES (19, '2018-12-31 14:52:38', b'0', '支付宝工具', 'tools/aliPay/index', 13, 34, 'alipay', 'aliPay'); +INSERT INTO `menu` VALUES (21, '2019-01-04 16:22:03', b'0', '多级菜单', '', 0, 900, 'menu', 'nested'); +INSERT INTO `menu` VALUES (22, '2019-01-04 16:23:29', b'0', '二级菜单1', 'nested/menu1/index', 21, 999, 'menu', 'menu1'); +INSERT INTO `menu` VALUES (23, '2019-01-04 16:23:57', b'0', '二级菜单2', 'nested/menu2/index', 21, 999, 'menu', 'menu2'); +INSERT INTO `menu` VALUES (24, '2019-01-04 16:24:48', b'0', '三级菜单1', 'nested/menu1/menu1-1', 22, 999, 'menu', 'menu1-1'); +INSERT INTO `menu` VALUES (27, '2019-01-07 17:27:32', b'0', '三级菜单2', 'nested/menu1/menu1-2', 22, 999, 'menu', 'menu1-2'); +INSERT INTO `menu` VALUES (28, '2019-01-07 20:34:40', b'0', '定时任务', 'system/timing/index', 1, 6, 'timing', 'timing'); +INSERT INTO `menu` VALUES (30, '2019-01-11 15:45:55', b'0', '代码生成', 'generator/index', 1, 8, 'dev', 'generator'); +INSERT INTO `menu` VALUES (32, '2019-01-13 13:49:03', b'0', '异常日志', 'monitor/log/errorLog', 6, 12, 'error', 'errorLog'); -- ---------------------------- -- Table structure for permission @@ -283,9 +190,8 @@ CREATE TABLE `picture` ( `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名称', `width` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片宽度', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 54 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 50 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; --- ---------------------------- -- Table structure for qiniu_config -- ---------------------------- DROP TABLE IF EXISTS `qiniu_config`; @@ -313,7 +219,7 @@ CREATE TABLE `qiniu_content` ( `update_time` datetime NULL DEFAULT NULL COMMENT '上传或同步的时间', `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件url', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Table structure for quartz_job @@ -344,18 +250,18 @@ INSERT INTO `quartz_job` VALUES (3, 'testTask', '0/5 * * * * ?', b'1', '测试', -- ---------------------------- DROP TABLE IF EXISTS `quartz_log`; CREATE TABLE `quartz_log` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', - `baen_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'Spring Bean名称', - `create_time` datetime NULL DEFAULT NULL COMMENT '创建日期', - `cron_expression` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'cron 表达式', - `exception_detail` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '异常详情', - `is_success` bit(1) NULL DEFAULT NULL COMMENT '运行状态:1成功,0异常', - `job_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务名称', - `method_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '方法名称', - `params` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参数', - `time` bigint(20) NULL DEFAULT NULL COMMENT '耗时', + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `baen_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `cron_expression` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `exception_detail` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `is_success` bit(1) NULL DEFAULT NULL, + `job_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `method_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `params` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `time` bigint(20) NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Table structure for role @@ -367,13 +273,72 @@ CREATE TABLE `role` ( `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称', `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of role -- ---------------------------- -INSERT INTO `role` VALUES (1, '2018-11-23 11:04:37', '超级管理员', '超级管理员'); -INSERT INTO `role` VALUES (2, '2018-11-23 13:09:06', '普通用户', '普通用户'); +INSERT INTO `role` VALUES (1, '2018-11-23 11:04:37', '管理员', '系统所有权'); +INSERT INTO `role` VALUES (2, '2018-11-23 13:09:06', '普通用户', '用于测试菜单与权限'); + +-- ---------------------------- +-- Table structure for roles_menus +-- ---------------------------- +DROP TABLE IF EXISTS `roles_menus`; +CREATE TABLE `roles_menus` ( + `role_id` bigint(20) NOT NULL COMMENT '角色ID', + `menu_id` bigint(20) NOT NULL COMMENT '菜单ID', + PRIMARY KEY (`menu_id`, `role_id`) USING BTREE, + INDEX `FKcngg2qadojhi3a651a5adkvbq`(`role_id`) USING BTREE, + CONSTRAINT `FKcngg2qadojhi3a651a5adkvbq` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FKq1knxf8ykt26we8k331naabjx` FOREIGN KEY (`menu_id`) REFERENCES `menu` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; + +-- ---------------------------- +-- Records of roles_menus +-- ---------------------------- +INSERT INTO `roles_menus` VALUES (1, 1); +INSERT INTO `roles_menus` VALUES (1, 2); +INSERT INTO `roles_menus` VALUES (1, 3); +INSERT INTO `roles_menus` VALUES (1, 4); +INSERT INTO `roles_menus` VALUES (1, 5); +INSERT INTO `roles_menus` VALUES (1, 6); +INSERT INTO `roles_menus` VALUES (1, 7); +INSERT INTO `roles_menus` VALUES (1, 8); +INSERT INTO `roles_menus` VALUES (1, 9); +INSERT INTO `roles_menus` VALUES (1, 10); +INSERT INTO `roles_menus` VALUES (1, 11); +INSERT INTO `roles_menus` VALUES (1, 12); +INSERT INTO `roles_menus` VALUES (1, 13); +INSERT INTO `roles_menus` VALUES (1, 14); +INSERT INTO `roles_menus` VALUES (1, 15); +INSERT INTO `roles_menus` VALUES (1, 16); +INSERT INTO `roles_menus` VALUES (1, 17); +INSERT INTO `roles_menus` VALUES (1, 18); +INSERT INTO `roles_menus` VALUES (1, 19); +INSERT INTO `roles_menus` VALUES (1, 21); +INSERT INTO `roles_menus` VALUES (1, 22); +INSERT INTO `roles_menus` VALUES (1, 23); +INSERT INTO `roles_menus` VALUES (1, 24); +INSERT INTO `roles_menus` VALUES (1, 27); +INSERT INTO `roles_menus` VALUES (1, 28); +INSERT INTO `roles_menus` VALUES (1, 30); +INSERT INTO `roles_menus` VALUES (1, 32); +INSERT INTO `roles_menus` VALUES (2, 1); +INSERT INTO `roles_menus` VALUES (2, 2); +INSERT INTO `roles_menus` VALUES (2, 6); +INSERT INTO `roles_menus` VALUES (2, 10); +INSERT INTO `roles_menus` VALUES (2, 11); +INSERT INTO `roles_menus` VALUES (2, 12); +INSERT INTO `roles_menus` VALUES (2, 13); +INSERT INTO `roles_menus` VALUES (2, 15); +INSERT INTO `roles_menus` VALUES (2, 16); +INSERT INTO `roles_menus` VALUES (2, 17); +INSERT INTO `roles_menus` VALUES (2, 21); +INSERT INTO `roles_menus` VALUES (2, 22); +INSERT INTO `roles_menus` VALUES (2, 23); +INSERT INTO `roles_menus` VALUES (2, 24); +INSERT INTO `roles_menus` VALUES (2, 27); -- ---------------------------- -- Table structure for roles_permissions @@ -392,13 +357,15 @@ CREATE TABLE `roles_permissions` ( -- Records of roles_permissions -- ---------------------------- INSERT INTO `roles_permissions` VALUES (1, 1); +INSERT INTO `roles_permissions` VALUES (2, 2); INSERT INTO `roles_permissions` VALUES (2, 3); -INSERT INTO `roles_permissions` VALUES (2, 8); -INSERT INTO `roles_permissions` VALUES (2, 14); -INSERT INTO `roles_permissions` VALUES (2, 19); +INSERT INTO `roles_permissions` VALUES (2, 4); +INSERT INTO `roles_permissions` VALUES (2, 5); +INSERT INTO `roles_permissions` VALUES (2, 6); INSERT INTO `roles_permissions` VALUES (2, 23); -INSERT INTO `roles_permissions` VALUES (2, 30); -INSERT INTO `roles_permissions` VALUES (2, 36); +INSERT INTO `roles_permissions` VALUES (2, 24); +INSERT INTO `roles_permissions` VALUES (2, 25); +INSERT INTO `roles_permissions` VALUES (2, 26); -- ---------------------------- -- Table structure for user @@ -456,20 +423,4 @@ CREATE TABLE `verification_code` ( `value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '接收邮箱或者手机号码', `scenes` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务名称:如重置邮箱、重置密码等', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; - --- ---------------------------- --- Table structure for visits --- ---------------------------- -DROP TABLE IF EXISTS `visits`; -CREATE TABLE `visits` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', - `date` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建日期:只存储年月日', - `ip_counts` bigint(20) NULL DEFAULT NULL COMMENT 'IP数', - `pv_counts` bigint(20) NULL DEFAULT NULL COMMENT '浏览量', - `week_day` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '星期', - `create_time` datetime NULL DEFAULT NULL COMMENT '创建日期', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 65 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; - -SET FOREIGN_KEY_CHECKS = 1; +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/RedisVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/RedisVo.java index 905db961b..434607d4b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/RedisVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/RedisVo.java @@ -5,6 +5,7 @@ import lombok.NoArgsConstructor; import javax.validation.constraints.NotBlank; +import java.io.Serializable; /** * @author jie @@ -13,7 +14,7 @@ @Data @AllArgsConstructor @NoArgsConstructor -public class RedisVo { +public class RedisVo implements Serializable { @NotBlank private String key; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java index 1cb0815e4..78a7c7616 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java @@ -5,6 +5,7 @@ import javax.persistence.*; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.sql.Timestamp; @@ -21,6 +22,7 @@ public class QuartzJob implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotNull(groups = {Update.class}) private Long id; /** @@ -75,4 +77,6 @@ public class QuartzJob implements Serializable { @UpdateTimestamp @Column(name = "update_time") private Timestamp updateTime; + + public interface Update{} } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java index c7a5fb5f6..9915a9e0d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java @@ -68,10 +68,7 @@ public ResponseEntity create(@Validated @RequestBody QuartzJob resources){ @Log("修改定时任务") @PutMapping(value = "/jobs") @PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')") - public ResponseEntity update(@Validated @RequestBody QuartzJob resources){ - if (resources.getId() == null) { - throw new BadRequestException(ENTITY_NAME +" ID Can not be empty"); - } + public ResponseEntity update(@Validated(QuartzJob.Update.class) @RequestBody QuartzJob resources){ quartzJobService.update(resources); return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java index 8d310b723..4fe33fa1d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java @@ -41,7 +41,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { private String tokenHeader; @Value("${jwt.auth.path}") - private String authenticationPath; + private String loginPath; @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { @@ -74,9 +74,18 @@ protected void configure(HttpSecurity httpSecurity) throws Exception { // 不创建会话 .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() - .authorizeRequests() - .antMatchers("/auth/**").permitAll() + // 过滤请求 + .authorizeRequests() + .antMatchers( + HttpMethod.GET, + "/*.html", + "/**/*.html", + "/**/*.css", + "/**/*.js" + ).permitAll() + + .antMatchers( HttpMethod.POST,"/auth/"+loginPath).permitAll() .antMatchers("/websocket/**").permitAll() .antMatchers("/druid/**").anonymous() @@ -91,33 +100,14 @@ protected void configure(HttpSecurity httpSecurity) throws Exception { .antMatchers("/*/api-docs").anonymous() // swagger end + // 接口限流测试 .antMatchers("/test/**").anonymous() .antMatchers(HttpMethod.OPTIONS, "/**").anonymous() + // 所有请求都需要认证 .anyRequest().authenticated(); httpSecurity .addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); } - - @Override - public void configure(WebSecurity web) throws Exception { - // AuthenticationTokenFilter will ignore the below paths - web.ignoring() - .antMatchers( - HttpMethod.POST, - authenticationPath - ) - - // allow anonymous resource requests - .and() - .ignoring() - .antMatchers( - HttpMethod.GET, - "/*.html", - "/**/*.html", - "/**/*.css", - "/**/*.js" - ); - } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java index a5ec229df..aa1a6a4be 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java @@ -2,7 +2,7 @@ import lombok.extern.slf4j.Slf4j; import me.zhengjie.aop.log.Log; -import me.zhengjie.modules.security.security.AuthenticationToken; +import me.zhengjie.modules.security.security.AuthenticationInfo; import me.zhengjie.modules.security.security.AuthorizationUser; import me.zhengjie.modules.security.security.JwtUser; import me.zhengjie.utils.EncryptUtils; @@ -47,21 +47,21 @@ public class AuthenticationController { @PostMapping(value = "${jwt.auth.path}") public ResponseEntity login(@Validated @RequestBody AuthorizationUser authorizationUser){ - final UserDetails userDetails = userDetailsService.loadUserByUsername(authorizationUser.getUsername()); + final JwtUser jwtUser = (JwtUser) userDetailsService.loadUserByUsername(authorizationUser.getUsername()); - if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(authorizationUser.getPassword()))){ + if(!jwtUser.getPassword().equals(EncryptUtils.encryptPassword(authorizationUser.getPassword()))){ throw new AccountExpiredException("密码错误"); } - if(!userDetails.isEnabled()){ + if(!jwtUser.isEnabled()){ throw new AccountExpiredException("账号已停用,请联系管理员"); } // 生成令牌 - final String token = jwtTokenUtil.generateToken(userDetails); + final String token = jwtTokenUtil.generateToken(jwtUser); // 返回 token - return ResponseEntity.ok(new AuthenticationToken(token)); + return ResponseEntity.ok(new AuthenticationInfo(token,jwtUser)); } /** diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthenticationToken.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthenticationInfo.java similarity index 70% rename from eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthenticationToken.java rename to eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthenticationInfo.java index ee8f8240e..399590fe2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthenticationToken.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthenticationInfo.java @@ -1,18 +1,19 @@ -package me.zhengjie.modules.security.security; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.io.Serializable; - -/** - * @author jie - * @date 2018-11-23 - * 返回token - */ -@Getter -@AllArgsConstructor -public class AuthenticationToken implements Serializable { - - private final String token; -} +package me.zhengjie.modules.security.security; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import java.io.Serializable; + +/** + * @author jie + * @date 2018-11-23 + * 返回token + */ +@Getter +@AllArgsConstructor +public class AuthenticationInfo implements Serializable { + + private final String token; + + private final JwtUser user; +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/JwtUserDetailsService.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/JwtUserDetailsService.java index 9e56781b6..aa9d5fdee 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/JwtUserDetailsService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/JwtUserDetailsService.java @@ -4,12 +4,12 @@ import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.User; import me.zhengjie.exception.EntityNotFoundException; +import me.zhengjie.modules.system.repository.PermissionRepository; +import me.zhengjie.modules.system.repository.RoleRepository; import me.zhengjie.modules.system.repository.UserRepository; import me.zhengjie.modules.security.security.JwtUser; import me.zhengjie.utils.ValidationUtil; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.Cacheable; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; @@ -33,6 +33,12 @@ public class JwtUserDetailsService implements UserDetailsService { @Autowired private UserRepository userRepository; + @Autowired + private RoleRepository roleRepository; + + @Autowired + private PermissionRepository permissionRepository; + @Override public UserDetails loadUserByUsername(String username){ @@ -57,20 +63,20 @@ public UserDetails create(User user) { user.getPassword(), user.getAvatar(), user.getEmail(), - mapToGrantedAuthorities(user.getRoles()), + mapToGrantedAuthorities(roleRepository.findByUsers_Id(user.getId()),permissionRepository), user.getEnabled(), user.getCreateTime(), user.getLastPasswordResetTime() ); } - private static List mapToGrantedAuthorities(Set roles) { + private static List mapToGrantedAuthorities(Set roles,PermissionRepository permissionRepository) { Set permissions = new HashSet<>(); for (Role role : roles) { Set roleSet = new HashSet<>(); roleSet.add(role); - permissions.addAll(role.getPermissions()); + permissions.addAll(permissionRepository.findByRoles_Id(role.getId())); } return permissions.stream() diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java index e23cb9197..fff4c54e0 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java @@ -1,10 +1,13 @@ package me.zhengjie.modules.system.domain; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; import org.hibernate.annotations.CreationTimestamp; import javax.persistence.*; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; import java.sql.Timestamp; import java.util.Set; @@ -16,10 +19,11 @@ @Getter @Setter @Table(name = "menu") -public class Menu { +public class Menu implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotNull(groups = {Update.class}) private Long id; @NotBlank @@ -47,11 +51,13 @@ public class Menu { @Column(name = "i_frame") private Boolean iFrame; - @ManyToMany - @JoinTable(name = "menus_roles", joinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}) + @ManyToMany(mappedBy = "menus") + @JsonIgnore private Set roles; @CreationTimestamp @Column(name = "create_time") private Timestamp createTime; + + public interface Update{} } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Permission.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Permission.java index 973dff12e..0be5a892c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Permission.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Permission.java @@ -4,7 +4,6 @@ import lombok.Getter; import lombok.Setter; import org.hibernate.annotations.CreationTimestamp; - import javax.persistence.*; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @@ -24,6 +23,7 @@ public class Permission implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotNull(groups = {Update.class}) private Long id; @NotBlank @@ -57,4 +57,6 @@ public String toString() { ", createTime=" + createTime + '}'; } + + public interface Update{} } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java index 00e3748ca..bb8e1d844 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java @@ -7,6 +7,7 @@ import javax.persistence.*; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.sql.Timestamp; import java.util.Set; @@ -24,6 +25,7 @@ public class Role implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotNull(groups = {Update.class}) private Long id; @Column(nullable = false) @@ -41,8 +43,8 @@ public class Role implements Serializable { @JoinTable(name = "roles_permissions", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "permission_id",referencedColumnName = "id")}) private Set permissions; - @JsonIgnore - @ManyToMany(mappedBy = "roles") + @ManyToMany + @JoinTable(name = "roles_menus", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "id")}) private Set menus; @CreationTimestamp @@ -58,4 +60,6 @@ public String toString() { ", createDateTime=" + createTime + '}'; } + + public interface Update{} } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java index d0f069883..66fff8ab9 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java @@ -25,6 +25,7 @@ public class User implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotNull(groups = Update.class) private Long id; @NotBlank @@ -65,4 +66,6 @@ public String toString() { ", lastPasswordResetTime=" + lastPasswordResetTime + '}'; } + + public @interface Update {} } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuMetaVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuMetaVo.java index 616734518..f465adb91 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuMetaVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuMetaVo.java @@ -3,13 +3,15 @@ import lombok.AllArgsConstructor; import lombok.Data; +import java.io.Serializable; + /** * @author jie * @date 2018-12-20 */ @Data @AllArgsConstructor -public class MenuMetaVo { +public class MenuMetaVo implements Serializable { private String title; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuVo.java index 72d70778d..1e7f80ac4 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuVo.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; +import java.io.Serializable; import java.util.List; /** @@ -12,7 +13,7 @@ */ @Data @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class MenuVo { +public class MenuVo implements Serializable { private String name; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java index 7a7efca27..86d255633 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java @@ -4,6 +4,9 @@ import me.zhengjie.modules.system.domain.Role; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +import java.util.Arrays; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -20,17 +23,12 @@ public interface MenuRepository extends JpaRepository, JpaSpecificat */ Menu findByName(String name); - /** - * findByRoles - * @param roleSet - * @return - */ - Set findByRolesOrderBySort(Set roleSet); - /** * findByPid * @param pid * @return */ List findByPid(long pid); + + LinkedHashSet findByRoles_IdOrderBySortAsc(Long id); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/PermissionRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/PermissionRepository.java index 937e44675..c37941e23 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/PermissionRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/PermissionRepository.java @@ -4,6 +4,8 @@ import me.zhengjie.modules.system.domain.Role; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +import java.util.Collection; import java.util.List; import java.util.Set; @@ -20,17 +22,12 @@ public interface PermissionRepository extends JpaRepository, J */ Permission findByName(String name); - /** - * findByRoles - * @param roleSet - * @return - */ - Set findByRoles(Set roleSet); - /** * findByPid * @param pid * @return */ List findByPid(long pid); + + Set findByRoles_Id(Long id); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java index 6979d6de6..fc41985a7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java @@ -4,6 +4,8 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import java.util.Set; + /** * @author jie * @date 2018-12-03 @@ -16,4 +18,6 @@ public interface RoleRepository extends JpaRepository, JpaSpecificat * @return */ Role findByName(String name); + + Set findByUsers_Id(Long id); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java index 42a518d1e..f0987c33e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java @@ -5,8 +5,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - import java.util.Date; /** @@ -20,16 +18,14 @@ public interface UserRepository extends JpaRepository, JpaSpecificat * @param username * @return */ - @Query("from User u join fetch u.roles where u.username = :username") - User findByUsername(@Param("username") String username); + User findByUsername(String username); /** * findByEmail * @param email * @return */ - @Query("from User u join fetch u.roles where u.email = :email") - User findByEmail(@Param("email") String email); + User findByEmail(String email); /** * 修改密码 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java index ac5640a6f..531477ae8 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java @@ -4,8 +4,8 @@ import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.User; import me.zhengjie.exception.BadRequestException; -import me.zhengjie.modules.security.utils.JwtTokenUtil; import me.zhengjie.modules.system.service.MenuService; +import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.dto.MenuDTO; import me.zhengjie.modules.system.service.query.MenuQueryService; @@ -17,7 +17,6 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; import java.util.List; /** @@ -28,9 +27,6 @@ @RequestMapping("api") public class MenuController { - @Autowired - private JwtTokenUtil jwtTokenUtil; - @Autowired private MenuService menuService; @@ -40,13 +36,10 @@ public class MenuController { @Autowired private UserService userService; - private static final String ENTITY_NAME = "menu"; + @Autowired + private RoleService roleService; - @GetMapping(value = "/menus/{id}") - @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')") - public ResponseEntity getMenus(@PathVariable Long id){ - return new ResponseEntity(menuService.findById(id), HttpStatus.OK); - } + private static final String ENTITY_NAME = "menu"; /** * 构建前端路由所需要的菜单 @@ -56,7 +49,7 @@ public ResponseEntity getMenus(@PathVariable Long id){ public ResponseEntity buildMenus(){ UserDetails userDetails = SecurityContextHolder.getUserDetails(); User user = userService.findByName(userDetails.getUsername()); - List menuDTOList = menuService.findByRoles(user.getRoles()); + List menuDTOList = menuService.findByRoles(roleService.findByUsers_Id(user.getId())); List menuDTOTree = (List)menuService.buildTree(menuDTOList).get("content"); return new ResponseEntity(menuService.buildMenus(menuDTOTree),HttpStatus.OK); } @@ -66,7 +59,7 @@ public ResponseEntity buildMenus(){ * @return */ @GetMapping(value = "/menus/tree") - @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')") + @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT','ROLES_SELECT','ROLES_ALL')") public ResponseEntity getMenuTree(){ return new ResponseEntity(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK); } @@ -92,10 +85,7 @@ public ResponseEntity create(@Validated @RequestBody Menu resources){ @Log("修改菜单") @PutMapping(value = "/menus") @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_EDIT')") - public ResponseEntity update(@Validated @RequestBody Menu resources){ - if (resources.getId() == null) { - throw new BadRequestException(ENTITY_NAME +" ID Can not be empty"); - } + public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Menu resources){ menuService.update(resources); return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/PermissionController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/PermissionController.java index aa89a7656..e0544dff7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/PermissionController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/PermissionController.java @@ -31,12 +31,6 @@ public class PermissionController { private static final String ENTITY_NAME = "permission"; - @GetMapping(value = "/permissions/{id}") - @PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')") - public ResponseEntity getPermissions(@PathVariable Long id){ - return new ResponseEntity(permissionService.findById(id), HttpStatus.OK); - } - /** * 返回全部的权限,新增角色时下拉选择 * @return @@ -68,10 +62,7 @@ public ResponseEntity create(@Validated @RequestBody Permission resources){ @Log("修改权限") @PutMapping(value = "/permissions") @PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_EDIT')") - public ResponseEntity update(@Validated @RequestBody Permission resources){ - if (resources.getId() == null) { - throw new BadRequestException(ENTITY_NAME +" ID Can not be empty"); - } + public ResponseEntity update(@Validated(Permission.Update.class) @RequestBody Permission resources){ permissionService.update(resources); return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java index 1dfb20907..cf1b3b0dc 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java @@ -41,7 +41,7 @@ public ResponseEntity getRoles(@PathVariable Long id){ * @return */ @GetMapping(value = "/roles/tree") - @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT','ROLES_ALL','USER_ALL','USER_SELECT')") + @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','USER_ALL','USER_SELECT')") public ResponseEntity getRoleTree(){ return new ResponseEntity(roleService.getRoleTree(),HttpStatus.OK); } @@ -66,14 +66,27 @@ public ResponseEntity create(@Validated @RequestBody Role resources){ @Log("修改角色") @PutMapping(value = "/roles") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')") - public ResponseEntity update(@Validated @RequestBody Role resources){ - if (resources.getId() == null) { - throw new BadRequestException(ENTITY_NAME +" ID Can not be empty"); - } + public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role resources){ roleService.update(resources); return new ResponseEntity(HttpStatus.NO_CONTENT); } + @Log("修改角色权限") + @PutMapping(value = "/roles/permission") + @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')") + public ResponseEntity updatePermission(@RequestBody Role resources){ + roleService.updatePermission(resources,roleService.findById(resources.getId())); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @Log("修改角色菜单") + @PutMapping(value = "/roles/menu") + @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')") + public ResponseEntity updateMenu(@RequestBody Role resources){ + roleService.updateMenu(resources,roleService.findById(resources.getId())); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + @Log("删除角色") @DeleteMapping(value = "/roles/{id}") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java index 97798d544..b8a5fe7c7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java @@ -59,12 +59,6 @@ public class UserController { private static final String ENTITY_NAME = "user"; - @GetMapping(value = "/users/{id}") - @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')") - public ResponseEntity getUser(@PathVariable Long id){ - return new ResponseEntity(userService.findById(id), HttpStatus.OK); - } - @Log("查询用户") @GetMapping(value = "/users") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')") @@ -85,10 +79,7 @@ public ResponseEntity create(@Validated @RequestBody User resources){ @Log("修改用户") @PutMapping(value = "/users") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_EDIT')") - public ResponseEntity update(@Validated @RequestBody User resources){ - if (resources.getId() == null) { - throw new BadRequestException(ENTITY_NAME +" ID Can not be empty"); - } + public ResponseEntity update(@Validated(User.Update.class) @RequestBody User resources){ userService.update(resources); return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java index ac11e50b6..4284e56ba 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java @@ -67,7 +67,6 @@ public interface MenuService { * @param menuDTOS * @return */ - @Cacheable(keyGenerator = "keyGenerator") Map buildTree(List menuDTOS); /** @@ -82,6 +81,5 @@ public interface MenuService { * @param byRoles * @return */ - @Cacheable(keyGenerator = "keyGenerator") Object buildMenus(List byRoles); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java index 6b42cc30b..8c399024a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java @@ -6,6 +6,8 @@ import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; +import java.util.Set; + /** * @author jie * @date 2018-12-03 @@ -49,4 +51,27 @@ public interface RoleService { */ @Cacheable(key = "'tree'") Object getRoleTree(); + + /** + * findByUsers_Id + * @param id + * @return + */ + Set findByUsers_Id(Long id); + + /** + * updatePermission + * @param resources + * @param roleDTO + */ + @CacheEvict(allEntries = true) + void updatePermission(Role resources, RoleDTO roleDTO); + + /** + * updateMenu + * @param resources + * @param roleDTO + */ + @CacheEvict(allEntries = true) + void updateMenu(Role resources, RoleDTO roleDTO); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java index d9eb33fb0..919646069 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java @@ -49,6 +49,7 @@ public interface UserService { * @param userName * @return */ + @Cacheable(keyGenerator = "keyGenerator") User findByName(String userName); /** diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuDTO.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuDTO.java index 02d6d1fc2..045ff6da5 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuDTO.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuDTO.java @@ -29,8 +29,6 @@ public class MenuDTO { private String icon; - private Set roles; - private List children; private Timestamp createTime; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDTO.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDTO.java index d21afadc7..98751fa1a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDTO.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDTO.java @@ -20,5 +20,7 @@ public class RoleDTO implements Serializable { private Set permissions; + private Set menus; + private Timestamp createTime; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java index e513bf65f..0b040e4f5 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java @@ -11,7 +11,6 @@ import me.zhengjie.modules.system.service.MenuService; import me.zhengjie.modules.system.service.dto.MenuDTO; import me.zhengjie.modules.system.service.mapper.MenuMapper; -import me.zhengjie.utils.ListSortUtil; import me.zhengjie.utils.ValidationUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -41,9 +40,7 @@ public MenuDTO findById(long id) { public List findByRoles(Set roles) { Set menus = new LinkedHashSet<>(); for (Role role : roles) { - ListSortUtil sortList = new ListSortUtil(); - List menus1 = role.getMenus().stream().collect(Collectors.toList()); - sortList.sort(menus1, "sort", "asc"); + List menus1 = menuRepository.findByRoles_IdOrderBySortAsc(role.getId()).stream().collect(Collectors.toList()); menus.addAll(menus1); } return menus.stream().map(menuMapper::toDto).collect(Collectors.toList()); @@ -85,7 +82,6 @@ public void update(Menu resources) { menu.setIFrame(resources.getIFrame()); menu.setPid(resources.getPid()); menu.setSort(resources.getSort()); - menu.setRoles(resources.getRoles()); menuRepository.save(menu); } @@ -141,11 +137,9 @@ public Map buildTree(List menuDTOS) { } } } - - Integer totalElements = menuDTOS!=null?menuDTOS.size():0; Map map = new HashMap(); map.put("content",trees.size() == 0?menuDTOS:trees); - map.put("totalElements",totalElements); + map.put("totalElements",menuDTOS!=null?menuDTOS.size():0); return map; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/PermissionServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/PermissionServiceImpl.java index b722e9a18..ecd357e95 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/PermissionServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/PermissionServiceImpl.java @@ -47,18 +47,19 @@ public PermissionDTO create(Permission resources) { @Override @Transactional(rollbackFor = Exception.class) public void update(Permission resources) { - Optional optionalPermission = permissionRepository.findById(resources.getId()); - ValidationUtil.isNull(optionalPermission,"Permission","id",resources.getId()); - - Permission permission = optionalPermission.get(); /** * 根据实际需求修改 */ - if(permission.getId().equals(1L)){ + if(resources.getId().equals(1L)){ throw new BadRequestException("该权限不能被修改"); } + Optional optionalPermission = permissionRepository.findById(resources.getId()); + ValidationUtil.isNull(optionalPermission,"Permission","id",resources.getId()); + + Permission permission = optionalPermission.get(); + Permission permission1 = permissionRepository.findByName(resources.getName()); if(permission1 != null && !permission1.getId().equals(permission.getId())){ @@ -80,6 +81,7 @@ public void delete(Long id) { if(id.equals(1L)){ throw new BadRequestException("该权限不能被删除"); } + List permissionList = permissionRepository.findByPid(id); for (Permission permission : permissionList) { permissionRepository.delete(permission); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java index e53afca11..2187a9039 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java @@ -47,18 +47,20 @@ public RoleDTO create(Role resources) { @Override @Transactional(rollbackFor = Exception.class) public void update(Role resources) { - Optional optionalRole = roleRepository.findById(resources.getId()); - ValidationUtil.isNull(optionalRole,"Role","id",resources.getId()); - - Role role = optionalRole.get(); /** * 根据实际需求修改 */ - if(role.getId().equals(1L)){ + if(resources.getId().equals(1L)){ throw new BadRequestException("该角色不能被修改"); } + + Optional optionalRole = roleRepository.findById(resources.getId()); + ValidationUtil.isNull(optionalRole,"Role","id",resources.getId()); + + Role role = optionalRole.get(); + Role role1 = roleRepository.findByName(resources.getName()); if(role1 != null && !role1.getId().equals(role.getId())){ @@ -67,14 +69,38 @@ public void update(Role resources) { role.setName(resources.getName()); role.setRemark(resources.getRemark()); + roleRepository.save(role); + } + + @Override + public void updatePermission(Role resources, RoleDTO roleDTO) { + /** + * 根据实际需求修改 + */ + if(resources.getId().equals(1L)){ + throw new BadRequestException("该角色不可操作"); + } + Role role = roleMapper.toEntity(roleDTO); role.setPermissions(resources.getPermissions()); roleRepository.save(role); } + @Override + public void updateMenu(Role resources, RoleDTO roleDTO) { + /** + * 根据实际需求修改 + */ + if(resources.getId().equals(1L)){ + throw new BadRequestException("该角色不可操作"); + } + Role role = roleMapper.toEntity(roleDTO); + role.setMenus(resources.getMenus()); + roleRepository.save(role); + } + @Override @Transactional(rollbackFor = Exception.class) public void delete(Long id) { - /** * 根据实际需求修改 */ @@ -98,4 +124,9 @@ public Object getRoleTree() { } return list; } + + @Override + public Set findByUsers_Id(Long id) { + return roleRepository.findByUsers_Id(id); + } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java index 0ea62bd3e..6b2d1edf3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java @@ -15,7 +15,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import java.util.Date; import java.util.Optional; @@ -59,7 +58,7 @@ public UserDTO create(User resources) { throw new BadRequestException("角色不能为空"); } - // 默认密码 123456 + // 默认密码 123456,此密码是 MD5加密后的字符 resources.setPassword("14e1b600b1fd579f47433b88e8d85291"); resources.setAvatar("https://i.loli.net/2018/12/06/5c08894d8de21.jpg"); return userMapper.toDto(userRepository.save(resources)); @@ -69,18 +68,18 @@ public UserDTO create(User resources) { @Transactional(rollbackFor = Exception.class) public void update(User resources) { - Optional userOptional = userRepository.findById(resources.getId()); - ValidationUtil.isNull(userOptional,"User","id",resources.getId()); - - User user = userOptional.get(); - /** * 根据实际需求修改 */ - if(user.getId().equals(1L)){ + if(resources.getId().equals(1L)){ throw new BadRequestException("该账号不能被修改"); } + Optional userOptional = userRepository.findById(resources.getId()); + ValidationUtil.isNull(userOptional,"User","id",resources.getId()); + + User user = userOptional.get(); + User user1 = userRepository.findByUsername(user.getUsername()); User user2 = userRepository.findByEmail(user.getEmail()); @@ -107,7 +106,6 @@ public void update(User resources) { @Override @Transactional(rollbackFor = Exception.class) public void delete(Long id) { - /** * 根据实际需求修改 */ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java index fc9362c7e..ca78dc46c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java @@ -10,7 +10,7 @@ * @author jie * @date 2018-12-17 */ -@Mapper(componentModel = "spring",uses = {RoleMapper.class},unmappedTargetPolicy = ReportingPolicy.IGNORE) +@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface MenuMapper extends EntityMapper { } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java index 822343267..fac2be299 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java @@ -10,7 +10,7 @@ * @author jie * @date 2018-11-23 */ -@Mapper(componentModel = "spring", uses = {PermissionMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE) +@Mapper(componentModel = "spring", uses = {PermissionMapper.class, MenuMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface RoleMapper extends EntityMapper { } diff --git a/eladmin-system/src/main/resources/template/email/email.ftl b/eladmin-system/src/main/resources/template/email/email.ftl index 6a636cf5c..3a1863582 100644 --- a/eladmin-system/src/main/resources/template/email/email.ftl +++ b/eladmin-system/src/main/resources/template/email/email.ftl @@ -34,7 +34,6 @@ maigin-bottom: 10px; font-size: 14px; color: #555;"> -

扣扣群:891137268

Github:https://github.com/elunez/eladmin

param = new LinkedMultiValueMap<>(); - param.add("smfile", resource); + HashMap paramMap = new HashMap<>(); - //设置头部,必须 - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); - headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"); + paramMap.put("smfile", file); + String result= HttpUtil.post(ElAdminConstant.Url.SM_MS_URL, paramMap); - HttpEntity> httpEntity = new HttpEntity>(param,headers); - ResponseEntity responseEntity = rest.exchange(ElAdminConstant.Url.SM_MS_URL, HttpMethod.POST, httpEntity, String.class); - - JSONObject jsonObject = JSONUtil.parseObj(responseEntity.getBody()); + JSONObject jsonObject = JSONUtil.parseObj(result); Picture picture = null; if(!jsonObject.get(CODE).toString().equals(SUCCESS)){ - throw new BadRequestException(jsonObject.get(MSG).toString()); + throw new BadRequestException(jsonObject.get(MSG).toString()); } //转成实体类 picture = JSON.parseObject(jsonObject.get("data").toString(), Picture.class); @@ -76,6 +63,7 @@ public Picture upload(MultipartFile multipartFile, String username) { //删除临时文件 FileUtil.deleteFile(file); return picture; + } @Override @@ -88,13 +76,9 @@ public Picture findById(Long id) { @Override @Transactional(rollbackFor = Exception.class) public void delete(Picture picture) { - RestTemplate rest = new RestTemplate(); try { - ResponseEntity str = rest.getForEntity(picture.getDelete(), String.class); - if(str.getStatusCode().is2xxSuccessful()){ - pictureRepository.delete(picture); - } - //如果删除的地址出错,直接删除数据库数据 + String result= HttpUtil.get(picture.getDelete()); + pictureRepository.delete(picture); } catch(Exception e){ pictureRepository.delete(picture); }