代码完善(dev): 数据库翻译空指针判断
This commit is contained in:
parent
156389e012
commit
56994cbcef
@ -1,5 +1,6 @@
|
||||
package com.aizuda.trans.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
@ -79,8 +80,10 @@ public class DataBaseTranslator implements Translatable {
|
||||
// 返回结果:张三、李四、王五
|
||||
where.set(codeColumn, StrUtil.split(origin, StrUtil.COMMA));
|
||||
List<Entity> entityList = Db.use(dataSource).find(where, EntityListHandler.create(), textColumnArray);
|
||||
for (String column : textColumnArray) {
|
||||
rsList.add(entityList.stream().map(e -> e.getStr(column)).collect(Collectors.joining("、")));
|
||||
if (CollUtil.isNotEmpty(entityList)) {
|
||||
for (String column : textColumnArray) {
|
||||
rsList.add(entityList.stream().map(e -> e.getStr(column)).collect(Collectors.joining("、")));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 单条记录多列(查询结果为单条多列,循环后为多条,根据传入的字段顺序返回)
|
||||
@ -89,8 +92,10 @@ public class DataBaseTranslator implements Translatable {
|
||||
// 返回结果:["aa","bb"]
|
||||
where.set(codeColumn, origin);
|
||||
Entity entity = Db.use(dataSource).find(where, EntityHandler.create(), textColumnArray);
|
||||
for (String column : textColumnArray) {
|
||||
rsList.add(entity.getStr(column));
|
||||
if (null != entity) {
|
||||
for (String column : textColumnArray) {
|
||||
rsList.add(entity.getStr(column));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user