Skip to content

Commit

Permalink
Old comments - remove
Browse files Browse the repository at this point in the history
  • Loading branch information
williamniemiec committed Apr 29, 2021
1 parent a5075a6 commit e80bf42
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 43 deletions.
5 changes: 0 additions & 5 deletions src/main/java/ferramong/reports/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
20 changes: 0 additions & 20 deletions src/main/java/ferramong/reports/controllers/ReportsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte[]> response = new ResponseEntity<byte[]>(pdf, headers, HttpStatus.OK);
return response;*/
}

protected void streamReport(HttpServletResponse response, byte[] data, String name)
Expand All @@ -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<byte[]> response = new ResponseEntity<byte[]>(pdf, headers, HttpStatus.OK);
return response;*/
}
}
20 changes: 2 additions & 18 deletions src/main/java/ferramong/reports/services/ReportService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ferramong.reports.services;


import ferramong.reports.entities.Purchases;
import ferramong.reports.models.DwellerHistory;
import ferramong.reports.models.Payment;
Expand All @@ -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 {
Expand All @@ -40,8 +30,8 @@ public byte[] exportReportSales(Date start, Date end) throws FileNotFoundExcepti
JRBeanCollectionDataSource dataSource=new JRBeanCollectionDataSource(payments);
Map<String, Object> 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 {
Expand All @@ -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<String, Object> parameters = new HashMap<>();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
return JasperExportManager.exportReportToPdf(jasperPrint);

return JasperExportManager.exportReportToPdf(jasperPrint);
}





}

0 comments on commit e80bf42

Please sign in to comment.