feat: 修改命名

This commit is contained in:
zengxiaobo 2024-05-07 16:34:06 +08:00
parent db28d2fbc5
commit 4796b3692b
3 changed files with 18 additions and 16 deletions

View File

@ -73,6 +73,18 @@ public class PageConverter {
return PageConverter.toResp(iPage); return PageConverter.toResp(iPage);
} }
public static <T, R> PageResp<R> toResp(IPage<T> page, Function<? super T, ? extends R> mapper) {
List<R> collect = page.getRecords().stream().map(mapper).collect(toList());
PageResp result = PageResp.builder()
.total(page.getTotal())
.current(page.getCurrent())
.size(page.getSize())
.build();
result.setData(collect);
return result;
}
/** /**
* 将所有的数据通过page接口写入到list. 并返回 * 将所有的数据通过page接口写入到list. 并返回
* function中需要参数为新的pageNum, 默认从第一页开始加载. 直到返回的记录行数小于 预期的行数 * function中需要参数为新的pageNum, 默认从第一页开始加载. 直到返回的记录行数小于 预期的行数
@ -104,15 +116,5 @@ public class PageConverter {
return totalData; return totalData;
} }
public static <T, R> PageResp<R> convert(IPage<T> page, Function<? super T, ? extends R> mapper) {
List<R> collect = page.getRecords().stream().map(mapper).collect(toList());
PageResp result = PageResp.builder()
.total(page.getTotal())
.current(page.getCurrent())
.size(page.getSize())
.build();
result.setData(collect);
return result;
}
} }

View File

@ -39,9 +39,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
@ -82,6 +79,10 @@
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -43,12 +43,11 @@ import java.util.List;
@Import(value = {TestConfig.class, MysqlConfig.class, RedisConfig.class, TransactionalConfig.class}) @Import(value = {TestConfig.class, MysqlConfig.class, RedisConfig.class, TransactionalConfig.class})
@ContextConfiguration @ContextConfiguration
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@SpringBootTest
@AutoConfigureMockMvc @AutoConfigureMockMvc
@Transactional @Transactional
@ActiveProfiles("unittest") @ActiveProfiles("unittest")
@ComponentScan("cn.axzo.**.config") @ComponentScan("cn.axzo.foundation.unittest.support.config")
public abstract class BaseTest { public abstract class BaseUnittest {
private static final String JSON_FILE_CLASSPATH = "classpath:json/"; private static final String JSON_FILE_CLASSPATH = "classpath:json/";
/** /**
* 记录对象原始的 field . 因为这些值可能被mock替换, 在每次执行单元测试前统一进行一次替换恢复 * 记录对象原始的 field . 因为这些值可能被mock替换, 在每次执行单元测试前统一进行一次替换恢复