summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangshuai <[email protected]>2023-08-24 16:25:17 +0800
committerzhangshuai <[email protected]>2023-08-24 16:25:17 +0800
commitec993cb62feb15f0a1936bca833e132c5cc8a726 (patch)
tree2ee15eb99cef2c9bab7153cfee10db813e460bfd
parentb8981f5bb8712af47b0dfdab01966f40743693aa (diff)
fix: NEZ-3094 导入文件内容或数据为空时,给出提示信息rel-23.07.05
-rw-r--r--nz-admin/src/main/java/com/nis/modules/sys/service/impl/BasicImportAndExportServicesImpl.java9
-rw-r--r--nz-common/src/main/java/com/nis/common/utils/RCode.java2
2 files changed, 11 insertions, 0 deletions
diff --git a/nz-admin/src/main/java/com/nis/modules/sys/service/impl/BasicImportAndExportServicesImpl.java b/nz-admin/src/main/java/com/nis/modules/sys/service/impl/BasicImportAndExportServicesImpl.java
index ba347f7b..531779ba 100644
--- a/nz-admin/src/main/java/com/nis/modules/sys/service/impl/BasicImportAndExportServicesImpl.java
+++ b/nz-admin/src/main/java/com/nis/modules/sys/service/impl/BasicImportAndExportServicesImpl.java
@@ -141,6 +141,9 @@ public class BasicImportAndExportServicesImpl implements BasicImportAndExportSer
if (!headerFlag) {
throw new NZException(RCode.EXCELFILE_HEADER_TEMPLATE_ERROR);
}
+ if (sheet.getFirstRowNum() == sheet.getLastRowNum()){
+ throw new NZException(RCode.IMPORT_FILE_DATA_ISNULL);
+ }
for (int i = sheet.getFirstRowNum() + 1; i <= sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i);
if (row == null) continue;
@@ -155,6 +158,9 @@ public class BasicImportAndExportServicesImpl implements BasicImportAndExportSer
case CSV: {
CsvData csvData = CSVUtils.getCsvDataFromMultipartFile(multipartFile);
List<CsvRow> rows = csvData.getRows();
+ if (rows.size() == 1){
+ throw new NZException(RCode.IMPORT_FILE_DATA_ISNULL);
+ }
CsvRow headers = rows.get(0);
// 表头校验
if (!CSVUtils.validateCSVHeader(headers, headerInfos)) {
@@ -184,6 +190,9 @@ public class BasicImportAndExportServicesImpl implements BasicImportAndExportSer
log.error(e, "[getJSONDataFromMultipartFile] [error] [file: {}]", multipartFile.getOriginalFilename());
throw new NZException(RCode.IMPORT_FILE_PARSE_ERROR);
}
+ if (CollUtil.isEmpty(mapList)){
+ throw new NZException(RCode.IMPORT_FILE_CONTENT_ISNULL);
+ }
LinkedHashMap map = mapList.get(0);
// 表头校验
List<String> arrayList = new ArrayList<>(map.keySet());
diff --git a/nz-common/src/main/java/com/nis/common/utils/RCode.java b/nz-common/src/main/java/com/nis/common/utils/RCode.java
index fab8eb89..bfa84f4b 100644
--- a/nz-common/src/main/java/com/nis/common/utils/RCode.java
+++ b/nz-common/src/main/java/com/nis/common/utils/RCode.java
@@ -956,6 +956,8 @@ public enum RCode {
IMPORT_ERROR_STOP(818, "Error stop import"),
IMPORT_SUBNET_VALUE_ERROR(819, "{0} Not in subnet value list"),
IMPORT_FILE_PARSE_ERROR(820, "Import file resolution failed"),
+ IMPORT_FILE_CONTENT_ISNULL(821, "Import file content cannot be empty"),
+ IMPORT_FILE_DATA_ISNULL(822, "Import file data cannot be empty"),
/**