|
|
@@ -8,11 +8,11 @@ import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@@ -88,20 +88,10 @@ public class OrganController {
|
|
|
* Endpoint para getTitulacionsByTypeCentre
|
|
|
*/
|
|
|
@GetMapping("/getTitulacionsByTypeCentre/{lugar}/{type}")
|
|
|
- public ResponseEntity<?> getTitulacionsByTypeCentre(@PathVariable Integer lugar, @PathVariable Integer type) {
|
|
|
- try {
|
|
|
- List<Organ> organList = os.getTitulacionsByTypeCentre(lugar, type);
|
|
|
- List<OrganTransferDTO> organDTOList = new ArrayList<>();
|
|
|
-
|
|
|
- for(Organ org: organList) {
|
|
|
- organDTOList.add(new OrganTransferDTO(org));
|
|
|
- }
|
|
|
-
|
|
|
- return ResponseEntity.ok(organDTOList);
|
|
|
- } catch(Exception e) {
|
|
|
- return ResponseEntity.badRequest().body("Error al obtener los organos" +
|
|
|
- " por lugar y ambit: " + e.getMessage());
|
|
|
- }
|
|
|
+ public List<OrganTransferDTO> getTitulacionsByTypeCentre(@PathVariable Integer lugar, @PathVariable Integer type) {
|
|
|
+ return os.getTitulacionsByTypeCentre(lugar, type).stream()
|
|
|
+ .map(OrganTransferDTO::new)
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@GetMapping("/existsOrg/{tlugar}/{idTitulacio}")
|
|
|
@@ -110,21 +100,10 @@ public class OrganController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getTitulacionsByCentreTambit/{centre}/{tambit}")
|
|
|
- public ResponseEntity<?> getTitulacionsByCentreTambit(@PathVariable Integer centre, @PathVariable String tambit) {
|
|
|
- try {
|
|
|
- List<Organ> organList = os.findActiveTitulacionsByCentreTambit(centre, tambit);
|
|
|
- List<OrganTransferDTO> organDTOList = new ArrayList<>();
|
|
|
-
|
|
|
- for(Organ org: organList) {
|
|
|
- System.out.println(org.getNomCas());
|
|
|
- organDTOList.add(new OrganTransferDTO(org));
|
|
|
- }
|
|
|
-
|
|
|
- return ResponseEntity.ok(organDTOList);
|
|
|
- } catch(Exception e) {
|
|
|
- return ResponseEntity.badRequest().body("Error al obtener los organos" +
|
|
|
- " por lugar y ambit: " + e.getMessage());
|
|
|
- }
|
|
|
+ public List<OrganTransferDTO> getTitulacionsByCentreTambit(@PathVariable Integer centre, @PathVariable String tambit) {
|
|
|
+ return os.findActiveTitulacionsByCentreTambit(centre, tambit).stream()
|
|
|
+ .map(OrganTransferDTO::new)
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getTitulacions/supervisor")
|
|
|
@@ -152,35 +131,17 @@ public class OrganController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getCentres")
|
|
|
- public ResponseEntity<?> getCentres() {
|
|
|
- try {
|
|
|
- List<Organ> organList = os.getCentres();
|
|
|
- List<OrganDTO> organDTOList = new ArrayList<>();
|
|
|
-
|
|
|
- for(Organ org: organList) {
|
|
|
- organDTOList.add(new OrganDTO(org));
|
|
|
- }
|
|
|
-
|
|
|
- return ResponseEntity.ok(organDTOList);
|
|
|
- } catch(Exception e) {
|
|
|
- return ResponseEntity.badRequest().body("Error al obtener los centros: " + e.getMessage());
|
|
|
- }
|
|
|
+ public List<OrganDTO> getCentres() {
|
|
|
+ return os.getActiveCentres().stream()
|
|
|
+ .map(OrganDTO::new)
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getActiveCentres")
|
|
|
- public ResponseEntity<?> getActiveCentres() {
|
|
|
- try {
|
|
|
- List<Organ> organList = os.getActiveCentres();
|
|
|
- List<OrganDTO> organDTOList = new ArrayList<>();
|
|
|
-
|
|
|
- for(Organ org: organList) {
|
|
|
- organDTOList.add(new OrganDTO(org));
|
|
|
- }
|
|
|
-
|
|
|
- return ResponseEntity.ok(organDTOList);
|
|
|
- } catch(Exception e) {
|
|
|
- return ResponseEntity.badRequest().body("Error al obtener los centros: " + e.getMessage());
|
|
|
- }
|
|
|
+ public List<OrganDTO> getActiveCentres() {
|
|
|
+ return os.getActiveCentres().stream()
|
|
|
+ .map(OrganDTO::new)
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
// Funciones ajax
|
|
|
@@ -435,4 +396,9 @@ public class OrganController {
|
|
|
model.put("sup_centers", centres);
|
|
|
return model;
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/getEquivalents")
|
|
|
+ public List<Integer> getEquivalents(@RequestParam Integer lugar, @RequestParam String tlugar) {
|
|
|
+ return os.getEquivalents(lugar, tlugar);
|
|
|
+ }
|
|
|
}
|