mirror of
https://github.com/dataease/dataease.git
synced 2026-06-16 20:42:07 +08:00
fix: 增加excel字段重复错误提示
This commit is contained in:
@@ -946,6 +946,12 @@ public class DataSetTableService {
|
||||
}
|
||||
|
||||
String[] fieldArray = fields.stream().map(TableFiled::getFieldName).toArray(String[]::new);
|
||||
|
||||
// 校验excel字段是否重名
|
||||
if (checkIsRepeat(fieldArray)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(data)) {
|
||||
jsonArray = data.stream().map(ele -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
@@ -1087,4 +1093,19 @@ public class DataSetTableService {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断数组中是否有重复的值
|
||||
*/
|
||||
public static boolean checkIsRepeat(String[] array) {
|
||||
HashSet<String> hashSet = new HashSet<String>();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
hashSet.add(array[i]);
|
||||
}
|
||||
if (hashSet.size() == array.length) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user