Compare commits

..

2 Commits

@ -32,7 +32,6 @@ dependencies {
implementation 'org.hibernate.validator:hibernate-validator:8.0.0.Final' implementation 'org.hibernate.validator:hibernate-validator:8.0.0.Final'
implementation 'io.jsonwebtoken:jjwt:0.9.1' implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'javax.xml.bind:jaxb-api:2.3.1' implementation 'javax.xml.bind:jaxb-api:2.3.1'
} }
tasks.named('test') { tasks.named('test') {

@ -1,4 +1,6 @@
FROM openjdk:17-bullseye FROM debian:11
RUN apt update && apt install -y openjdk-17-jre
COPY pedidos.core-0.0.1-SNAPSHOT.jar /app.jar COPY pedidos.core-0.0.1-SNAPSHOT.jar /app.jar

@ -4,6 +4,7 @@ services:
backend: backend:
image: pedidosbackend:1 image: pedidosbackend:1
environment: environment:
- TZ=America/Guayaquil
- SPRING_PROFILES_ACTIVE=prod - SPRING_PROFILES_ACTIVE=prod
ports: ports:
- target: 8080 - target: 8080
@ -12,7 +13,7 @@ services:
mode: host mode: host
networks: networks:
- desarrollo_net - desarrollo_net
dbclases: db:
image: postgres:15.0-bullseye image: postgres:15.0-bullseye
environment: environment:
- TZ=America/Guayaquil - TZ=America/Guayaquil

Binary file not shown.

Binary file not shown.

@ -107,7 +107,7 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception)
throws IOException, ServletException { throws IOException, ServletException {
response.setStatus(401); response.setStatus(401);
response.setContentType("application/json; charset=utf-8"); response.setContentType("application/json");
response.getWriter().append(json(exception.getLocalizedMessage())); response.getWriter().append(json(exception.getLocalizedMessage()));
} }
@ -117,7 +117,7 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
return "{\"timestamp\": " + date + ", " return "{\"timestamp\": " + date + ", "
+ "\"status\": 401, " + "\"status\": 401, "
+ "\"error\": \"Not authorized\", " + "\"error\": \"Not authorized\", "
+ "\"message\": \""+ message+ "\", " + "\"message\": "+ message+ ", "
+ "\"path\": \"/login\"}"; + "\"path\": \"/login\"}";
} }
} }

@ -1,8 +1,5 @@
package pedidos.pedidos.core.authz.conf; package pedidos.pedidos.core.authz.conf;
import java.util.Arrays;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -11,10 +8,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import pedidos.pedidos.core.authz.service.UserService; import pedidos.pedidos.core.authz.service.UserService;
@Configuration @Configuration
@ -30,8 +23,6 @@ public class SecurityConfiguration{
http http
.csrf().disable() .csrf().disable()
.cors()
.and()
.authorizeHttpRequests((authorize) -> authorize .authorizeHttpRequests((authorize) -> authorize
.requestMatchers("/login").permitAll() .requestMatchers("/login").permitAll()
.requestMatchers("/swagger-ui/*").permitAll() .requestMatchers("/swagger-ui/*").permitAll()
@ -45,33 +36,4 @@ public class SecurityConfiguration{
return http.build(); return http.build();
} }
@Bean
protected CorsConfigurationSource corsConfigurationSource() {
final CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Collections.singletonList("http://localhost:3000"));
configuration.setAllowedMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"));
// NOTE: setAllowCredentials(true) is important,
// otherwise, the value of the 'Access-Control-Allow-Origin' header in the response
// must not be the wildcard '*' when the request's credentials mode is 'include'.
configuration.setAllowCredentials(true);
// NOTE: setAllowedHeaders is important!
// Without it, OPTIONS preflight request will fail with 403 Invalid CORS request
configuration.setAllowedHeaders(Arrays.asList(
"Authorization",
"Accept",
"Cache-Control",
"Content-Type",
"Origin",
"x-csrf-token",
"x-requested-with"
));
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
} }

@ -1,7 +1,6 @@
package pedidos.pedidos.core.cliente; package pedidos.pedidos.core.cliente;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -12,16 +11,6 @@ import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.core.type.TypeReference;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.persistence.ManyToOne;
import pedidos.pedidos.core.compania.CompaniaService;
import java.util.List; import java.util.List;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Map; import java.util.Map;
@ -29,14 +18,10 @@ import java.util.Map;
@RestController @RestController
@RequestMapping("api/cliente") @RequestMapping("api/cliente")
@CrossOrigin({"*"}) @CrossOrigin({"*"})
@Tag(name = "Controlador de Cliente (Tabla cliente)")
public class ClienteController { public class ClienteController {
@Autowired ClienteService clienteService; @Autowired ClienteService clienteService;
@Autowired CompaniaService companiaService;
@PreAuthorize("hasAuthority('Cliente_LeerTodos')")
@GetMapping("/") @GetMapping("/")
@Operation(summary = "Obtiene todos los clientes, requiere el permiso Cliente_LeerTodos ")
public List<Cliente> findAll(){ public List<Cliente> findAll(){
return clienteService.findAll(); return clienteService.findAll();
} }
@ -47,7 +32,6 @@ public class ClienteController {
} }
@PostMapping("/") @PostMapping("/")
@PreAuthorize("hasAuthority('Cliente_Crear')")
public Cliente save(@RequestBody Cliente entity){ public Cliente save(@RequestBody Cliente entity){
return clienteService.save(entity); return clienteService.save(entity);
} }
@ -74,20 +58,9 @@ public class ClienteController {
// utiliza reflection para establecer el valor del campo en la entidad // utiliza reflection para establecer el valor del campo en la entidad
try { try {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
Field campoEntidad = Cliente.class.getDeclaredField(fieldName); Field campoEntidad = Cliente.class.getDeclaredField(fieldName);
campoEntidad.setAccessible(true); campoEntidad.setAccessible(true);
if (campoEntidad.isAnnotationPresent(ManyToOne.class)) {
java.util.LinkedHashMap<String, Long> keyValue = mapper.convertValue(fieldValue, new TypeReference<java.util.LinkedHashMap<String, Long>>(){});
Object relatedEntity = companiaService.findById(keyValue.get("id"));
campoEntidad.set(cliente, relatedEntity);
}else{
campoEntidad.set(cliente, fieldValue); campoEntidad.set(cliente, fieldValue);
}
} catch (NoSuchFieldException | IllegalAccessException ex) { } catch (NoSuchFieldException | IllegalAccessException ex) {
// maneja la excepción si ocurre algún error al acceder al campo // maneja la excepción si ocurre algún error al acceder al campo
} }

@ -1,14 +1,11 @@
package pedidos.pedidos.core.compania; package pedidos.pedidos.core.compania;
import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@ -16,13 +13,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import jakarta.persistence.ManyToOne;
import pedidos.pedidos.core.cliente.Cliente;
@RestController @RestController
@RequestMapping("api/compania") @RequestMapping("api/compania")
@CrossOrigin({"*"}) @CrossOrigin({"*"})
@ -60,37 +50,4 @@ public class CompaniaController {
companiaService.deleteById(id); companiaService.deleteById(id);
} }
@PatchMapping("/{id}/")
public Compania partialUpdate(@PathVariable long id, @RequestBody Map<String, Object> fields){
Compania entity = findById(id);
// itera sobre los campos que se desean actualizar
for (Map.Entry<String, Object> field : fields.entrySet()) {
String fieldName = field.getKey();
Object fieldValue = field.getValue();
// utiliza reflection para establecer el valor del campo en la entidad
try {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
Field campoEntidad = Compania.class.getDeclaredField(fieldName);
campoEntidad.setAccessible(true);
if (campoEntidad.isAnnotationPresent(ManyToOne.class)) {
java.util.LinkedHashMap<String, Long> keyValue = mapper.convertValue(fieldValue, new TypeReference<java.util.LinkedHashMap<String, Long>>(){});
Object relatedEntity = companiaService.findById(keyValue.get("id"));
campoEntidad.set(entity, relatedEntity);
}else{
campoEntidad.set(entity, fieldValue);
}
} catch (NoSuchFieldException | IllegalAccessException ex) {
// maneja la excepción si ocurre algún error al acceder al campo
}
}
return update(entity);
}
} }

@ -1,24 +0,0 @@
package pedidos.pedidos.core.pedidos;
import java.math.BigDecimal;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import lombok.Data;
import pedidos.pedidos.core.producto.Producto;
@Data
@Entity
public class DetallePedido {
@Id
@GeneratedValue(strategy = GenerationType.AUTO )
private long id;
@ManyToOne
private Producto producto;
private Integer cantidad;
private BigDecimal precio;
}

@ -1,31 +0,0 @@
package pedidos.pedidos.core.pedidos;
import java.util.ArrayList;
import java.util.List;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import lombok.Data;
import pedidos.pedidos.core.cliente.Cliente;
@Data
@Entity
public class Pedido {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE )
private long id;
private String numero;
@ManyToOne
private Cliente cliente;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = false)
@JoinColumn(name="pedido_id")
private List<DetallePedido> detalle = new ArrayList<>();
}

@ -1,135 +0,0 @@
package pedidos.pedidos.core.pedidos;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import pedidos.pedidos.core.cliente.ClienteService;
@RestController
@RequestMapping("/api/pedido")
@CrossOrigin({"*"})
public class PedidoController {
@Autowired
PedidoService service;
@Autowired ClienteService clienteService;
@GetMapping("/{id}/")
public Pedido findById(@PathVariable Integer id){
return service.findById(id);
}
@GetMapping("/")
public List<Pedido> findAll(){
return service.findAll();
}
//Create
//Delimitador de acceso (public, private), tipo de dato de retorno, nombre del método, parametros de entrada { Sentencias }
@PostMapping("/")
public Pedido save (@RequestBody Pedido entity ){
return service.save(entity);
}
@PutMapping("/")
public Pedido update (@RequestBody Pedido entity){
return service.save(entity);
}
@DeleteMapping("/{id}/")
public void deleteById(@PathVariable Integer id){
service.deleteById(id);
}
@PatchMapping("/{id}/")
public Pedido partialUpdate(@PathVariable long id, @RequestBody Map<String, Object> fields){
Pedido entity = service.findById(id);
// itera sobre los campos que se desean actualizar
for (Map.Entry<String, Object> field : fields.entrySet()) {
String fieldName = field.getKey();
Object fieldValue = null;
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
java.lang.reflect.Field campoEntidad = org.springframework.util.ReflectionUtils.findField(Pedido.class, fieldName);
campoEntidad.setAccessible(true);
if (fieldName.equals("precio")){
fieldValue= new BigDecimal (field.getValue().toString());
}else if (fieldName.equals("creado")){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm");
fieldValue = LocalDateTime.parse(field.getValue().toString(),formatter);
}else if (fieldName.equals("detalle")){
List<?> originalList = mapper.convertValue(fields.get(fieldName), new TypeReference<List<?>>() {});
try {
Class<?> type = Class.forName("pedidos.pedidos.core.pedidos.DetallePedido");
List<Object> newList = new java.util.ArrayList<>();
for (Object o : originalList) {
newList.add(mapper.convertValue(o, type));
}
campoEntidad.set(entity,newList);
} catch(ClassNotFoundException ex) {
System.out.println("Error occuured");
ex.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else {
fieldValue =field.getValue();
}
// utiliza reflection para establecer el valor del campo en la entidad
try {
//Field campoEntidad = Pedido.class.getDeclaredField(fieldName);
if (campoEntidad.isAnnotationPresent(ManyToOne.class)) {
java.util.LinkedHashMap<String, Long> keyValue = mapper.convertValue(fieldValue, new TypeReference<java.util.LinkedHashMap<String, Long>>(){});
Object relatedEntity = clienteService.findById(keyValue.get("id"));
campoEntidad.set(entity, relatedEntity);
} if (campoEntidad.isAnnotationPresent(OneToMany.class)) {
//java.util.LinkedHashMap<String, Long> keyValue = mapper.convertValue(fieldValue, new TypeReference<java.util.LinkedHashMap<String, Long>>(){});
//Object relatedEntity = entidadService.findById(keyValue.get("id"));
//campoEntidad.set(entity, relatedEntity);
}
else{
//campoEntidad.set(entity, fieldValue);
campoEntidad.set(entity, mapper.convertValue(fieldValue, campoEntidad.getType()));
}
} catch ( IllegalAccessException ex) {
// maneja la excepción si ocurre algún error al acceder al campo
}
}
return update(entity);
}
}

@ -1,10 +0,0 @@
package pedidos.pedidos.core.pedidos;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
public interface PedidoRepository extends CrudRepository <Pedido, Long> {
List<Pedido> findAll();
}

@ -1,28 +0,0 @@
package pedidos.pedidos.core.pedidos;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class PedidoService {
@Autowired
PedidoRepository repository;
public Pedido save( Pedido entity){
return repository.save(entity);
}
public void deleteById(long id){
repository.deleteById(id);
}
public Pedido findById(long id){
return repository.findById(id).orElse(null);
}
public List<Pedido> findAll(){
return repository.findAll();
}
}

@ -8,7 +8,6 @@ import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType; import jakarta.persistence.GenerationType;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import lombok.Data; import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
@Data @Data
@Entity @Entity
@ -16,12 +15,11 @@ public class Producto {
//Atributos: Delimitador de acceso, Tipo de dato, Nombre del atributo //Atributos: Delimitador de acceso, Tipo de dato, Nombre del atributo
@Id @Id
@GeneratedValue(strategy = GenerationType.SEQUENCE) @GeneratedValue(strategy = GenerationType.AUTO)
private long id; private long id;
private String nombre; private String nombre;
private String codigo; private String codigo;
private BigDecimal precio; private BigDecimal precio;
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm", shape = JsonFormat.Shape.STRING)
private LocalDateTime creado = LocalDateTime.now();; private LocalDateTime creado = LocalDateTime.now();;
} }

@ -11,20 +11,10 @@ import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Map; import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.core.type.TypeReference;
import jakarta.persistence.ManyToOne;
@RestController @RestController
@RequestMapping("api/producto") @RequestMapping("api/producto")
@ -32,6 +22,7 @@ import jakarta.persistence.ManyToOne;
public class ProductoController { public class ProductoController {
@Autowired ProductoService productoService; @Autowired ProductoService productoService;
@PreAuthorize("hasAuthority('Product_Read')")
@GetMapping("/") @GetMapping("/")
public List<Producto> findAll(){ public List<Producto> findAll(){
return productoService.findAll(); return productoService.findAll();
@ -60,51 +51,22 @@ public class ProductoController {
@PatchMapping("/{id}/") @PatchMapping("/{id}/")
public Producto partialUpdate(@PathVariable long id, @RequestBody Map<String, Object> fields){ public Producto partialUpdate(@PathVariable long id, @RequestBody Map<String, Object> fields){
Producto entity = findById(id); Producto producto = findById(id);
// itera sobre los campos que se desean actualizar // itera sobre los campos que se desean actualizar
for (Map.Entry<String, Object> field : fields.entrySet()) { for (Map.Entry<String, Object> field : fields.entrySet()) {
String fieldName = field.getKey(); String fieldName = field.getKey();
Object fieldValue = null; Object fieldValue = field.getValue();
if (fieldName.equals("precio")){
fieldValue= new BigDecimal (field.getValue().toString());
}else if (fieldName.equals("creado")){
DateTimeFormatter formatter;
String dateString = field.getValue().toString();
if (field.getValue().toString().length()>16){
dateString = dateString.substring(0, 16);
}
formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm");
fieldValue = LocalDateTime.parse(dateString,formatter);
}else {
fieldValue =field.getValue();
}
// utiliza reflection para establecer el valor del campo en la entidad // utiliza reflection para establecer el valor del campo en la entidad
try { try {
ObjectMapper mapper = new ObjectMapper(); Field campoEntidad = Producto.class.getDeclaredField(fieldName);
mapper.registerModule(new JavaTimeModule());
//Field campoEntidad = Producto.class.getDeclaredField(fieldName);
java.lang.reflect.Field campoEntidad = org.springframework.util.ReflectionUtils.findField(Producto.class, fieldName);
campoEntidad.setAccessible(true); campoEntidad.setAccessible(true);
campoEntidad.set(producto, fieldValue);
} catch (NoSuchFieldException | IllegalAccessException ex) {
if (campoEntidad.isAnnotationPresent(ManyToOne.class)) {
//java.util.LinkedHashMap<String, Long> keyValue = mapper.convertValue(fieldValue, new TypeReference<java.util.LinkedHashMap<String, Long>>(){});
//Object relatedEntity = entidadService.findById(keyValue.get("id"));
//campoEntidad.set(entity, relatedEntity);
}else{
//campoEntidad.set(entity, fieldValue);
campoEntidad.set(entity, mapper.convertValue(fieldValue, campoEntidad.getType()));
}
} catch ( IllegalAccessException ex) {
// maneja la excepción si ocurre algún error al acceder al campo // maneja la excepción si ocurre algún error al acceder al campo
} }
} }
return update(entity); return update(producto);
} }
} }

@ -3,7 +3,6 @@ package pedidos.pedidos.core.producto;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigInteger;
@Service @Service
public class ProductoService { public class ProductoService {

@ -1,6 +1,7 @@
spring.datasource.url=jdbc:postgresql://dbclases:5432/pedidosdb spring.datasource.url=jdbc:postgresql://db:5432/pedidosdb
spring.datasource.username=postgres spring.datasource.username=postgres
spring.datasource.password=postgres spring.datasource.password=postgres
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
#spring.jpa.show-sql=true #spring.jpa.show-sql=true
server.port=8080 #spring.sql.init.mode=always
server.port=8081
Loading…
Cancel
Save