fix: excel导入异常时兜底拦截

This commit is contained in:
wuy 2020-07-15 18:26:33 +08:00
parent 3b85a0801d
commit bfba5fd509
1 changed files with 8 additions and 0 deletions

View File

@ -178,6 +178,10 @@ public abstract class BaseExcelFileController extends BaseFileController {
} }
throw e; throw e;
} }
//最后拦截如果数据异常在listener中未被拦截抛出异常此处进行处理
if (V.notEmpty(listener.getErrorMsgs())) {
throw new BusinessException(Status.FAIL_VALIDATION, S.join(listener.getErrorMsgs(), "; "));
}
// 绑定属性到model // 绑定属性到model
dataMap.put("header", listener.getFieldHeaders()); dataMap.put("header", listener.getFieldHeaders());
dataMap.put(ORIGIN_FILE_NAME, originFileName); dataMap.put(ORIGIN_FILE_NAME, originFileName);
@ -209,6 +213,10 @@ public abstract class BaseExcelFileController extends BaseFileController {
} }
throw e; throw e;
} }
//最后拦截如果数据异常在listener中未被拦截抛出异常此处进行处理
if (V.notEmpty(listener.getErrorMsgs())) {
throw new BusinessException(Status.FAIL_VALIDATION, S.join(listener.getErrorMsgs(), "; "));
}
return listener.getDataList().size(); return listener.getDataList().size();
} }