-
Notifications
You must be signed in to change notification settings - Fork 1
Adds the endpoint to obtain a product list report of the chosen products by id #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,10 @@ | |
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.context.MessageSource; | ||
| import org.springframework.data.domain.*; | ||
| import org.springframework.http.HttpHeaders; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
| import sic.aspect.AccesoRolesPermitidos; | ||
| import sic.modelo.*; | ||
|
|
@@ -139,6 +143,18 @@ public void getListaDePrecios( | |
| } | ||
| } | ||
|
|
||
| @GetMapping("/productos/reporte") | ||
| public ResponseEntity<byte[]> getListaProductosSeleccionados( | ||
| @RequestParam long[] idProducto) { | ||
| HttpHeaders headers = new HttpHeaders(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could use "var" instead |
||
| headers.setContentType(MediaType.APPLICATION_PDF); | ||
| headers.add("content-disposition", "inline; filename=ProductList.pdf"); | ||
| headers.setCacheControl("must-revalidate, post-check=0, pre-check=0"); | ||
| byte[] reportePDF = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could use "var" instead, and all in one line |
||
| productoService.getListaDePreciosEnPdf(idProducto); | ||
| return new ResponseEntity<>(reportePDF, headers, HttpStatus.OK); | ||
| } | ||
|
|
||
| @DeleteMapping("/productos") | ||
| @AccesoRolesPermitidos({Rol.ADMINISTRADOR}) | ||
| public void eliminarMultiplesProductos(@RequestParam long[] idProducto) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1130,6 +1130,15 @@ public void getListaDePreciosEnPdf(BusquedaProductoCriteria criteria, long idSuc | |
| this.getListaDePrecios(productos, FORMATO_PDF), FORMATO_PDF); | ||
| } | ||
|
|
||
| @Override | ||
| public byte[] getListaDePreciosEnPdf(long[] idProductos) { | ||
| var productos = new ArrayList<Producto>(); | ||
| for (long idProducto : idProductos) { | ||
| productos.add(this.getProductoNoEliminadoPorId(idProducto)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very inefficient. The query should be something like SELECT xxxx FROM xxxx WHERE IN ..... |
||
| } | ||
| return this.getListaDePrecios(productos, FORMATO_PDF); | ||
| } | ||
|
|
||
| @Override | ||
| public void enviarListaDeProductosPorEmail(String mailTo, byte[] listaDeProductos, String formato) { | ||
| emailService.enviarEmail( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The response should be sent by email
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use case doesn't require the response to be send by email, the requirement is obtain a report of the chosen products the same way that others like Factura and Pedidos do, the email one it's beacause usualy whitout a product selection the list is to big and the request take to long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the user selects X (a very big number) products and sends the request? It's gonna crush. We need to cover all possible scenarios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happens that the access to the business email account it's only to very few people, and the new feature it's to vendedor use as "Presupuesto". Now I notice a problem, to use this as a vendedor we have to let it access to the product administration list, then the real solution it's to have a real "Presupuesto" report, this do not solve the original problem and carry a new one.