From 837f23080b0cb1d2f055229e040b355fab53e3e5 Mon Sep 17 00:00:00 2001 From: "luoqiangzheng@hz-cpp.com" Date: Mon, 14 Mar 2022 15:05:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eladmin-common/pom.xml | 2 +- .../me/zhengjie/config/SwaggerConfig.java | 16 ++-- .../me/zhengjie/utils/ValidationUtil.java | 17 ++-- .../java/me/zhengjie/utils/DateUtilsTest.java | 2 +- .../me/zhengjie/utils/EncryptUtilsTest.java | 5 +- .../java/me/zhengjie/utils/FileUtilTest.java | 4 +- .../me/zhengjie/utils/StringUtilsTest.java | 15 ++-- eladmin-generator/pom.xml | 2 +- eladmin-system/pom.xml | 4 +- .../me/zhengjie/config/ConfigurerAdapter.java | 2 +- .../service/impl/MonitorServiceImpl.java | 5 +- eladmin-system/src/main/resources/banner.txt | 2 +- .../EladminSystemApplicationTests.java | 5 +- .../test/java/me/zhengjie/LoginCacheTest.java | 90 +++++++++---------- eladmin-tools/pom.xml | 6 +- pom.xml | 54 ++++------- 16 files changed, 107 insertions(+), 124 deletions(-) diff --git a/eladmin-common/pom.xml b/eladmin-common/pom.xml index 2150b4b72..a349edd48 100644 --- a/eladmin-common/pom.xml +++ b/eladmin-common/pom.xml @@ -9,7 +9,7 @@ 4.0.0 - 5.3.4 + 5.7.22 eladmin-common diff --git a/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java index 50343bcb9..b42ddde38 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java @@ -15,8 +15,8 @@ */ package me.zhengjie.config; +import cn.hutool.core.collection.CollUtil; import com.fasterxml.classmate.TypeResolver; -import com.google.common.base.Predicates; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -29,14 +29,18 @@ import springfox.documentation.builders.PathSelectors; import springfox.documentation.schema.AlternateTypeRule; import springfox.documentation.schema.AlternateTypeRuleConvention; -import springfox.documentation.service.*; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.ApiKey; +import springfox.documentation.service.AuthorizationScope; +import springfox.documentation.service.SecurityReference; +import springfox.documentation.service.SecurityScheme; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; + import static springfox.documentation.schema.AlternateTypeRules.newRule; /** @@ -62,7 +66,7 @@ public Docket createRestApi() { .pathMapping("/") .apiInfo(apiInfo()) .select() - .paths(Predicates.not(PathSelectors.regex("/error.*"))) + .paths(PathSelectors.regex("^(?!/error).*")) .paths(PathSelectors.any()) .build() //添加登陆认证 @@ -98,7 +102,7 @@ private List securityContexts() { private SecurityContext getContextByPath() { return SecurityContext.builder() .securityReferences(defaultAuth()) - .forPaths(PathSelectors.regex("^(?!/auth).*$")) + .operationSelector(o->o.requestMappingPattern().matches("^(?!/auth).*$")) .build(); } @@ -128,7 +132,7 @@ public int getOrder() { @Override public List rules() { - return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class))); + return CollUtil.newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class))); } }; } diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java index 57a4913d2..e561762b9 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java @@ -15,16 +15,17 @@ */ package me.zhengjie.utils; +import cn.hutool.core.lang.Validator; import cn.hutool.core.util.ObjectUtil; import me.zhengjie.exception.BadRequestException; -import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator; /** * 验证工具 + * * @author Zheng Jie * @date 2018-11-23 */ -public class ValidationUtil{ +public class ValidationUtil { /** * 验证空 @@ -36,10 +37,10 @@ public static void isNull(Object obj, String entity, String parameter , Object v } } - /** - * 验证是否为邮箱 - */ - public static boolean isEmail(String email) { - return new EmailValidator().isValid(email, null); - } + /** + * 验证是否为邮箱 + */ + public static boolean isEmail(String email) { + return Validator.isEmail(email); + } } diff --git a/eladmin-common/src/test/java/me/zhengjie/utils/DateUtilsTest.java b/eladmin-common/src/test/java/me/zhengjie/utils/DateUtilsTest.java index 4f28ed377..dfe01e09e 100644 --- a/eladmin-common/src/test/java/me/zhengjie/utils/DateUtilsTest.java +++ b/eladmin-common/src/test/java/me/zhengjie/utils/DateUtilsTest.java @@ -1,6 +1,6 @@ package me.zhengjie.utils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.util.Date; diff --git a/eladmin-common/src/test/java/me/zhengjie/utils/EncryptUtilsTest.java b/eladmin-common/src/test/java/me/zhengjie/utils/EncryptUtilsTest.java index f909d9dbd..3ec737523 100644 --- a/eladmin-common/src/test/java/me/zhengjie/utils/EncryptUtilsTest.java +++ b/eladmin-common/src/test/java/me/zhengjie/utils/EncryptUtilsTest.java @@ -1,8 +1,9 @@ package me.zhengjie.utils; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + import static me.zhengjie.utils.EncryptUtils.*; +import static org.junit.jupiter.api.Assertions.assertEquals; public class EncryptUtilsTest { diff --git a/eladmin-common/src/test/java/me/zhengjie/utils/FileUtilTest.java b/eladmin-common/src/test/java/me/zhengjie/utils/FileUtilTest.java index f069c1587..48e06bd7d 100644 --- a/eladmin-common/src/test/java/me/zhengjie/utils/FileUtilTest.java +++ b/eladmin-common/src/test/java/me/zhengjie/utils/FileUtilTest.java @@ -1,10 +1,10 @@ package me.zhengjie.utils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.MockMultipartFile; -import static org.junit.Assert.*; import static me.zhengjie.utils.FileUtil.*; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FileUtilTest { diff --git a/eladmin-common/src/test/java/me/zhengjie/utils/StringUtilsTest.java b/eladmin-common/src/test/java/me/zhengjie/utils/StringUtilsTest.java index 12e875a83..ffb2cf88b 100644 --- a/eladmin-common/src/test/java/me/zhengjie/utils/StringUtilsTest.java +++ b/eladmin-common/src/test/java/me/zhengjie/utils/StringUtilsTest.java @@ -1,13 +1,18 @@ package me.zhengjie.utils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.MockHttpServletRequest; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Date; -import static me.zhengjie.utils.StringUtils.*; -import static org.junit.Assert.*; +import static me.zhengjie.utils.StringUtils.getIp; +import static me.zhengjie.utils.StringUtils.getWeekDay; +import static me.zhengjie.utils.StringUtils.toCamelCase; +import static me.zhengjie.utils.StringUtils.toCapitalizeCamelCase; +import static me.zhengjie.utils.StringUtils.toUnderScoreCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class StringUtilsTest { @@ -40,4 +45,4 @@ public void testGetWeekDay() { public void testGetIP() { assertEquals("127.0.0.1", getIp(new MockHttpServletRequest())); } -} \ No newline at end of file +} diff --git a/eladmin-generator/pom.xml b/eladmin-generator/pom.xml index 52cdcfbe3..960896168 100644 --- a/eladmin-generator/pom.xml +++ b/eladmin-generator/pom.xml @@ -13,7 +13,7 @@ 代码生成模块 - 1.9 + 1.10 diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml index 46d81786c..fc36c5c5d 100644 --- a/eladmin-system/pom.xml +++ b/eladmin-system/pom.xml @@ -13,7 +13,7 @@ 核心模块 - 0.11.1 + 0.11.2 5.8.0 @@ -84,7 +84,7 @@ com.github.oshi oshi-core - 5.7.1 + 6.1.4 diff --git a/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java b/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java index dca5b94b9..a0093d689 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java @@ -54,7 +54,7 @@ public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); - config.addAllowedOrigin("*"); + config.addAllowedOriginPattern("*"); config.addAllowedHeader("*"); config.addAllowedMethod("*"); source.registerCorsConfiguration("/**", config); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java index 7ff2e91b8..6e7e52226 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java @@ -15,9 +15,8 @@ */ package me.zhengjie.modules.system.service.impl; -import cn.hutool.core.date.BetweenFormater; +import cn.hutool.core.date.BetweenFormatter.Level; import cn.hutool.core.date.DateUtil; -import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.system.service.MonitorService; import me.zhengjie.utils.ElAdminConstant; import me.zhengjie.utils.FileUtil; @@ -177,7 +176,7 @@ private Map getSystemInfo(OperatingSystem os){ long time = ManagementFactory.getRuntimeMXBean().getStartTime(); Date date = new Date(time); // 计算项目运行时间 - String formatBetween = DateUtil.formatBetween(date, new Date(),BetweenFormater.Level.HOUR); + String formatBetween = DateUtil.formatBetween(date, new Date(), Level.HOUR); // 系统信息 systemInfo.put("os", os.toString()); systemInfo.put("day", formatBetween); diff --git a/eladmin-system/src/main/resources/banner.txt b/eladmin-system/src/main/resources/banner.txt index d0f401a88..cc460ce3b 100644 --- a/eladmin-system/src/main/resources/banner.txt +++ b/eladmin-system/src/main/resources/banner.txt @@ -5,4 +5,4 @@ | __| | | (_| | (_| | | | | | | | | | | \___|_| \__,_|\__,_|_| |_| |_|_|_| |_| - :: Spring Boot :: (v2.1.0.RELEASE) \ No newline at end of file + :: Spring Boot :: (v2.6.4) \ No newline at end of file diff --git a/eladmin-system/src/test/java/me/zhengjie/EladminSystemApplicationTests.java b/eladmin-system/src/test/java/me/zhengjie/EladminSystemApplicationTests.java index 45d521209..d3986f0f2 100644 --- a/eladmin-system/src/test/java/me/zhengjie/EladminSystemApplicationTests.java +++ b/eladmin-system/src/test/java/me/zhengjie/EladminSystemApplicationTests.java @@ -1,11 +1,8 @@ package me.zhengjie; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class EladminSystemApplicationTests { diff --git a/eladmin-system/src/test/java/me/zhengjie/LoginCacheTest.java b/eladmin-system/src/test/java/me/zhengjie/LoginCacheTest.java index 4cae4a8fe..9ebbfaab3 100644 --- a/eladmin-system/src/test/java/me/zhengjie/LoginCacheTest.java +++ b/eladmin-system/src/test/java/me/zhengjie/LoginCacheTest.java @@ -1,64 +1,62 @@ package me.zhengjie; import me.zhengjie.modules.security.service.UserDetailsServiceImpl; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class LoginCacheTest { - @Resource(name = "userDetailsService") - private UserDetailsServiceImpl userDetailsService; - ExecutorService executor = Executors.newCachedThreadPool(); + @Resource(name = "userDetailsService") + private UserDetailsServiceImpl userDetailsService; - @Test - public void testCache() throws InterruptedException { - long start1 = System.currentTimeMillis(); - int size = 1000; - CountDownLatch latch = new CountDownLatch(size); - for (int i = 0; i < size; i++) { - executor.submit(() -> userDetailsService.loadUserByUsername("admin")); - latch.countDown(); - } - latch.await(); + ExecutorService executor = Executors.newCachedThreadPool(); - long end1 = System.currentTimeMillis(); - //关闭缓存 - userDetailsService.setEnableCache(false); - long start2 = System.currentTimeMillis(); - for (int i = 0; i < size; i++) { - userDetailsService.loadUserByUsername("admin"); - } - long end2 = System.currentTimeMillis(); - System.out.print("使用缓存:" + (end1 - start1) + "毫秒\n 不使用缓存:" + (end2 - start2) + "毫秒"); + @Test + public void testCache() throws InterruptedException { + long start1 = System.currentTimeMillis(); + int size = 1000; + CountDownLatch latch = new CountDownLatch(size); + for (int i = 0; i < size; i++) { + executor.submit(() -> userDetailsService.loadUserByUsername("admin")); + latch.countDown(); } - - @Test - public void testCacheManager() throws InterruptedException { - int size = 1000; - CountDownLatch latch = new CountDownLatch(size); - for (int i = 0; i < size; i++) { - int mod = i % 10; - executor.submit(() -> { - try { - Thread.sleep(mod * 2 + (int) (Math.random() * 10000)); - } catch (InterruptedException e) { - e.printStackTrace(); - } - userDetailsService.loadUserByUsername("admin" + mod); - latch.countDown(); - System.out.println("剩余未完成数量" + latch.getCount()); - }); - } - latch.await(); + latch.await(); + + long end1 = System.currentTimeMillis(); + // 关闭缓存 + userDetailsService.setEnableCache(false); + long start2 = System.currentTimeMillis(); + for (int i = 0; i < size; i++) { + userDetailsService.loadUserByUsername("admin"); } - + long end2 = System.currentTimeMillis(); + System.out.print("使用缓存:" + (end1 - start1) + "毫秒\n 不使用缓存:" + (end2 - start2) + "毫秒"); + } + + @Test + public void testCacheManager() throws InterruptedException { + int size = 1000; + CountDownLatch latch = new CountDownLatch(size); + for (int i = 0; i < size; i++) { + int mod = i % 10; + executor.submit( + () -> { + try { + Thread.sleep(mod * 2 + (int) (Math.random() * 10000)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + userDetailsService.loadUserByUsername("admin" + mod); + latch.countDown(); + System.out.println("剩余未完成数量" + latch.getCount()); + }); + } + latch.await(); + } } diff --git a/eladmin-tools/pom.xml b/eladmin-tools/pom.xml index 4bbf9f4c7..dbf5e63b2 100644 --- a/eladmin-tools/pom.xml +++ b/eladmin-tools/pom.xml @@ -14,8 +14,8 @@ 1.4.7 - [7.2.0, 7.2.99] - 4.9.153.ALL + 7.9.3 + 4.22.57.ALL @@ -47,4 +47,4 @@ ${alipay.version} - \ No newline at end of file + diff --git a/pom.xml b/pom.xml index 0f82d1a10..dbcc3d4b3 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.springframework.boot spring-boot-starter-parent - 2.2.10.RELEASE + 2.6.4 @@ -34,10 +34,10 @@ 1.8 1.16 2.9.2 - 1.2.70 - 1.1.24 - 2.5.0 - 1.3.1.Final + 1.2.79 + 1.2.8 + 2.11.1 + 1.4.2.Final @@ -80,6 +80,7 @@ + org.apache.commons commons-pool2 @@ -98,37 +99,14 @@ + - io.springfox - springfox-swagger2 - ${swagger.version} - - - io.swagger - swagger-annotations - - - io.swagger - swagger-models - - - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.swagger - swagger-annotations - 1.5.21 - - - io.swagger - swagger-models - 1.5.21 + com.github.xiaoymin + knife4j-spring-boot-starter + 3.0.3 + mysql @@ -144,13 +122,13 @@ + net.dreamlu mica-ip2region - 2.5.6 + 2.6.3 - org.projectlombok @@ -162,12 +140,12 @@ org.apache.poi poi - 3.17 + 5.2.0 org.apache.poi poi-ooxml - 3.17 + 5.2.0 xerces @@ -211,7 +189,7 @@ nl.basjes.parse.useragent yauaa - 5.23 + 6.11