diff --git a/src/main/java/ferramong/reports/App.java b/src/main/java/ferramong/reports/App.java index b7ace4b..05d77b3 100644 --- a/src/main/java/ferramong/reports/App.java +++ b/src/main/java/ferramong/reports/App.java @@ -3,11 +3,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -/* - * Para testar, rode o projeto e no navegador digite: http://localhost:8080/listall/fulano - * Para modificar o banco de dados de testes (H2 - em memória), modifique 'resources/data.sql' - */ - @SpringBootApplication public class App { diff --git a/src/main/java/ferramong/reports/controllers/ReportsController.java b/src/main/java/ferramong/reports/controllers/ReportsController.java index b53351a..9d4c99e 100644 --- a/src/main/java/ferramong/reports/controllers/ReportsController.java +++ b/src/main/java/ferramong/reports/controllers/ReportsController.java @@ -86,15 +86,6 @@ public void generateOngReport(@PathVariable("start") byte[] pdf = reportService.exportReportSales(start,end); streamReport(response, pdf, "vendas.pdf"); - /* - HttpHeaders headers = new HttpHeaders(); - - headers.setContentType(MediaType.parseMediaType("application/pdf")); - - headers.add("Content-Disposition", "inline; filename=" + "vendas.pdf"); - headers.setCacheControl("must-revalidate, post-check=0, pre-check=0"); - ResponseEntity response = new ResponseEntity(pdf, headers, HttpStatus.OK); - return response;*/ } protected void streamReport(HttpServletResponse response, byte[] data, String name) @@ -112,18 +103,7 @@ protected void streamReport(HttpServletResponse response, byte[] data, String na @GetMapping(value="/purchases/report/{id_dweller}", produces = MediaType.APPLICATION_JSON_VALUE) public void generateDwellerReport(@PathVariable("id_dweller") int idDweller, HttpServletResponse response) throws IOException, JRException { - - byte[] pdf = reportService.exportReportPurchases(idDweller); streamReport(response, pdf, "historico.pdf"); - /* - HttpHeaders headers = new HttpHeaders(); - - headers.setContentType(MediaType.parseMediaType("application/pdf")); - - headers.add("Content-Disposition", "inline; filename=" + "vendas.pdf"); - headers.setCacheControl("must-revalidate, post-check=0, pre-check=0"); - ResponseEntity response = new ResponseEntity(pdf, headers, HttpStatus.OK); - return response;*/ } } diff --git a/src/main/java/ferramong/reports/services/ReportService.java b/src/main/java/ferramong/reports/services/ReportService.java index 5f558d7..ad01e5a 100644 --- a/src/main/java/ferramong/reports/services/ReportService.java +++ b/src/main/java/ferramong/reports/services/ReportService.java @@ -1,6 +1,5 @@ package ferramong.reports.services; - import ferramong.reports.entities.Purchases; import ferramong.reports.models.DwellerHistory; import ferramong.reports.models.Payment; @@ -15,15 +14,6 @@ import java.time.LocalDate; import java.util.*; -/* - * Service - * Terá a lógica principal - * Não tem a ver com modelagem de dados - * Não faz comunicação direta com bd (quem faz é 'repositories') - * Não é um estado (por outro lado, 'models' são) - * Não modela dados (quem faz isso são os 'models') - */ - @Service @AllArgsConstructor public class ReportService { @@ -40,8 +30,8 @@ public byte[] exportReportSales(Date start, Date end) throws FileNotFoundExcepti JRBeanCollectionDataSource dataSource=new JRBeanCollectionDataSource(payments); Map parameters = new HashMap<>(); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource); - return JasperExportManager.exportReportToPdf(jasperPrint); + return JasperExportManager.exportReportToPdf(jasperPrint); } public byte[] exportReportPurchases(int idDweller) throws FileNotFoundException, JRException { @@ -58,19 +48,13 @@ public byte[] exportReportPurchases(int idDweller) throws FileNotFoundException, compras.get(i).setBalance(Purchases.getBalance(idDweller)); } - File file= ResourceUtils.getFile(path + "/historico.jrxml"); JasperReport jasperReport= JasperCompileManager.compileReport(file.getAbsolutePath()); JRBeanCollectionDataSource dataSource=new JRBeanCollectionDataSource(compras); Map parameters = new HashMap<>(); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource); - return JasperExportManager.exportReportToPdf(jasperPrint); + return JasperExportManager.exportReportToPdf(jasperPrint); } - - - - - }