use of com.albedo.java.modules.sys.domain.vo.UserExcelVo in project albedo by somowhere.
the class UserResource method uploadData.
/**
* @param dataFile
* @param response
* @return
* @throws Exception
*/
@PostMapping(value = "/upload")
@PreAuthorize("@pms.hasPermission('sys_user_upload')")
@LogOperate(value = "用户管理导入")
public ResponseEntity<Result> uploadData(@RequestParam("uploadFile") MultipartFile dataFile, HttpServletResponse response) throws Exception {
if (dataFile.isEmpty()) {
return ResponseEntityBuilder.buildFail("上传文件为空");
}
ExcelUtil<UserExcelVo> util = new ExcelUtil(UserExcelVo.class);
List<UserExcelVo> dataList = util.importExcel(dataFile.getInputStream());
for (UserExcelVo userExcelVo : dataList) {
if (userExcelVo.getPhone().length() != 11) {
BigDecimal bd = new BigDecimal(userExcelVo.getPhone());
userExcelVo.setPhone(bd.toPlainString());
}
userService.save(userExcelVo);
}
return ResponseEntityBuilder.buildOk("操作成功");
}
Aggregations