use of com.github.lybgeek.modules.customerservice.vo.CustomerserviceWagesVO in project springboot-learning by lyb-geek.
the class CustomerserviceWagesController method importExcel.
/**
* 本方法用的模板是位于excel-template下的-->复杂表头样例.xls
* @param file
* @return
* @throws Exception
*/
@PostMapping(value = "/import")
@ResponseBody
public Result<CustomerserviceWagesDTO> importExcel(MultipartFile file) throws Exception {
ExcelImportResult<CustomerserviceWagesVO> excelData = ExcelReader.builder().titleRows(1).headRowNumber(2).sheetNo(0).inputStream(file.getInputStream()).build().read(CustomerserviceWagesVO.class, true);
boolean verifyFail = excelData.isVerifyFail();
if (verifyFail) {
String errorMsg = ExcelUtils.getErrorMsg(excelData.getFailList());
throw new BizException(errorMsg);
}
List<CustomerserviceWagesDTO> customerserviceWagesDTOS = customerserviceWagesConverter.convertVOList2DTOList(excelData.getList());
customerserviceWagesService.saveCustomerserviceWages(customerserviceWagesDTOS);
Result result = new Result().builder().data(customerserviceWagesDTOS).build();
return result;
}
Aggregations