Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级依赖包 #735

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eladmin-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<hutool.version>5.3.4</hutool.version>
<hutool.version>5.7.22</hutool.version>
</properties>

<artifactId>eladmin-common</artifactId>
Expand Down
16 changes: 10 additions & 6 deletions eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand All @@ -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()
//添加登陆认证
Expand Down Expand Up @@ -98,7 +102,7 @@ private List<SecurityContext> securityContexts() {
private SecurityContext getContextByPath() {
return SecurityContext.builder()
.securityReferences(defaultAuth())
.forPaths(PathSelectors.regex("^(?!/auth).*$"))
.operationSelector(o->o.requestMappingPattern().matches("^(?!/auth).*$"))
.build();
}

Expand Down Expand Up @@ -128,7 +132,7 @@ public int getOrder() {

@Override
public List<AlternateTypeRule> rules() {
return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class)));
return CollUtil.newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class)));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

/**
* 验证空
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -40,4 +45,4 @@ public void testGetWeekDay() {
public void testGetIP() {
assertEquals("127.0.0.1", getIp(new MockHttpServletRequest()));
}
}
}
2 changes: 1 addition & 1 deletion eladmin-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>代码生成模块</name>

<properties>
<configuration.version>1.9</configuration.version>
<configuration.version>1.10</configuration.version>
</properties>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions eladmin-system/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>核心模块</name>

<properties>
<jjwt.version>0.11.1</jjwt.version>
<jjwt.version>0.11.2</jjwt.version>
<!-- oshi监控需要指定jna版本, 问题详见 https://github.com/oshi/oshi/issues/1040 -->
<jna.version>5.8.0</jna.version>
</properties>
Expand Down Expand Up @@ -84,7 +84,7 @@
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>5.7.1</version>
<version>6.1.4</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -177,7 +176,7 @@ private Map<String,Object> 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);
Expand Down
2 changes: 1 addition & 1 deletion eladmin-system/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
| __| | | (_| | (_| | | | | | | | | | |
\___|_| \__,_|\__,_|_| |_| |_|_|_| |_|

:: Spring Boot :: (v2.1.0.RELEASE)
:: Spring Boot :: (v2.6.4)
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
90 changes: 44 additions & 46 deletions eladmin-system/src/test/java/me/zhengjie/LoginCacheTest.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
6 changes: 3 additions & 3 deletions eladmin-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<properties>
<mail.version>1.4.7</mail.version>
<qiniu.version>[7.2.0, 7.2.99]</qiniu.version>
<alipay.version>4.9.153.ALL</alipay.version>
<qiniu.version>7.9.3</qiniu.version>
<alipay.version>4.22.57.ALL</alipay.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -47,4 +47,4 @@
<version>${alipay.version}</version>
</dependency>
</dependencies>
</project>
</project>
Loading