|
|
@ -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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|