| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.sql.ResultSet; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @ApiOperation("数据导入") |
| | | @PostMapping("excelImport") |
| | | public Response excelImport(@RequestParam MultipartFile file) throws IOException, InvalidFormatException { |
| | | public Response excelImport(@RequestPart MultipartFile file) throws IOException, InvalidFormatException { |
| | | Response<Object> response = new Response<>(); |
| | | String name=file.getOriginalFilename(); |
| | | if(!name.substring(name.length()-4).equals(".xls") && !name.substring(name.length()-5).equals(".xlsx")){ |
| | | if(!name.endsWith(".xls") && !name.endsWith(".xlsx")){ |
| | | response.set(1,false,"文件类型错误"); |
| | | }else{ |
| | | service.excelImport(file.getInputStream()); |
| | | InputStream is=file.getInputStream(); |
| | | service.excelImport(is); |
| | | if(is!=null){ |
| | | try { |
| | | is.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | response.set(1,true,"数据导入完成"); |
| | | } |
| | | return response; |
| | | } |
| | | @ApiOperation("测试mybatisDb") |
| | | @GetMapping("testTableDb") |
| | | public Response testTableDb(@RequestParam String va,@RequestParam String c){ |
| | | List list = service.testTableDb(va,c); |
| | | return new Response().setII(1,true,list,null); |
| | | public Response testTableDb(){ |
| | | return service.testTableDb(); |
| | | } |
| | | } |