代码优化

master
wayn 4 years ago
parent b8afc036c4
commit b9e01b2d1d

@ -2,11 +2,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
<version>2.4.4</version>
</parent>
<modules>
<module>waynboot-common</module>
@ -18,21 +18,22 @@
</modules>
<groupId>com.wayn</groupId>
<artifactId>waynboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
<packaging>pom</packaging>
<name>waynboot</name>
<description>waynboot project for Spring Boot</description>
<description>waynboot mall</description>
<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<spring-boot.version>2.2.4.RELEASE</spring-boot.version>
<spring-boot.version>2.4.4</spring-boot.version>
<mysql.connector.java.version>8.0.19</mysql.connector.java.version>
<jedis.version>3.3.0</jedis.version>
<lombok.version>1.18.6</lombok.version>
<mybatis-plus.version>3.4.1</mybatis-plus.version>
<mybatis-plus.version>3.4.2</mybatis-plus.version>
<druid.version>1.2.4</druid.version>
<commons.io.version>2.8.0</commons.io.version>
<commons.collections.version>3.2.2</commons.collections.version>
@ -42,8 +43,8 @@
<easy-captcha.version>1.6.2</easy-captcha.version>
<swagger.version>2.9.2</swagger.version>
<easypoi.version>4.2.0</easypoi.version>
<jwt.version>3.12.0</jwt.version>
<qiniu.version>[7.2.0, 7.2.99]</qiniu.version>
<jwt.version>3.14.0</jwt.version>
<qiniu.version>7.4.0</qiniu.version>
<mail.version>1.4.7</mail.version>
</properties>
@ -242,6 +243,32 @@
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<url>https://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<compilerArg>-parameters</compilerArg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -5,7 +5,7 @@
<parent>
<artifactId>waynboot</artifactId>
<groupId>com.wayn</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -55,7 +55,7 @@
<dependency>
<groupId>com.wayn</groupId>
<artifactId>waynboot-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.elasticsearch</groupId>
@ -75,7 +75,7 @@
<dependency>
<groupId>com.wayn</groupId>
<artifactId>waynboot-message-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
@ -99,13 +99,14 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<!-- 指定该Main Class为全局的唯一入口 -->
<mainClass>com.wayn.AdminApplication</mainClass>
<layout>ZIP</layout>
<commandlineArguments>
-parameters
</commandlineArguments>
<!-- <commandlineArguments>-->
<!-- -parameters-->
<!-- </commandlineArguments>-->
</configuration>
<executions>
<execution>

@ -102,7 +102,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedOriginPattern("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.setAllowCredentials(true);

@ -5,12 +5,11 @@
<parent>
<artifactId>waynboot</artifactId>
<groupId>com.wayn</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>waynboot-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
<dependencies>
<dependency>
@ -198,21 +197,4 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<compilerArg>-parameters</compilerArg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -5,11 +5,11 @@
<parent>
<artifactId>waynboot</artifactId>
<groupId>com.wayn</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>waynboot-generator</artifactId>
<version>1.1.0</version>
<dependencies>
<!-- Apache工具组件 -->
@ -22,7 +22,7 @@
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${mybatis-plus.version}</version>
<version>3.4.1</version>
</dependency>
<!--阿里数据库连接池 -->
@ -51,5 +51,4 @@
<version>2.3.30</version>
</dependency>
</dependencies>
</project>
</project>

@ -5,19 +5,13 @@
<parent>
<artifactId>waynboot</artifactId>
<groupId>com.wayn</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>waynboot-message-core</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<version>1.1.0</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

@ -5,18 +5,18 @@
<parent>
<artifactId>waynboot</artifactId>
<groupId>com.wayn</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>waynboot-message</artifactId>
<version>1.1.0</version>
<dependencies>
<dependency>
<groupId>com.wayn</groupId>
<artifactId>waynboot-message-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
</dependency>
<dependency>
@ -76,9 +76,9 @@
<!-- 指定该Main Class为全局的唯一入口 -->
<mainClass>com.wayn.MessageApplication</mainClass>
<layout>ZIP</layout>
<commandlineArguments>
-parameters
</commandlineArguments>
<!-- <commandlineArguments>-->
<!-- -parameters-->
<!-- </commandlineArguments>-->
</configuration>
<executions>
<execution>

@ -5,11 +5,13 @@
<parent>
<artifactId>waynboot</artifactId>
<groupId>com.wayn</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>waynboot-mobile-api</artifactId>
<version>1.1.0</version>
<dependencies>
<!-- swagger2-->
@ -55,7 +57,7 @@
<dependency>
<groupId>com.wayn</groupId>
<artifactId>waynboot-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.elasticsearch</groupId>
@ -75,7 +77,7 @@
<dependency>
<groupId>com.wayn</groupId>
<artifactId>waynboot-message-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
@ -103,9 +105,9 @@
<!-- 指定该Main Class为全局的唯一入口 -->
<mainClass>com.wayn.MobileApplication</mainClass>
<layout>ZIP</layout>
<commandlineArguments>
-parameters
</commandlineArguments>
<!-- <commandlineArguments>-->
<!-- -parameters-->
<!-- </commandlineArguments>-->
</configuration>
<executions>
<execution>

@ -43,13 +43,14 @@ public class IHomeServiceImpl implements IHomeService {
@Override
public R getHomeIndexData() {
// if (redisCache.existsKey(INDEX_DATA)) {
// return redisCache.getCacheObject(INDEX_DATA);
// }
R success = R.success();
ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(10, 10,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(), r -> new Thread(r, "首页线程"));
ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(
10,
10,
0L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(),
r -> new Thread(r, "首页线程"));
Callable<List<Banner>> bannerCall = () -> iBannerService.list(new QueryWrapper<Banner>().eq("status", 0).orderByAsc("sort"));
Callable<List<Diamond>> diamondCall = () -> iDiamondService.list(new QueryWrapper<Diamond>()
.orderByAsc("sort")
@ -93,7 +94,7 @@ public class IHomeServiceImpl implements IHomeService {
return redisCache.getCacheObject(INDEX_DATA);
}
R success = R.success();
List<CompletableFuture<Void>> list = new ArrayList();
List<CompletableFuture<Void>> list = new ArrayList<>();
CompletableFuture<Void> f1 = CompletableFuture.supplyAsync(() -> iBannerService.list(new QueryWrapper<Banner>().eq("status", 0).orderByAsc("sort")))
.thenAccept(data -> success.add("bannerList", data));
CompletableFuture<Void> f2 = CompletableFuture.supplyAsync(() -> iCategoryService.list(new QueryWrapper<Category>().eq("level", "L1").orderByAsc("sort")))
@ -114,7 +115,7 @@ public class IHomeServiceImpl implements IHomeService {
list.add(f2);
list.add(f3);
list.add(f4);
CompletableFuture.allOf(list.toArray(new CompletableFuture[list.size()])).join();
CompletableFuture.allOf(list.toArray(new CompletableFuture[0])).join();
redisCache.setCacheObject(INDEX_DATA, success, 10, TimeUnit.MINUTES);
return success;
}

Loading…
Cancel
Save