v1.6 版本发布 ,详情查看版本说明

pull/41/head
zhengjie 2019-02-28 16:31:18 +08:00
parent f63407fd81
commit 4e39694ea3
46 changed files with 350 additions and 434 deletions

View File

@ -109,7 +109,7 @@ eladmin-qt和eladmin-qd只是命名方式的区别无其他区别
<td><img src="https://i.loli.net/2018/12/22/5c1e10c7890ab.png"/></td> <td><img src="https://i.loli.net/2018/12/22/5c1e10c7890ab.png"/></td>
</tr> </tr>
<tr> <tr>
<td><img src="https://i.loli.net/2018/12/22/5c1e10c782a05.png"/></td> <td><img src="https://i.loli.net/2019/02/28/5c7795b707347.png"/></td>
<td><img src="https://i.loli.net/2018/12/22/5c1e10c7b089b.png"/></td> <td><img src="https://i.loli.net/2018/12/22/5c1e10c7b089b.png"/></td>
</tr> </tr>
<tr> <tr>

View File

@ -7,10 +7,10 @@ import me.zhengjie.exception.EntityNotFoundException;
import me.zhengjie.utils.ThrowableUtil; import me.zhengjie.utils.ThrowableUtil;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.nio.file.AccessDeniedException;
import static org.springframework.http.HttpStatus.*; import static org.springframework.http.HttpStatus.*;
/** /**

View File

@ -94,10 +94,9 @@ public class RedisConfig extends CachingConfigurerSupport {
// 全局开启AutoType不建议使用 // 全局开启AutoType不建议使用
// ParserConfig.getGlobalInstance().setAutoTypeSupport(true); // ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
// 建议使用这种方式,小范围指定白名单 // 建议使用这种方式,小范围指定白名单
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.domain");
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.system.service.dto");
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.system.domain");
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.quartz.domain"); ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.quartz.domain");
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.monitor.domain"); ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.monitor.domain");
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.security.security"); ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.security.security");

View File

@ -2,7 +2,6 @@ package me.zhengjie.swagger2;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.builders.ParameterBuilder;
@ -13,25 +12,17 @@ import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* api /swagger-ui.html * api /swagger-ui.html
* controller@ComponentScan(basePackages = {"me.aurora.app.rest","..."})
* @author jie * @author jie
* @date 2018-11-23 * @date 2018-11-23
*/ */
@Configuration @Configuration
@EnableSwagger2 @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 { public class SwaggerConfig {
@Bean @Bean

View File

@ -1,7 +1,6 @@
package me.zhengjie.utils; package me.zhengjie.utils;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory; import javax.crypto.SecretKeyFactory;

View File

@ -2,7 +2,6 @@ package me.zhengjie.utils;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;

View File

@ -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 <T>
*/
public class ListSortUtil<T> {
/**
* @param targetList List
* @param sortField ()
* @param sortMode asc or desc
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void sort(List<T> 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;
}
});
}
}

View File

@ -21,6 +21,12 @@
<groupId>me.zhengjie</groupId> <groupId>me.zhengjie</groupId>
<artifactId>eladmin-generator</artifactId> <artifactId>eladmin-generator</artifactId>
<version>1.5</version> <version>1.5</version>
<exclusions>
<exclusion>
<groupId>me.zhengjie</groupId>
<artifactId>eladmin-common</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -1,17 +1,17 @@
/* /*
Navicat MySQL Data Transfer Navicat Premium Data Transfer
Source Server : Source Server : localhost
Source Server Type : MySQL Source Server Type : MySQL
Source Server Version : 50559 Source Server Version : 50562
Source Host : localhost:3306 Source Host : localhost:3306
Source Schema : eladmin Source Schema : eladmin
Target Server Type : MySQL Target Server Type : MySQL
Target Server Version : 50559 Target Server Version : 50562
File Encoding : 65001 File Encoding : 65001
Date: 20/01/2019 19:17:08 Date: 27/02/2019 13:15:23
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -39,7 +39,7 @@ CREATE TABLE `alipay_config` (
-- ---------------------------- -- ----------------------------
-- Records of 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 -- Table structure for email_config
@ -73,25 +73,7 @@ CREATE TABLE `gen_config` (
-- ---------------------------- -- ----------------------------
-- Records of 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'); 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 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;
-- ---------------------------- -- ----------------------------
-- Table structure for menu -- Table structure for menu
@ -100,121 +82,46 @@ DROP TABLE IF EXISTS `menu`;
CREATE TABLE `menu` ( CREATE TABLE `menu` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建日期', `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 '菜单名称', `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 '组件', `component` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '组件',
`pid` bigint(20) NOT NULL COMMENT '上级菜单ID', `pid` bigint(20) NOT NULL COMMENT '上级菜单ID',
`sort` bigint(20) NOT NULL COMMENT '排序', `sort` bigint(20) NOT NULL COMMENT '排序',
`icon` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 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 '链接地址', `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 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 -- 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 (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', '用户管理', 'system/user/index', 1, 2, 'peoples', 'user', b'0'); 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', '角色管理', 'system/role/index', 1, 3, 'role', 'role', b'0'); 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', '权限管理', 'system/permission/index', 1, 4, 'permission', 'permission', b'0'); 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', '菜单管理', 'system/menu/index', 1, 5, 'menu', 'menu', b'0'); 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', '系统监控', NULL, 0, 10, 'monitor', 'monitor', b'0'); 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', '操作日志', 'monitor/log/index', 6, 11, 'log', 'logs', b'0'); 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', '系统缓存', 'monitor/redis/index', 6, 13, 'redis', 'redis', b'0'); 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', 'SQL监控', NULL, 6, 14, 'sqlMonitor', 'http://localhost:8000/druid', b'1'); 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', '组件管理', NULL, 0, 50, 'zujian', 'components', b'0'); 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', '图标库', 'components/IconSelect', 10, 51, 'icon', 'icon', b'0'); 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', '实时控制台', 'monitor/log/msg', 6, 15, 'codeConsole', 'msg', b'0'); 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', '三方工具', '', 0, 30, 'tools', 'tools', b'0'); 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', '邮件工具', 'tools/email/index', 13, 31, 'email', 'email', b'0'); 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', '富文本', 'components/Editor', 10, 52, 'fwb', 'tinymce', b'0'); 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', 'SM.MS图床', 'tools/picture/index', 13, 32, 'image', 'pictures', b'0'); 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', '项目地址', '', 0, 0, 'github', 'https://github.com/elunez/eladmin', b'1'); 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', '七牛云存储', 'tools/qiniu/index', 13, 33, 'qiniu', 'qiniu', b'0'); 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', '支付宝工具', 'tools/aliPay/index', 13, 34, 'alipay', 'aliPay', b'0'); 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', '多级菜单', '', 0, 900, 'menu', 'nested', b'0'); 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', '二级菜单1', 'nested/menu1/index', 21, 999, 'menu', 'menu1', b'0'); 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', '二级菜单2', 'nested/menu2/index', 21, 999, 'menu', 'menu2', b'0'); 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', '三级菜单1', 'nested/menu1/menu1-1', 22, 999, 'menu', 'menu1-1', b'0'); 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', '三级菜单2', 'nested/menu1/menu1-2', 22, 999, 'menu', 'menu1-2', b'0'); 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', '定时任务', 'system/timing/index', 1, 6, 'timing', 'timing', b'0'); 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', '代码生成', 'generator/index', 1, 8, 'dev', 'generator', b'0'); 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', '异常日志', 'monitor/log/errorLog', 6, 12, 'error', 'errorLog', b'0'); INSERT INTO `menu` VALUES (32, '2019-01-13 13:49:03', b'0', '异常日志', 'monitor/log/errorLog', 6, 12, 'error', 'errorLog');
-- ----------------------------
-- 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;
-- ---------------------------- -- ----------------------------
-- Table structure for permission -- 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 '用户名称', `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 '图片宽度', `width` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片宽度',
PRIMARY KEY (`id`) USING BTREE 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 -- Table structure for qiniu_config
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `qiniu_config`; DROP TABLE IF EXISTS `qiniu_config`;
@ -313,7 +219,7 @@ CREATE TABLE `qiniu_content` (
`update_time` datetime NULL DEFAULT NULL COMMENT '上传或同步的时间', `update_time` datetime NULL DEFAULT NULL COMMENT '上传或同步的时间',
`url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件url', `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件url',
PRIMARY KEY (`id`) USING BTREE 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 -- 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`; DROP TABLE IF EXISTS `quartz_log`;
CREATE TABLE `quartz_log` ( CREATE TABLE `quartz_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` bigint(20) NOT NULL AUTO_INCREMENT,
`baen_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'Spring Bean名称', `baen_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL COMMENT '创建日期', `create_time` datetime NULL DEFAULT NULL,
`cron_expression` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'cron 表达式', `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 COMMENT '异常详情', `exception_detail` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
`is_success` bit(1) NULL DEFAULT NULL COMMENT '运行状态1成功0异常', `is_success` bit(1) NULL DEFAULT NULL,
`job_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务名称', `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 COMMENT '方法名称', `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 COMMENT '参数', `params` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`time` bigint(20) NULL DEFAULT NULL COMMENT '耗时', `time` bigint(20) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE 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 -- Table structure for role
@ -367,13 +273,72 @@ CREATE TABLE `role` (
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称', `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 '备注', `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) USING BTREE 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 -- Records of role
-- ---------------------------- -- ----------------------------
INSERT INTO `role` VALUES (1, '2018-11-23 11:04:37', '超级管理员', '超级管理员'); 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 (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 -- Table structure for roles_permissions
@ -392,13 +357,15 @@ CREATE TABLE `roles_permissions` (
-- Records of roles_permissions -- Records of roles_permissions
-- ---------------------------- -- ----------------------------
INSERT INTO `roles_permissions` VALUES (1, 1); 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, 3);
INSERT INTO `roles_permissions` VALUES (2, 8); INSERT INTO `roles_permissions` VALUES (2, 4);
INSERT INTO `roles_permissions` VALUES (2, 14); INSERT INTO `roles_permissions` VALUES (2, 5);
INSERT INTO `roles_permissions` VALUES (2, 19); INSERT INTO `roles_permissions` VALUES (2, 6);
INSERT INTO `roles_permissions` VALUES (2, 23); INSERT INTO `roles_permissions` VALUES (2, 23);
INSERT INTO `roles_permissions` VALUES (2, 30); INSERT INTO `roles_permissions` VALUES (2, 24);
INSERT INTO `roles_permissions` VALUES (2, 36); INSERT INTO `roles_permissions` VALUES (2, 25);
INSERT INTO `roles_permissions` VALUES (2, 26);
-- ---------------------------- -- ----------------------------
-- Table structure for user -- 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 '接收邮箱或者手机号码', `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 '业务名称:如重置邮箱、重置密码等', `scenes` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务名称:如重置邮箱、重置密码等',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 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 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;

View File

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/** /**
* @author jie * @author jie
@ -13,7 +14,7 @@ import javax.validation.constraints.NotBlank;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class RedisVo { public class RedisVo implements Serializable {
@NotBlank @NotBlank
private String key; private String key;

View File

@ -5,6 +5,7 @@ import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -21,6 +22,7 @@ public class QuartzJob implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = {Update.class})
private Long id; private Long id;
/** /**
@ -75,4 +77,6 @@ public class QuartzJob implements Serializable {
@UpdateTimestamp @UpdateTimestamp
@Column(name = "update_time") @Column(name = "update_time")
private Timestamp updateTime; private Timestamp updateTime;
public interface Update{}
} }

View File

@ -68,10 +68,7 @@ public class QuartzJobController {
@Log("修改定时任务") @Log("修改定时任务")
@PutMapping(value = "/jobs") @PutMapping(value = "/jobs")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')")
public ResponseEntity update(@Validated @RequestBody QuartzJob resources){ public ResponseEntity update(@Validated(QuartzJob.Update.class) @RequestBody QuartzJob resources){
if (resources.getId() == null) {
throw new BadRequestException(ENTITY_NAME +" ID Can not be empty");
}
quartzJobService.update(resources); quartzJobService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }

View File

@ -41,7 +41,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
private String tokenHeader; private String tokenHeader;
@Value("${jwt.auth.path}") @Value("${jwt.auth.path}")
private String authenticationPath; private String loginPath;
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
@ -74,9 +74,18 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// 不创建会话 // 不创建会话
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .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("/websocket/**").permitAll()
.antMatchers("/druid/**").anonymous() .antMatchers("/druid/**").anonymous()
@ -91,33 +100,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/*/api-docs").anonymous() .antMatchers("/*/api-docs").anonymous()
// swagger end // swagger end
// 接口限流测试
.antMatchers("/test/**").anonymous() .antMatchers("/test/**").anonymous()
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous() .antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
// 所有请求都需要认证 // 所有请求都需要认证
.anyRequest().authenticated(); .anyRequest().authenticated();
httpSecurity httpSecurity
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); .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"
);
}
} }

View File

@ -2,7 +2,7 @@ package me.zhengjie.modules.security.rest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.zhengjie.aop.log.Log; 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.AuthorizationUser;
import me.zhengjie.modules.security.security.JwtUser; import me.zhengjie.modules.security.security.JwtUser;
import me.zhengjie.utils.EncryptUtils; import me.zhengjie.utils.EncryptUtils;
@ -47,21 +47,21 @@ public class AuthenticationController {
@PostMapping(value = "${jwt.auth.path}") @PostMapping(value = "${jwt.auth.path}")
public ResponseEntity login(@Validated @RequestBody AuthorizationUser authorizationUser){ 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("密码错误"); throw new AccountExpiredException("密码错误");
} }
if(!userDetails.isEnabled()){ if(!jwtUser.isEnabled()){
throw new AccountExpiredException("账号已停用,请联系管理员"); throw new AccountExpiredException("账号已停用,请联系管理员");
} }
// 生成令牌 // 生成令牌
final String token = jwtTokenUtil.generateToken(userDetails); final String token = jwtTokenUtil.generateToken(jwtUser);
// 返回 token // 返回 token
return ResponseEntity.ok(new AuthenticationToken(token)); return ResponseEntity.ok(new AuthenticationInfo(token,jwtUser));
} }
/** /**

View File

@ -1,18 +1,19 @@
package me.zhengjie.modules.security.security; package me.zhengjie.modules.security.security;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import java.io.Serializable;
import java.io.Serializable;
/**
/** * @author jie
* @author jie * @date 2018-11-23
* @date 2018-11-23 * token
* token */
*/ @Getter
@Getter @AllArgsConstructor
@AllArgsConstructor public class AuthenticationInfo implements Serializable {
public class AuthenticationToken implements Serializable {
private final String token;
private final String token;
} private final JwtUser user;
}

View File

@ -4,12 +4,12 @@ import me.zhengjie.modules.system.domain.Permission;
import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.domain.User;
import me.zhengjie.exception.EntityNotFoundException; 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.system.repository.UserRepository;
import me.zhengjie.modules.security.security.JwtUser; import me.zhengjie.modules.security.security.JwtUser;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired; 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.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
@ -33,6 +33,12 @@ public class JwtUserDetailsService implements UserDetailsService {
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;
@Autowired
private RoleRepository roleRepository;
@Autowired
private PermissionRepository permissionRepository;
@Override @Override
public UserDetails loadUserByUsername(String username){ public UserDetails loadUserByUsername(String username){
@ -57,20 +63,20 @@ public class JwtUserDetailsService implements UserDetailsService {
user.getPassword(), user.getPassword(),
user.getAvatar(), user.getAvatar(),
user.getEmail(), user.getEmail(),
mapToGrantedAuthorities(user.getRoles()), mapToGrantedAuthorities(roleRepository.findByUsers_Id(user.getId()),permissionRepository),
user.getEnabled(), user.getEnabled(),
user.getCreateTime(), user.getCreateTime(),
user.getLastPasswordResetTime() user.getLastPasswordResetTime()
); );
} }
private static List<GrantedAuthority> mapToGrantedAuthorities(Set<Role> roles) { private static List<GrantedAuthority> mapToGrantedAuthorities(Set<Role> roles,PermissionRepository permissionRepository) {
Set<Permission> permissions = new HashSet<>(); Set<Permission> permissions = new HashSet<>();
for (Role role : roles) { for (Role role : roles) {
Set<Role> roleSet = new HashSet<>(); Set<Role> roleSet = new HashSet<>();
roleSet.add(role); roleSet.add(role);
permissions.addAll(role.getPermissions()); permissions.addAll(permissionRepository.findByRoles_Id(role.getId()));
} }
return permissions.stream() return permissions.stream()

View File

@ -1,10 +1,13 @@
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Set; import java.util.Set;
@ -16,10 +19,11 @@ import java.util.Set;
@Getter @Getter
@Setter @Setter
@Table(name = "menu") @Table(name = "menu")
public class Menu { public class Menu implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = {Update.class})
private Long id; private Long id;
@NotBlank @NotBlank
@ -47,11 +51,13 @@ public class Menu {
@Column(name = "i_frame") @Column(name = "i_frame")
private Boolean iFrame; private Boolean iFrame;
@ManyToMany @ManyToMany(mappedBy = "menus")
@JoinTable(name = "menus_roles", joinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}) @JsonIgnore
private Set<Role> roles; private Set<Role> roles;
@CreationTimestamp @CreationTimestamp
@Column(name = "create_time") @Column(name = "create_time")
private Timestamp createTime; private Timestamp createTime;
public interface Update{}
} }

View File

@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -24,6 +23,7 @@ public class Permission implements Serializable{
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = {Update.class})
private Long id; private Long id;
@NotBlank @NotBlank
@ -57,4 +57,6 @@ public class Permission implements Serializable{
", createTime=" + createTime + ", createTime=" + createTime +
'}'; '}';
} }
public interface Update{}
} }

View File

@ -7,6 +7,7 @@ import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Set; import java.util.Set;
@ -24,6 +25,7 @@ public class Role implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = {Update.class})
private Long id; private Long id;
@Column(nullable = false) @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")}) @JoinTable(name = "roles_permissions", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "permission_id",referencedColumnName = "id")})
private Set<Permission> permissions; private Set<Permission> permissions;
@JsonIgnore @ManyToMany
@ManyToMany(mappedBy = "roles") @JoinTable(name = "roles_menus", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "id")})
private Set<Menu> menus; private Set<Menu> menus;
@CreationTimestamp @CreationTimestamp
@ -58,4 +60,6 @@ public class Role implements Serializable {
", createDateTime=" + createTime + ", createDateTime=" + createTime +
'}'; '}';
} }
public interface Update{}
} }

View File

@ -25,6 +25,7 @@ public class User implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = Update.class)
private Long id; private Long id;
@NotBlank @NotBlank
@ -65,4 +66,6 @@ public class User implements Serializable {
", lastPasswordResetTime=" + lastPasswordResetTime + ", lastPasswordResetTime=" + lastPasswordResetTime +
'}'; '}';
} }
public @interface Update {}
} }

View File

@ -3,13 +3,15 @@ package me.zhengjie.modules.system.domain.vo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
/** /**
* @author jie * @author jie
* @date 2018-12-20 * @date 2018-12-20
*/ */
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class MenuMetaVo { public class MenuMetaVo implements Serializable {
private String title; private String title;

View File

@ -3,6 +3,7 @@ package me.zhengjie.modules.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@ -12,7 +13,7 @@ import java.util.List;
*/ */
@Data @Data
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public class MenuVo { public class MenuVo implements Serializable {
private String name; private String name;

View File

@ -4,6 +4,9 @@ import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.Role;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -20,17 +23,12 @@ public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificat
*/ */
Menu findByName(String name); Menu findByName(String name);
/**
* findByRoles
* @param roleSet
* @return
*/
Set<Menu> findByRolesOrderBySort(Set<Role> roleSet);
/** /**
* findByPid * findByPid
* @param pid * @param pid
* @return * @return
*/ */
List<Menu> findByPid(long pid); List<Menu> findByPid(long pid);
LinkedHashSet<Menu> findByRoles_IdOrderBySortAsc(Long id);
} }

View File

@ -4,6 +4,8 @@ import me.zhengjie.modules.system.domain.Permission;
import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.Role;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -20,17 +22,12 @@ public interface PermissionRepository extends JpaRepository<Permission, Long>, J
*/ */
Permission findByName(String name); Permission findByName(String name);
/**
* findByRoles
* @param roleSet
* @return
*/
Set<Permission> findByRoles(Set<Role> roleSet);
/** /**
* findByPid * findByPid
* @param pid * @param pid
* @return * @return
*/ */
List<Permission> findByPid(long pid); List<Permission> findByPid(long pid);
Set<Permission> findByRoles_Id(Long id);
} }

View File

@ -4,6 +4,8 @@ import me.zhengjie.modules.system.domain.Role;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Set;
/** /**
* @author jie * @author jie
* @date 2018-12-03 * @date 2018-12-03
@ -16,4 +18,6 @@ public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificat
* @return * @return
*/ */
Role findByName(String name); Role findByName(String name);
Set<Role> findByUsers_Id(Long id);
} }

View File

@ -5,8 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.Date; import java.util.Date;
/** /**
@ -20,16 +18,14 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
* @param username * @param username
* @return * @return
*/ */
@Query("from User u join fetch u.roles where u.username = :username") User findByUsername(String username);
User findByUsername(@Param("username") String username);
/** /**
* findByEmail * findByEmail
* @param email * @param email
* @return * @return
*/ */
@Query("from User u join fetch u.roles where u.email = :email") User findByEmail(String email);
User findByEmail(@Param("email") String email);
/** /**
* *

View File

@ -4,8 +4,8 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.domain.User;
import me.zhengjie.exception.BadRequestException; 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.MenuService;
import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.MenuDTO; import me.zhengjie.modules.system.service.dto.MenuDTO;
import me.zhengjie.modules.system.service.query.MenuQueryService; import me.zhengjie.modules.system.service.query.MenuQueryService;
@ -17,7 +17,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
/** /**
@ -28,9 +27,6 @@ import java.util.List;
@RequestMapping("api") @RequestMapping("api")
public class MenuController { public class MenuController {
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Autowired @Autowired
private MenuService menuService; private MenuService menuService;
@ -40,13 +36,10 @@ public class MenuController {
@Autowired @Autowired
private UserService userService; private UserService userService;
private static final String ENTITY_NAME = "menu"; @Autowired
private RoleService roleService;
@GetMapping(value = "/menus/{id}") private static final String ENTITY_NAME = "menu";
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')")
public ResponseEntity getMenus(@PathVariable Long id){
return new ResponseEntity(menuService.findById(id), HttpStatus.OK);
}
/** /**
* *
@ -56,7 +49,7 @@ public class MenuController {
public ResponseEntity buildMenus(){ public ResponseEntity buildMenus(){
UserDetails userDetails = SecurityContextHolder.getUserDetails(); UserDetails userDetails = SecurityContextHolder.getUserDetails();
User user = userService.findByName(userDetails.getUsername()); User user = userService.findByName(userDetails.getUsername());
List<MenuDTO> menuDTOList = menuService.findByRoles(user.getRoles()); List<MenuDTO> menuDTOList = menuService.findByRoles(roleService.findByUsers_Id(user.getId()));
List<MenuDTO> menuDTOTree = (List<MenuDTO>)menuService.buildTree(menuDTOList).get("content"); List<MenuDTO> menuDTOTree = (List<MenuDTO>)menuService.buildTree(menuDTOList).get("content");
return new ResponseEntity(menuService.buildMenus(menuDTOTree),HttpStatus.OK); return new ResponseEntity(menuService.buildMenus(menuDTOTree),HttpStatus.OK);
} }
@ -66,7 +59,7 @@ public class MenuController {
* @return * @return
*/ */
@GetMapping(value = "/menus/tree") @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(){ public ResponseEntity getMenuTree(){
return new ResponseEntity(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK); return new ResponseEntity(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK);
} }
@ -92,10 +85,7 @@ public class MenuController {
@Log("修改菜单") @Log("修改菜单")
@PutMapping(value = "/menus") @PutMapping(value = "/menus")
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_EDIT')")
public ResponseEntity update(@Validated @RequestBody Menu resources){ public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Menu resources){
if (resources.getId() == null) {
throw new BadRequestException(ENTITY_NAME +" ID Can not be empty");
}
menuService.update(resources); menuService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }

View File

@ -31,12 +31,6 @@ public class PermissionController {
private static final String ENTITY_NAME = "permission"; 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 * @return
@ -68,10 +62,7 @@ public class PermissionController {
@Log("修改权限") @Log("修改权限")
@PutMapping(value = "/permissions") @PutMapping(value = "/permissions")
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_EDIT')")
public ResponseEntity update(@Validated @RequestBody Permission resources){ public ResponseEntity update(@Validated(Permission.Update.class) @RequestBody Permission resources){
if (resources.getId() == null) {
throw new BadRequestException(ENTITY_NAME +" ID Can not be empty");
}
permissionService.update(resources); permissionService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }

View File

@ -41,7 +41,7 @@ public class RoleController {
* @return * @return
*/ */
@GetMapping(value = "/roles/tree") @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(){ public ResponseEntity getRoleTree(){
return new ResponseEntity(roleService.getRoleTree(),HttpStatus.OK); return new ResponseEntity(roleService.getRoleTree(),HttpStatus.OK);
} }
@ -66,14 +66,27 @@ public class RoleController {
@Log("修改角色") @Log("修改角色")
@PutMapping(value = "/roles") @PutMapping(value = "/roles")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')")
public ResponseEntity update(@Validated @RequestBody Role resources){ public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role resources){
if (resources.getId() == null) {
throw new BadRequestException(ENTITY_NAME +" ID Can not be empty");
}
roleService.update(resources); roleService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT); 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("删除角色") @Log("删除角色")
@DeleteMapping(value = "/roles/{id}") @DeleteMapping(value = "/roles/{id}")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')")

View File

@ -59,12 +59,6 @@ public class UserController {
private static final String ENTITY_NAME = "user"; 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("查询用户") @Log("查询用户")
@GetMapping(value = "/users") @GetMapping(value = "/users")
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')")
@ -85,10 +79,7 @@ public class UserController {
@Log("修改用户") @Log("修改用户")
@PutMapping(value = "/users") @PutMapping(value = "/users")
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_EDIT')")
public ResponseEntity update(@Validated @RequestBody User resources){ public ResponseEntity update(@Validated(User.Update.class) @RequestBody User resources){
if (resources.getId() == null) {
throw new BadRequestException(ENTITY_NAME +" ID Can not be empty");
}
userService.update(resources); userService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }

View File

@ -67,7 +67,6 @@ public interface MenuService {
* @param menuDTOS * @param menuDTOS
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator")
Map buildTree(List<MenuDTO> menuDTOS); Map buildTree(List<MenuDTO> menuDTOS);
/** /**
@ -82,6 +81,5 @@ public interface MenuService {
* @param byRoles * @param byRoles
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator")
Object buildMenus(List<MenuDTO> byRoles); Object buildMenus(List<MenuDTO> byRoles);
} }

View File

@ -6,6 +6,8 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import java.util.Set;
/** /**
* @author jie * @author jie
* @date 2018-12-03 * @date 2018-12-03
@ -49,4 +51,27 @@ public interface RoleService {
*/ */
@Cacheable(key = "'tree'") @Cacheable(key = "'tree'")
Object getRoleTree(); Object getRoleTree();
/**
* findByUsers_Id
* @param id
* @return
*/
Set<Role> 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);
} }

View File

@ -49,6 +49,7 @@ public interface UserService {
* @param userName * @param userName
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator")
User findByName(String userName); User findByName(String userName);
/** /**

View File

@ -29,8 +29,6 @@ public class MenuDTO {
private String icon; private String icon;
private Set<RoleDTO> roles;
private List<MenuDTO> children; private List<MenuDTO> children;
private Timestamp createTime; private Timestamp createTime;

View File

@ -20,5 +20,7 @@ public class RoleDTO implements Serializable {
private Set<PermissionDTO> permissions; private Set<PermissionDTO> permissions;
private Set<MenuDTO> menus;
private Timestamp createTime; private Timestamp createTime;
} }

View File

@ -11,7 +11,6 @@ import me.zhengjie.modules.system.repository.MenuRepository;
import me.zhengjie.modules.system.service.MenuService; import me.zhengjie.modules.system.service.MenuService;
import me.zhengjie.modules.system.service.dto.MenuDTO; import me.zhengjie.modules.system.service.dto.MenuDTO;
import me.zhengjie.modules.system.service.mapper.MenuMapper; import me.zhengjie.modules.system.service.mapper.MenuMapper;
import me.zhengjie.utils.ListSortUtil;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -41,9 +40,7 @@ public class MenuServiceImpl implements MenuService {
public List<MenuDTO> findByRoles(Set<Role> roles) { public List<MenuDTO> findByRoles(Set<Role> roles) {
Set<Menu> menus = new LinkedHashSet<>(); Set<Menu> menus = new LinkedHashSet<>();
for (Role role : roles) { for (Role role : roles) {
ListSortUtil<Menu> sortList = new ListSortUtil<Menu>(); List<Menu> menus1 = menuRepository.findByRoles_IdOrderBySortAsc(role.getId()).stream().collect(Collectors.toList());
List<Menu> menus1 = role.getMenus().stream().collect(Collectors.toList());
sortList.sort(menus1, "sort", "asc");
menus.addAll(menus1); menus.addAll(menus1);
} }
return menus.stream().map(menuMapper::toDto).collect(Collectors.toList()); return menus.stream().map(menuMapper::toDto).collect(Collectors.toList());
@ -85,7 +82,6 @@ public class MenuServiceImpl implements MenuService {
menu.setIFrame(resources.getIFrame()); menu.setIFrame(resources.getIFrame());
menu.setPid(resources.getPid()); menu.setPid(resources.getPid());
menu.setSort(resources.getSort()); menu.setSort(resources.getSort());
menu.setRoles(resources.getRoles());
menuRepository.save(menu); menuRepository.save(menu);
} }
@ -141,11 +137,9 @@ public class MenuServiceImpl implements MenuService {
} }
} }
} }
Integer totalElements = menuDTOS!=null?menuDTOS.size():0;
Map map = new HashMap(); Map map = new HashMap();
map.put("content",trees.size() == 0?menuDTOS:trees); map.put("content",trees.size() == 0?menuDTOS:trees);
map.put("totalElements",totalElements); map.put("totalElements",menuDTOS!=null?menuDTOS.size():0);
return map; return map;
} }

View File

@ -47,18 +47,19 @@ public class PermissionServiceImpl implements PermissionService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(Permission resources) { public void update(Permission resources) {
Optional<Permission> 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("该权限不能被修改"); throw new BadRequestException("该权限不能被修改");
} }
Optional<Permission> optionalPermission = permissionRepository.findById(resources.getId());
ValidationUtil.isNull(optionalPermission,"Permission","id",resources.getId());
Permission permission = optionalPermission.get();
Permission permission1 = permissionRepository.findByName(resources.getName()); Permission permission1 = permissionRepository.findByName(resources.getName());
if(permission1 != null && !permission1.getId().equals(permission.getId())){ if(permission1 != null && !permission1.getId().equals(permission.getId())){
@ -80,6 +81,7 @@ public class PermissionServiceImpl implements PermissionService {
if(id.equals(1L)){ if(id.equals(1L)){
throw new BadRequestException("该权限不能被删除"); throw new BadRequestException("该权限不能被删除");
} }
List<Permission> permissionList = permissionRepository.findByPid(id); List<Permission> permissionList = permissionRepository.findByPid(id);
for (Permission permission : permissionList) { for (Permission permission : permissionList) {
permissionRepository.delete(permission); permissionRepository.delete(permission);

View File

@ -47,18 +47,20 @@ public class RoleServiceImpl implements RoleService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(Role resources) { public void update(Role resources) {
Optional<Role> 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("该角色不能被修改"); throw new BadRequestException("该角色不能被修改");
} }
Optional<Role> optionalRole = roleRepository.findById(resources.getId());
ValidationUtil.isNull(optionalRole,"Role","id",resources.getId());
Role role = optionalRole.get();
Role role1 = roleRepository.findByName(resources.getName()); Role role1 = roleRepository.findByName(resources.getName());
if(role1 != null && !role1.getId().equals(role.getId())){ if(role1 != null && !role1.getId().equals(role.getId())){
@ -67,14 +69,38 @@ public class RoleServiceImpl implements RoleService {
role.setName(resources.getName()); role.setName(resources.getName());
role.setRemark(resources.getRemark()); 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()); role.setPermissions(resources.getPermissions());
roleRepository.save(role); 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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delete(Long id) { public void delete(Long id) {
/** /**
* *
*/ */
@ -98,4 +124,9 @@ public class RoleServiceImpl implements RoleService {
} }
return list; return list;
} }
@Override
public Set<Role> findByUsers_Id(Long id) {
return roleRepository.findByUsers_Id(id);
}
} }

View File

@ -15,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.Date;
import java.util.Optional; import java.util.Optional;
@ -59,7 +58,7 @@ public class UserServiceImpl implements UserService {
throw new BadRequestException("角色不能为空"); throw new BadRequestException("角色不能为空");
} }
// 默认密码 123456 // 默认密码 123456,此密码是 MD5加密后的字符
resources.setPassword("14e1b600b1fd579f47433b88e8d85291"); resources.setPassword("14e1b600b1fd579f47433b88e8d85291");
resources.setAvatar("https://i.loli.net/2018/12/06/5c08894d8de21.jpg"); resources.setAvatar("https://i.loli.net/2018/12/06/5c08894d8de21.jpg");
return userMapper.toDto(userRepository.save(resources)); return userMapper.toDto(userRepository.save(resources));
@ -69,18 +68,18 @@ public class UserServiceImpl implements UserService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(User resources) { public void update(User resources) {
/**
*
*/
if(resources.getId().equals(1L)){
throw new BadRequestException("该账号不能被修改");
}
Optional<User> userOptional = userRepository.findById(resources.getId()); Optional<User> userOptional = userRepository.findById(resources.getId());
ValidationUtil.isNull(userOptional,"User","id",resources.getId()); ValidationUtil.isNull(userOptional,"User","id",resources.getId());
User user = userOptional.get(); User user = userOptional.get();
/**
*
*/
if(user.getId().equals(1L)){
throw new BadRequestException("该账号不能被修改");
}
User user1 = userRepository.findByUsername(user.getUsername()); User user1 = userRepository.findByUsername(user.getUsername());
User user2 = userRepository.findByEmail(user.getEmail()); User user2 = userRepository.findByEmail(user.getEmail());
@ -107,7 +106,6 @@ public class UserServiceImpl implements UserService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delete(Long id) { public void delete(Long id) {
/** /**
* *
*/ */

View File

@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author jie * @author jie
* @date 2018-12-17 * @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<MenuDTO, Menu> { public interface MenuMapper extends EntityMapper<MenuDTO, Menu> {
} }

View File

@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author jie * @author jie
* @date 2018-11-23 * @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<RoleDTO, Role> { public interface RoleMapper extends EntityMapper<RoleDTO, Role> {
} }

View File

@ -34,7 +34,6 @@
maigin-bottom: 10px; maigin-bottom: 10px;
font-size: 14px; font-size: 14px;
color: #555;"> color: #555;">
<p style="line-height: 12px;">扣扣群891137268</p>
<p style="line-height: 12px;">Github<a hover="color: #DA251D;" style="color: #999;" href="https://github.com/elunez/eladmin" target="_blank">https://github.com/elunez/eladmin</a></p> <p style="line-height: 12px;">Github<a hover="color: #DA251D;" style="color: #999;" href="https://github.com/elunez/eladmin" target="_blank">https://github.com/elunez/eladmin</a></p>
</div> </div>
<div class="foot-hr hr" style="margin: 0 auto; <div class="foot-hr hr" style="margin: 0 auto;

View File

@ -30,12 +30,6 @@ public class ${className}Controller {
private static final String ENTITY_NAME = "${changeClassName}"; private static final String ENTITY_NAME = "${changeClassName}";
@GetMapping(value = "/${changeClassName}/{id}")
@PreAuthorize("hasAnyRole('ADMIN')")
public ResponseEntity get${className}(@PathVariable ${pkColumnType} id){
return new ResponseEntity(${changeClassName}Service.findById(id), HttpStatus.OK);
}
@Log("查询${className}") @Log("查询${className}")
@GetMapping(value = "/${changeClassName}") @GetMapping(value = "/${changeClassName}")
@PreAuthorize("hasAnyRole('ADMIN')") @PreAuthorize("hasAnyRole('ADMIN')")

View File

@ -3,7 +3,6 @@ package me.zhengjie.config;
import org.springframework.boot.web.servlet.MultipartConfigFactory; import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.servlet.MultipartConfigElement; import javax.servlet.MultipartConfigElement;
import java.io.File; import java.io.File;
@ -20,7 +19,7 @@ public class MultipartConfig {
@Bean @Bean
MultipartConfigElement multipartConfigElement() { MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory(); MultipartConfigFactory factory = new MultipartConfigFactory();
String location = System.getProperty("user.dir") + "target/file/tmp"; String location = System.getProperty("user.home") + "/.eladmin/file/tmp";
File tmpFile = new File(location); File tmpFile = new File(location);
if (!tmpFile.exists()) { if (!tmpFile.exists()) {
tmpFile.mkdirs(); tmpFile.mkdirs();

View File

@ -60,8 +60,8 @@ public class QiniuController {
public ResponseEntity upload(@RequestParam MultipartFile file){ public ResponseEntity upload(@RequestParam MultipartFile file){
QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find()); QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find());
Map map = new HashMap(); Map map = new HashMap();
map.put("errno",0);
map.put("id",qiniuContent.getId()); map.put("id",qiniuContent.getId());
map.put("errno",0);
map.put("data",new String[]{qiniuContent.getUrl()}); map.put("data",new String[]{qiniuContent.getUrl()});
return new ResponseEntity(map,HttpStatus.OK); return new ResponseEntity(map,HttpStatus.OK);
} }

View File

@ -1,5 +1,6 @@
package me.zhengjie.service.impl; package me.zhengjie.service.impl;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@ -12,17 +13,12 @@ import me.zhengjie.utils.ElAdminConstant;
import me.zhengjie.utils.FileUtil; import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.HashMap;
import java.util.Optional; import java.util.Optional;
/** /**
@ -47,25 +43,16 @@ public class PictureServiceImpl implements PictureService {
@Transactional(rollbackFor = Throwable.class) @Transactional(rollbackFor = Throwable.class)
public Picture upload(MultipartFile multipartFile, String username) { public Picture upload(MultipartFile multipartFile, String username) {
File file = FileUtil.toFile(multipartFile); File file = FileUtil.toFile(multipartFile);
//将参数合成一个请求
RestTemplate rest = new RestTemplate();
FileSystemResource resource = new FileSystemResource(file); HashMap<String, Object> paramMap = new HashMap<>();
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
param.add("smfile", resource);
//设置头部,必须 paramMap.put("smfile", file);
HttpHeaders headers = new HttpHeaders(); String result= HttpUtil.post(ElAdminConstant.Url.SM_MS_URL, paramMap);
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");
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<MultiValueMap<String, Object>>(param,headers); JSONObject jsonObject = JSONUtil.parseObj(result);
ResponseEntity<String> responseEntity = rest.exchange(ElAdminConstant.Url.SM_MS_URL, HttpMethod.POST, httpEntity, String.class);
JSONObject jsonObject = JSONUtil.parseObj(responseEntity.getBody());
Picture picture = null; Picture picture = null;
if(!jsonObject.get(CODE).toString().equals(SUCCESS)){ 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); picture = JSON.parseObject(jsonObject.get("data").toString(), Picture.class);
@ -76,6 +63,7 @@ public class PictureServiceImpl implements PictureService {
//删除临时文件 //删除临时文件
FileUtil.deleteFile(file); FileUtil.deleteFile(file);
return picture; return picture;
} }
@Override @Override
@ -88,13 +76,9 @@ public class PictureServiceImpl implements PictureService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delete(Picture picture) { public void delete(Picture picture) {
RestTemplate rest = new RestTemplate();
try { try {
ResponseEntity<String> str = rest.getForEntity(picture.getDelete(), String.class); String result= HttpUtil.get(picture.getDelete());
if(str.getStatusCode().is2xxSuccessful()){ pictureRepository.delete(picture);
pictureRepository.delete(picture);
}
//如果删除的地址出错,直接删除数据库数据
} catch(Exception e){ } catch(Exception e){
pictureRepository.delete(picture); pictureRepository.delete(picture);
} }