Ejemplo n.º 1
0
 @RequestMapping("/export")
 public ResponseEntity<byte[]> download() throws IOException {
   String fileName =
       String.format("菜品列表%s.xlsx", new SimpleDateFormat("yyyyMMdd").format(new Date()));
   ExcelFactory.exportProducts(
       fileName,
       productService.getAll(),
       productService.getTypeMap(),
       productService.getProcurement());
   File file = new File(fileName);
   HttpHeaders headers = new HttpHeaders();
   String cnfileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1");
   headers.setContentDispositionFormData("attachment", cnfileName);
   headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
   return new ResponseEntity<>(FileUtils.readFileToByteArray(file), headers, HttpStatus.CREATED);
 }
Ejemplo n.º 2
0
 @RequestMapping(value = "/all", method = RequestMethod.GET)
 public @ResponseBody List<Product> getAll() {
   return productService.getAll();
 }