1 集合快速分组
List<List<EcontResourcesDto>> partition = com.google.common.collect.Lists.partition(list, 20);
集合快速拆分; 每组20调数据
guava的依赖
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.0-jre</version>
</dependency>
2 方法返回两个返回值
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
MutablePair<String, String> mutablePair = MutablePair.of("1", "第二个值");
System.out.println(mutablePair.getLeft() + "," + mutablePair.getRight());
3 方法返回三个返回值
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
MutableTriple<Integer, String, Date> mutableTriple = MutableTriple.of(2, "中间值", new Date());
System.out.println(mutableTriple.getLeft() + "," + mutableTriple.getMiddle() + "," + mutableTriple.getRight());
4 事物方法模拟回退、回滚、异常
// // binc_rollback 实验代码稍后删除 模拟这里发生异常,看看能否回退
int i = 1;
int j = 1;
if (i-j == 0){
throw BusinessRtException.of("------------------------------------------------------" +
"---------------------------------------------------------------------------------" +
"-----------------------------------模拟发生异常,强制数据库执行回退---------------------------------------------" +
"---------------------------------------------------------------------------------" +
"--------------------------------------------------------------");
}
5 mapper.xml 默认值问题
<if test="item.state != null">
#{state} ,
</if>
<if test="item.state == null">
1 ,
</if>
6 string 一些操作
StringUtils.hasText(字符串) 里面的值为 null 、"" 、 " ",
那么返回值为false,否则为true
7 option
accountsRefundDto.setTradeStatus(Optional.ofNullable(accountVo).map(o -> Optional.ofNullable(o.getPayStatus()).orElse(FundAccountFlowConstants.TRADE_STATUS_FAIL)).orElse(FundAccountFlowConstants.TRADE_STATUS_FAIL));
data.stream()
.filter(d -> Objects.equals(d.getOrgLevelId(), f.getBranchId()))
.findFirst()
.ifPresent(p -> {
f.setBranchName(p.getOrgLevelName());
});