La problema de empresa esta resuleta, parece que esta causada por error de hibernate que esta confindiendo id de empresa y sector por algun razon

master
vicsash 4 months ago
parent af0e7f5c69
commit 314fdab96c

@ -6,6 +6,7 @@ import com.example.proyectofinal.models.empresas.Sector;
import com.example.proyectofinal.repositories.empresas.ContactoRepository; import com.example.proyectofinal.repositories.empresas.ContactoRepository;
import com.example.proyectofinal.servicios.implemetations.empresas.IEmpresa; import com.example.proyectofinal.servicios.implemetations.empresas.IEmpresa;
import com.example.proyectofinal.servicios.implemetations.empresas.ISector; import com.example.proyectofinal.servicios.implemetations.empresas.ISector;
import jakarta.persistence.EntityManager;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -26,6 +27,8 @@ public class EmpressaController {
@Autowired @Autowired
private ContactoRepository contactoRepository; private ContactoRepository contactoRepository;
@Autowired
private EntityManager entityManager;
@Autowired @Autowired
IEmpresa empresaService; IEmpresa empresaService;
@ -103,22 +106,17 @@ public class EmpressaController {
@PostMapping("/empresa/update") @PostMapping("/empresa/update")
public ResponseEntity<String> updateEmpresa(Empresa empresa, @RequestParam("sector.id") Long sectorId, @RequestParam("joinedKeywords") String keywords){ public ResponseEntity<String> updateEmpresa(Empresa empresa, @RequestParam("sectorId") Long sectorId, @RequestParam("joinedKeywords") String keywords){
try{ try{
if (keywords != null && !keywords.isEmpty() && keywords.charAt(0) == ',') { if (keywords != null && !keywords.isEmpty() && keywords.charAt(0) == ',') {
keywords = keywords.substring(1); keywords = keywords.substring(1);
} }
assert keywords != null; assert keywords != null;
empresa.setKeywords(keywords); empresa.setKeywords(keywords);
entityManager.detach(empresa);
Sector existingSector = sectorService.findById(sectorId); Sector existingSector = sectorService.findById(sectorId);
if(existingSector != null) { if(existingSector != null) {
System.out.println("TEST UPDATE: EX-SEC " + existingSector.getNombre());
System.out.println("TEST UPDATE: EX-SEC " + existingSector.getId());
empresa.setSector(existingSector); empresa.setSector(existingSector);
System.out.println("TEST UPDATE: EMPRESA-NOMBRE " + empresa.getNombre());
System.out.println("TEST UPDATE: EMPRESA-ID " + empresa.getId());
System.out.println("TEST UPDATE: EMPRESA-SEC " + empresa.getSector().getNombre());
System.out.println("TEST UPDATE: EMPRESA-SEC-ID " + empresa.getSector().getId());
} else { } else {
return new ResponseEntity<>("Sector no encontrado", HttpStatus.BAD_REQUEST); return new ResponseEntity<>("Sector no encontrado", HttpStatus.BAD_REQUEST);
} }

@ -40,36 +40,37 @@ h1 {
} }
.table { .table {
width: 100%; width: 100%;
} table-layout: auto!important;
.table th, .table td.keywords-cell {
width: 200px; /* Adjust this value to your needs */
} }
.table thead th { .table thead th {
position: sticky; position: sticky;
top: 0; top: 0;
background: #fff; background: #fff;
z-index: 10; z-index: 10;
width: 200px; /* Set a specific width */ width: 300px !important; /* Set a specific width */
overflow: auto; /* Add overflow */
} }
.table td.keywords-cell { .table td{
display: inline-block !important;
overflow-x: auto !important;
text-overflow: clip !important;
border: 1px solid #ddd; border: 1px solid #ddd;
} }
.table-header, .keywords-cell { .table td.keywords-cell {
width: 200px; /* Adjust this value as needed */ overflow-y: auto !important; /* Enables vertical scrollbar if content exceeds cell height */
text-overflow: clip !important;
white-space: normal; /* Allows text to wrap to next line */
max-height: 25px !important;/* Set a specific height */
} }
.table tr td:first-child { .table tr td:first-child {
width: 50px; min-width: 150px !important;
overflow: hidden; }
text-overflow: ellipsis; .table td.nombre-cell {
min-width: 225px !important; /* Adjust this value to your needs */
text-align: left; /* Aligns the content to the left */
} }
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
.table { .table {
} }
} }
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
.table td, .table th { .table td, .table th {
font-size: 14px; font-size: 14px;
@ -84,7 +85,7 @@ h1 {
@media screen and (max-width: 400px) { @media screen and (max-width: 400px) {
.table td, .table th { .table td, .table th {
font-size: 12px; font-size: 12px;
padding: 3px; padding: 2px;
} }
#edit-icon, #delete-icon { #edit-icon, #delete-icon {
@ -138,18 +139,18 @@ html, body {
} }
.edit-icon { .edit-icon {
color: #ffa600; color: #ffa600;
margin-right: 10px; margin-right: 5px;
margin-left: 10px; margin-left: 5px;
font-size: 24px; font-size: 20px;
} }
.delete-icon { .delete-icon {
color: red; color: red;
margin-left: 5px; margin-left: 5px;
font-size: 24px; font-size: 20px;
} }
#create-icon { #create-icon {
color: green; color: green;
font-size: 24px; font-size: 20px;
margin-left: 10px; margin-left: 10px;
} }
.inactive { .inactive {

@ -113,7 +113,7 @@
<div class ="form-group row"> <div class ="form-group row">
<label class="col-sm-3 col-form-label" for="sector">Sector</label> <label class="col-sm-3 col-form-label" for="sector">Sector</label>
<div class = "col-sm-9"> <div class = "col-sm-9">
<select th:field="*{sector.id}" class="form-control" id="sector"> <select name="sectorId" class="form-control" id="sector">
<option th:each="sector : ${sectores}" th:value="${sector.id}" th:text="${sector.nombre}" th:selected="${sector.id == empresa.sector.id}"></option> <option th:each="sector : ${sectores}" th:value="${sector.id}" th:text="${sector.nombre}" th:selected="${sector.id == empresa.sector.id}"></option>
</select> </select>
</div> </div>

@ -8,7 +8,6 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Lista: Alumnos</title> <title>Lista: Alumnos</title>
<style> <style>
</style> </style>
</head> </head>
<body> <body>
@ -93,7 +92,7 @@
</thead> </thead>
<tbody> <tbody>
<tr class="cell" th:each="alumno :${alumnos}" th:data-id="${alumno.id}"> <tr class="cell" th:each="alumno :${alumnos}" th:data-id="${alumno.id}">
<td> <td class="nombre-cell">
<i class="edit-icon fas fa-pen-square"></i> <i class="edit-icon fas fa-pen-square"></i>
<i class="delete-icon fas fa-ban hide-icon"></i> <i class="delete-icon fas fa-ban hide-icon"></i>
[[${alumno.nombre}]] [[${alumno.nombre}]]

@ -299,7 +299,7 @@
} }
}); });
}); });
/*
/////////////////MOUSE SROLL FOR KEYWORD AND SKILLS////////////////////// /////////////////MOUSE SROLL FOR KEYWORD AND SKILLS//////////////////////
const cells = document.querySelectorAll('.keywords-cell'); const cells = document.querySelectorAll('.keywords-cell');
cells.forEach(cell => { cells.forEach(cell => {
@ -307,7 +307,7 @@
e.preventDefault(); e.preventDefault();
this.scrollLeft += e.deltaY; this.scrollLeft += e.deltaY;
}, { passive: false }); }, { passive: false });
}); });*/
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save

Powered by INFORMATICA.FP.EDU.ES.