导入统一校验
This commit is contained in:
+13
-1
@@ -253,9 +253,21 @@ public class ${entityName}Controller {
|
||||
try {
|
||||
List<${entityName}Page> list = ExcelImportUtil.importExcel(file.getInputStream(), ${entityName}Page.class, params);
|
||||
for (${entityName}Page page : list) {
|
||||
int lineNumber = i + 1;
|
||||
${entityName} po = new ${entityName}();
|
||||
BeanUtils.copyProperties(page, po);
|
||||
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
|
||||
try {
|
||||
List<String> errorList = ValidUtil.validateReturnList(po);
|
||||
if (!errorList.isEmpty()){
|
||||
errorLines++;
|
||||
errorMessage.add("第 " + lineNumber + " 行:"+ StringUtils.join(errorList,","));
|
||||
}
|
||||
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
|
||||
} catch (Exception e) {
|
||||
// 通过索引名判断出错信息
|
||||
errorMessage.add("第 " + lineNumber + " 行:未知错误");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return Result.OK("文件导入成功!数据行数:" + list.size());
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user