mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-09 12:29:13 +00:00
trabajando en la vista del pedido
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.imprimelibros.erp.pedidos;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.security.Principal;
|
||||
@ -12,6 +13,7 @@ import java.util.Map;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import com.imprimelibros.erp.common.Utils;
|
||||
import com.imprimelibros.erp.datatables.DataTable;
|
||||
@ -31,13 +33,15 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
public class PedidosController {
|
||||
|
||||
private final PedidoRepository repoPedido;
|
||||
private final PedidoService pedidoService;
|
||||
private final UserDao repoUser;
|
||||
private final MessageSource messageSource;
|
||||
private final PedidoLineaRepository repoPedidoLinea;
|
||||
|
||||
public PedidosController(PedidoRepository repoPedido, UserDao repoUser, MessageSource messageSource,
|
||||
public PedidosController(PedidoRepository repoPedido, PedidoService pedidoService, UserDao repoUser, MessageSource messageSource,
|
||||
PedidoLineaRepository repoPedidoLinea) {
|
||||
this.repoPedido = repoPedido;
|
||||
this.pedidoService = pedidoService;
|
||||
this.repoUser = repoUser;
|
||||
this.messageSource = messageSource;
|
||||
this.repoPedidoLinea = repoPedidoLinea;
|
||||
@ -162,4 +166,21 @@ public class PedidosController {
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/view/{id}")
|
||||
public String verPedido(
|
||||
@PathVariable(name = "id", required = true) Long id,
|
||||
Model model, Locale locale) {
|
||||
|
||||
Boolean isAdmin = Utils.isCurrentUserAdmin();
|
||||
if (isAdmin) {
|
||||
model.addAttribute("isAdmin", true);
|
||||
} else {
|
||||
model.addAttribute("isAdmin", false);
|
||||
}
|
||||
List<Map<String, Object>> lineas = pedidoService.getLineas(id, locale);
|
||||
model.addAttribute("lineas", lineas);
|
||||
model.addAttribute("id", id);
|
||||
return "imprimelibros/pedidos/pedidos-view";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user