Skip to content

Commit

Permalink
feat:1.升级springboot -> 3.2.0 mybatis -> 3.0.3... 全面支持jdk21。2.优化uno-te…
Browse files Browse the repository at this point in the history
…st模块
  • Loading branch information
ClearXs committed Nov 24, 2023
1 parent 0cab224 commit eeb7f9c
Show file tree
Hide file tree
Showing 36 changed files with 241 additions and 618 deletions.
49 changes: 48 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<properties>
<java.version>21</java.version>
<reactor-bom>2020.0.12</reactor-bom>
<spring.boot.version>3.1.5</spring.boot.version>
<spring.boot.version>3.2.0</spring.boot.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-plugin.version>3.8.1</maven-plugin.version>
<maven-jar-plugin.version>3.1.0</maven-jar-plugin.version>
Expand Down Expand Up @@ -199,4 +199,51 @@
<url>https://packages.aliyun.com/maven/repository/2300285-snapshot-JAW5GT/</url>
</snapshotRepository>
</distributionManagement>

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>
36 changes: 3 additions & 33 deletions uno-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.5</version>
<version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -22,8 +22,6 @@
<protostuff.version>1.5.9</protostuff.version>
<!-- google SPI -->
<auto-service.version>1.0.1</auto-service.version>
<!-- json对象处理 -->
<jackson.version>2.11.4</jackson.version>
<!-- 代理相关 -->
<byte-buddy.version>1.12.2</byte-buddy.version>
<cglib.version>3.3.0</cglib.version>
Expand All @@ -36,7 +34,8 @@
<swagger-v3.version>2.2.17</swagger-v3.version>
<swagger-v2.version>1.6.2</swagger-v2.version>
<springfox-swagger2.version>3.0.0</springfox-swagger2.version>
<mybatis-spring-boot.version>3.0.2</mybatis-spring-boot.version>
<!-- mybatis 还为支持springboot3.2.x 临时处理 -->
<mybatis-spring-boot.version>3.0.3-SNAPSHOT</mybatis-spring-boot.version>
<mybatis-plus-boot.version>3.5.3</mybatis-plus-boot.version>
<!-- 数据库 -->
<druid.version>1.2.20</druid.version>
Expand Down Expand Up @@ -176,35 +175,6 @@
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<!-- bytebuddy -->
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<!-- jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- ======================== test framework ======================== -->
<!-- junit -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private Mono<Tuple2<String, List<HttpSwapper>>> buildMultiValueSwapper(Map.Entry
*/
private Flux<HttpSwapper> buildSwappers(String path, PathItem pathItem) {
return Flux.fromIterable(pathItem.readOperationsMap().entrySet())
.map(operation -> HttpSwapper.build(host.concat(path), HttpMethod.resolve(operation.getKey().name())));
.map(operation -> HttpSwapper.build(host.concat(path), HttpMethod.valueOf(operation.getKey().name())));
}

/**
Expand Down
1 change: 0 additions & 1 deletion uno-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cc.allio.uno.core.datastructure.tree;

import lombok.NonNull;

import java.io.Serializable;
import java.util.Comparator;

public class ComparableElement<T extends ComparableElement<T>> extends DefaultElement {

private final Comparator<T> comparator;

public ComparableElement(@NonNull Serializable id, Comparator<T> comparator) {
super(id);
this.comparator = comparator;
}

@Override
public void addChildren(Element element) {
super.addChildren(element);
if (comparator != null) {
getChildren().sort((o1, o2) -> comparator.compare((T) o1, (T) o2));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Setter;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
Expand All @@ -25,7 +26,7 @@ public class DefaultElement extends TraversalElement {
@Setter
private Element parent;

private final List<Element> children;
private List<? super Element> children;

public DefaultElement(@NonNull Serializable id) {
this.id = id;
Expand All @@ -45,13 +46,12 @@ public boolean isLeaf() {

@Override
public <T extends Element> void setChildren(List<T> children) {
clearChildren();
this.children.addAll(children);
this.children = Collections.singletonList(children);
}

@Override
public void addChildren(Element element) {
children.add(element);
this.children.add(element);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cc.allio.uno.core.datastructure.tree;

import cc.allio.uno.core.util.CollectionUtils;
import com.google.common.collect.Lists;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand All @@ -15,14 +15,16 @@
* @date 2023/11/9 11:34
* @since 1.1.5
*/
public class TreeSupport {
public final class TreeSupport {

private TreeSupport() {
}

/**
* @see #treeify(List, Function)
*/
public static <T extends Expand, R extends Element> List<R> treeify(List<T> expandTrees) {
return (List<R>) treeify(expandTrees, e -> new DefaultElement(e.getId()));
public static <T extends Expand> List<DefaultElement> treeify(List<T> expandTrees) {
return treeify(expandTrees, e -> new DefaultElement(e.getId()));
}

/**
Expand All @@ -40,7 +42,10 @@ public static <T extends Expand, R extends Element> List<R> treeify(List<T> expa
* @param <R> 继承于{@link Element}的泛型
* @return hierarchy filter expand tree depth == 0的结点
*/
public static <T extends Expand, R extends Element> List<R> treeify(List<T> expandTrees, Function<T, R> treeFunc) {
public static synchronized <T extends Expand, R extends Element> List<R> treeify(List<T> expandTrees, Function<T, R> treeFunc) {
if (CollectionUtils.isEmpty(expandTrees)) {
return Collections.emptyList();
}
// transfer expand id must not null
Map<Serializable, R> idElement =
expandTrees.stream()
Expand All @@ -59,19 +64,27 @@ public static <T extends Expand, R extends Element> List<R> treeify(List<T> expa
}
}

// 返回根结点数据
return idElement.values()
.stream()
.filter(e -> e.getDepth() == Element.ROOT_NODE)
.toList();
}
T fake = expandTrees.getFirst();

R sentinel = treeFunc.apply(fake);
for (R virtual : idElement.values()) {
if (virtual.getDepth() == Element.ROOT_NODE) {
// 触发Element添加结点的特性,如排序
sentinel.addChildren(virtual);
}
}

return sentinel.getChildren();
}

/**
* @see #expand(List, Function)
* @see #expand(List, Function, Comparator)
*/
public static <T extends Expand, R extends Element> List<T> expand(List<R> forest) {
return (List<T>) expand(forest, (r) -> new DefaultExpand(r.getId(), r.getParent() != null ? r.getParent().getId() : null));
public static <R extends Element> List<DefaultExpand> expand(List<R> forest) {
return expand(
forest,
r -> new DefaultExpand(r.getId(), r.getParent() != null ? r.getParent().getId() : null),
null);
}

/**
Expand All @@ -80,14 +93,15 @@ public static <T extends Expand, R extends Element> List<T> expand(List<R> fores
*
* @param forest 树
* @param expandFunc 树结构展缓为平展结构
* @param comparator 用于平展结构的排序,可以为null
* @param <T> 继承于{@link Expand}的泛型
* @param <R> 继承于{@link Element}的泛型
* @return expand
*/
public static <T extends Expand, R extends Element> List<T> expand(List<R> forest, Function<R, T> expandFunc) {
public static synchronized <T extends Expand, R extends Element> List<T> expand(List<R> forest, Function<R, T> expandFunc, Comparator<T> comparator) {
List<T> expands = Lists.newArrayList();
try {
Element.ROOT_SENTINEL.setChildren(forest);
Element.ROOT_SENTINEL.setChildren(Lists.newArrayList(forest));
Element.ROOT_SENTINEL.accept(e -> {
// 忽略哨兵结点
if (!Element.ROOT_SENTINEL.equals(e)) {
Expand All @@ -97,6 +111,9 @@ public static <T extends Expand, R extends Element> List<T> expand(List<R> fores
} finally {
Element.ROOT_SENTINEL.clearChildren();
}
if (comparator != null) {
expands.sort(comparator);
}
return expands;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,62 @@

import cc.allio.uno.core.BaseTestCase;
import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.NonNull;
import org.junit.jupiter.api.Test;

import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.function.Function;

public class TreeSupportTest extends BaseTestCase {

static List<Expand> testData = Lists.newArrayList(
List<Expand> testData = Lists.newArrayList(
new DefaultExpand(1, 0),
new DefaultExpand(2, 0),
new DefaultExpand(3, 0),
new DefaultExpand(2, 0),
new DefaultExpand(4, 1),
new DefaultExpand(6, 2),
new DefaultExpand(5, 2)
);

@Test
void testTreeifyAndExpand() {
List<Element> treeify = TreeSupport.treeify(testData);
List<DefaultElement> treeify = TreeSupport.treeify(testData);

assertEquals(3, treeify.size());

List<Expand> expands = TreeSupport.expand(treeify);
List<DefaultExpand> expands = TreeSupport.expand(Lists.newArrayList(treeify));

assertEquals(testData.size(), expands.size());
}

@Test
void testComparatorTreeify() {
List<Element> treeify =
TreeSupport.treeify(
testData,
expand -> new Role(expand.getId(), Comparator.comparingInt(Role::getSort))
);
assertEquals(3, treeify.size());
Element element = treeify.get(1);
assertNotNull(element);
Element sort = element.getChildren().get(0);
assertNotNull(sort);
assertEquals(5, sort.getId());
}


@Getter
public static class Role extends ComparableElement<Role> {

private final int sort;

public Role(@NonNull Serializable id, Comparator<Role> comparator) {
super(id, comparator);
this.sort = (int) id;
}
}
}
4 changes: 2 additions & 2 deletions uno-gis/src/test/java/cc/allio/uno/gis/type/VillageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import cc.allio.uno.test.CoreTest;
import cc.allio.uno.test.Inject;
import cc.allio.uno.test.RunMapperTest;
import cc.allio.uno.test.RunTest;
import cc.allio.uno.gis.config.UnoGisMybatisAutoConfiguration;
import cc.allio.uno.gis.type.entity.Village;
import cc.allio.uno.gis.type.mapper.VillageMapper;
import cc.allio.uno.test.env.annotation.MybatisPlusEnv;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.junit.jupiter.api.Test;

import java.util.List;

@RunMapperTest(mapperScan = TestScan.class)
@RunTest(components = UnoGisMybatisAutoConfiguration.class)
@MybatisPlusEnv(basePackages = "cc.allio.uno.gis.type.mapper.**")
public class VillageTest extends CoreTest {

@Inject
Expand Down
Loading

0 comments on commit eeb7f9c

Please sign in to comment.