use of com.github.lybgeek.modules.image.dto.ImageDTO in project springboot-learning by lyb-geek.
the class ImageController method importImage.
@PostMapping(value = "/import")
@ResponseBody
public Result<ImageDTO> importImage(MultipartFile file) throws Exception {
ExcelImportResult<ImageVO> excelData = ExcelReader.builder().headRowNumber(1).sheetNo(0).inputStream(file.getInputStream()).build().read(ImageVO.class, true);
boolean verifyFail = excelData.isVerifyFail();
if (verifyFail) {
String errorMsg = ExcelUtils.getErrorMsg(excelData.getFailList());
throw new BizException(errorMsg);
}
List<ImageDTO> imageDTOS = imageConvertMapper.listImageVO2ListDTO(excelData.getList());
imageService.saveImages(imageDTOS);
Result result = Result.builder().data(imageDTOS).build();
return result;
}
Aggregations