update:补充导入前的表头校验

This commit is contained in:
sunzheng
2024-09-23 11:33:20 +08:00
parent 0427e9fa22
commit 0bd92a76eb
@@ -789,6 +789,8 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 校验模板表头
excelHeadVerify(file, LawsClubExcel.class, 0 ,0);
try {
ImportParams params = new ImportParams();
params.setNeedSave(true);
@@ -960,4 +962,15 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
));
}
private void excelHeadVerify(MultipartFile file, Class<LawsClubExcel> clazz, int titleRows, int i) {
try {
if (!(boolean) ImportExcelUtil.checkTemplateTitle(file, clazz, titleRows, i)){
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}catch (Exception e) {
e.printStackTrace();
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}
}