translate

This commit is contained in:
dwh 2024-09-03 16:18:09 +08:00
parent 1d269c8d24
commit e6ea006aa4
1 changed files with 11 additions and 4 deletions

View File

@ -157,14 +157,19 @@ public interface TransStrategy<T> {
String codeColumn = anno.codeColumn(); String codeColumn = anno.codeColumn();
String id = e.getValueBeforeTranslation().toString(); String id = e.getValueBeforeTranslation().toString();
Object rootObject = e.getRootObject(); Object rootObject = e.getRootObject();
return Triple.of(tab, codeColumn,nameColumn); // return Triple.of(tab, codeColumn,nameColumn);
return Pair.of(tab, codeColumn);
}, Collectors.collectingAndThen(Collectors.toList(), listTmp -> { }, Collectors.collectingAndThen(Collectors.toList(), listTmp -> {
//按照表分组 //按照表分组
Dict anno = listTmp.get(0).getAnno(); Dict anno = listTmp.get(0).getAnno();
String tab = anno.tab(); String tab = anno.tab();
String nameColumn = anno.nameColumn();
String codeColumn = anno.codeColumn(); String codeColumn = anno.codeColumn();
String collect = listTmp.stream().map(e -> e.getValueBeforeTranslation()).map(e -> e.toString()).collect(Collectors.joining(",")); String collect = listTmp.stream().map(e -> e.getValueBeforeTranslation()).map(e -> e.toString()).distinct().collect(Collectors.joining(","));
String nameColumn = listTmp.stream().map(e -> {
Dict anno1 = e.getAnno();
String s = Optional.ofNullable(anno1).map(Dict::nameColumn).orElse(null);
return s;
}).map(e -> e.toString()).distinct().collect(Collectors.joining(","));
List<JSONObject> jsonObjects = bean.queryTableDictTextByKeys2(tab, nameColumn, codeColumn, collect); List<JSONObject> jsonObjects = bean.queryTableDictTextByKeys2(tab, nameColumn, codeColumn, collect);
@ -197,8 +202,10 @@ public interface TransStrategy<T> {
}); });
if (ObjUtil.isNotEmpty(one)) { if (ObjUtil.isNotEmpty(one)) {
Dict anno1 = e.getAnno();
String s = anno1.nameColumn();
ReflectUtil.setFieldValue(rootObject, ReflectUtil.setFieldValue(rootObject,
anno.ignoreVo()? e.getTranslatedAttributeNames() : attributeNameBeforeTranslation, one.get(nameColumn)); anno1.ignoreVo()? e.getTranslatedAttributeNames() : attributeNameBeforeTranslation, one.get(s));
} }
} }