Commit 98996e3d authored by charles53681's avatar charles53681

aeropuerto-v1

parents
Pipeline #307 failed with stages
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
FROM openjdk:8
COPY target/aeropuerto-back-0.0.1-SNAPSHOT.jar /demo2.jar
CMD ["java","-jar","/demo2.jar"]
\ No newline at end of file
This diff is collapsed.
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>aeropuerto-back</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>aeropuerto-back</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.example.aeropuertoback.AeropuertoBackApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.example.aeropuertoback;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
//@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
@SpringBootApplication
public class AeropuertoBackApplication {
public static void main(String[] args) {
SpringApplication.run(AeropuertoBackApplication.class, args);
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.entity.Aeropuerto;
import com.example.aeropuertoback.service.aeropuerto.IAeropuertoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(value = "/aeropuertos")
@CrossOrigin(origins = "http://localhost:4200")
public class AeropuertoController {
@Autowired
private IAeropuertoService aeropuertoService;
@GetMapping(value = "/listar")
public List<Aeropuerto> listar(){
return aeropuertoService.findAll();
}
@PostMapping(value = "/agregar")
public Aeropuerto guardarPasajero(@RequestBody Aeropuerto aeropuerto){
return aeropuertoService.save(aeropuerto);
}
@PutMapping(value = "/actualizar/{id}")
public Aeropuerto actualizarPasajero(@PathVariable Integer id, @RequestBody Aeropuerto aeropuerto){
Aeropuerto editarAeropuerto = aeropuertoService.findOne(id);
aeropuerto.setId(editarAeropuerto.getId());
return aeropuertoService.save(aeropuerto);
}
@GetMapping(value = "/byId/{id}")
public Aeropuerto listarPorId(@PathVariable Integer id){
return aeropuertoService.findOne(id);
}
@DeleteMapping(value="/eliminar/{id}")
public void eliminarAeropuerto(@PathVariable Integer id){
aeropuertoService.delete(id);
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.entity.AgentesAuth;
import com.example.aeropuertoback.service.agenteAuth.IAgenteAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping(value = "/agentes-auth")
public class AgenteAuthController {
@Autowired
private IAgenteAuthService iAgenteAuthService;
@GetMapping(value = "/listar")
public List<AgentesAuth> listar(){
return iAgenteAuthService.findAll();
}
@PostMapping(value = "/agregar", consumes = MediaType.APPLICATION_JSON_VALUE)
public AgentesAuth guardarPasajero(@RequestBody AgentesAuth agentesAuth){
return iAgenteAuthService.save(agentesAuth);
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.entity.AgenteReserva;
import com.example.aeropuertoback.service.agente.IAgenteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(value = "/agentes")
@CrossOrigin(origins = "http://localhost:4200")
public class AgenteController {
@Autowired
private IAgenteService agenteService;
@GetMapping(value = "/listar")
public List<AgenteReserva> listar(){
return agenteService.findAll();
}
@PostMapping(value = "/agregar")
public AgenteReserva guardarPasajero(@RequestBody AgenteReserva agenteReserva){
return agenteService.save(agenteReserva);
}
@PutMapping(value = "/actualizar/{id}")
public AgenteReserva actualizarPasajero(@PathVariable Integer id, @RequestBody AgenteReserva agenteReserva){
AgenteReserva editarAgente = agenteService.findOne(id);
agenteReserva.setId(editarAgente.getId());
agenteReserva.setAgenteAuth(editarAgente.getAgenteAuth());
return agenteService.save(agenteReserva);
}
@GetMapping(value = "/byId/{id}")
public AgenteReserva listarPorId(@PathVariable Integer id){
return agenteService.findOne(id);
}
@DeleteMapping(value="/eliminar/{id}")
public void aliminarAgente(@PathVariable Integer id) {
agenteService.delete(id);
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.dao.ItinerarioRepository;
import com.example.aeropuertoback.entity.*;
import com.example.aeropuertoback.service.aeropuerto.IAeropuertoService;
import com.example.aeropuertoback.service.escala.IEscalaService;
import com.example.aeropuertoback.service.vuelo.IVueloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping(value = "/escalas")
public class EscalaController {
@Autowired
private IEscalaService escalaService;
@Autowired
private IAeropuertoService aeropuertoService;
@Autowired
private IVueloService vueloService;
@Autowired
private ItinerarioRepository itinerarioRepository;
@GetMapping(value = "/listar")
public List<Escala> listar(){
return escalaService.findAll();
}
@PostMapping(value = "/agregar", consumes = MediaType.APPLICATION_JSON_VALUE)
public Escala guardarVuelo(@RequestBody Escala escala){
Aeropuerto aeropuertoOrigen = aeropuertoService.findOne(escala.getCodigoAeropuertoOrigen().getId());
Aeropuerto aeropuertoDestino = aeropuertoService.findOne(escala.getCodigoAeropuertoDestino().getId());
Vuelo vuelo = vueloService.findOne(escala.getCodigoVuelo().getId());
escala.setCodigoAeropuertoOrigen(aeropuertoOrigen);
escala.setCodigoAeropuertoDestino(aeropuertoDestino);
escala.setCodigoVuelo(vuelo);
return escalaService.save(escala);
}
@GetMapping("listar/{id}/vuelos")
public List<Escala> listarVuelosByEscalas(@PathVariable Integer id){
List<Escala> escala = vueloService.findOne(id).getEscalas();
return escala;
}
@PostMapping("/reserva/{id}")
public Escala addEscala(@PathVariable(value = "id") Integer id, @RequestBody Escala escalaRequest) {
Escala escala = itinerarioRepository.findById(id).map(itinerarioReserva -> {
Integer escalaId = escalaRequest.getId();
Escala _esc = escalaService.findOne(escalaId);
itinerarioReserva.addEscala(_esc);
itinerarioRepository.save(itinerarioReserva);
return _esc;
}).orElseThrow(null);
return escala;
}
@DeleteMapping(value="/eliminar/{id}")
public void eliminarEscala(@PathVariable Integer id){
escalaService.delete(id);
}
@GetMapping("escala/{id}")
public Integer getVueloByEscalaId(@PathVariable Integer id){
return escalaService.findOne(id).getCodigoVuelo().getId();
}
}
package com.example.aeropuertoback.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/app")
public class IndexController {
@Autowired
@GetMapping("/index")
public String index(){
return "index2";
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.entity.AgenteReserva;
import com.example.aeropuertoback.entity.ItinerarioReserva;
import com.example.aeropuertoback.entity.Pago;
import com.example.aeropuertoback.entity.Pasajero;
import com.example.aeropuertoback.service.agente.IAgenteService;
import com.example.aeropuertoback.service.itinerario.IItinerarioService;
import com.example.aeropuertoback.service.pasajero.IPasajeroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping(value = "/itinerarios")
public class ItinerarioReservaController {
@Autowired
private IItinerarioService itinerarioService;
@Autowired
private IPasajeroService iPasajeroService;
@Autowired
private IAgenteService iAgenteService;
@GetMapping(value = "/listar")
public List<ItinerarioReserva> listar(){
return itinerarioService.findAll();
}
@PostMapping(value = "/agregar")
public ItinerarioReserva guardarItinerario(@RequestBody ItinerarioReserva itinerarioReserva){
Pasajero pasajero = iPasajeroService.findOne(itinerarioReserva.getPasajero().getId());
AgenteReserva agenteReserva = iAgenteService.findOne(itinerarioReserva.getAgente().getId());
itinerarioReserva.setPasajero(pasajero);
itinerarioReserva.setAgente(agenteReserva);
return itinerarioService.save(itinerarioReserva);
}
@PutMapping(value = "/actualizar/{id}")
public ItinerarioReserva actualizarReserva(@PathVariable Integer id, @RequestBody ItinerarioReserva itinerarioReservaDeta){
ItinerarioReserva editReserva= itinerarioService.findOne(id);
editReserva.setEstado(itinerarioReservaDeta.getEstado());
return itinerarioService.save(editReserva);
}
@GetMapping("listar/{id}/pagos")
public List<Pago> listarFiestasDeLaPersona(@PathVariable Integer id){
ItinerarioReserva itinerarioReserva = itinerarioService.findOne(id);
return itinerarioReserva.getPagos();
}
@GetMapping(value = "/byId/{id}")
public ItinerarioReserva listarPorId(@PathVariable Integer id){
return itinerarioService.findOne(id);
}
@GetMapping(value = "/pasajero/{id}")
public List<ItinerarioReserva> listarReservaPorPasajeroId(@PathVariable Integer id){
return iPasajeroService.findOne(id).getItinerarioReservas();
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.dao.ItinerarioRepository;
import com.example.aeropuertoback.dao.PagoRepository;
import com.example.aeropuertoback.entity.Pago;
import com.example.aeropuertoback.service.pago.IPagoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping(value = "/pagos")
public class PagoController {
@Autowired
private IPagoService pagoService;
@Autowired
private PagoRepository pagoRepository;
@Autowired
private ItinerarioRepository itinerarioRepository;
@GetMapping(value = "/listar")
public List<Pago> listar(){
return pagoService.findAll();
}
@PostMapping(value = "/agregar", consumes = MediaType.APPLICATION_JSON_VALUE)
public Pago guardarPasajero(@RequestBody Pago pago){
return pagoService.save(pago);
}
@GetMapping(value = "/byId/{id}")
public Pago listarPorId(@PathVariable Integer id){
return pagoService.findOne(id);
}
@GetMapping("/reservas/{id}/pagos")
public List<Pago> getAllPagosByReservaId(@PathVariable(value = "id") Integer id) {
List<Pago> PagoA = pagoRepository.findPagosByItinerarioReservaId(id);
return PagoA;
}
@DeleteMapping(value="/eliminar/{id}")
public void eliminarPasajero(@PathVariable Integer id){
pagoService.delete(id);
}
@PostMapping("/reservas/{id}/pagos")
public Pago addTag(@PathVariable(value = "id") Integer id, @RequestBody Pago pagoRequest) {
Pago pago = itinerarioRepository.findById(id).map(itinerarioReserva -> {
Integer pagoId = pagoRequest.getId();
Pago _pag = pagoRepository.findById(pagoId).orElseThrow(null);
itinerarioReserva.addPago(_pag);
itinerarioRepository.save(itinerarioReserva);
return _pag;
}).orElseThrow(null);
return pago;
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.entity.PasajeroAuth;
import com.example.aeropuertoback.service.pasajeroAuth.IPasajeroAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping(value = "/pasajeros-auth")
public class PasajeroAuthController {
@Autowired
private IPasajeroAuthService iPasajeroAuthService;
@GetMapping(value = "/listar")
public List<PasajeroAuth> listar(){
return iPasajeroAuthService.findAll();
}
@PostMapping(value = "/agregar", consumes = MediaType.APPLICATION_JSON_VALUE)
public PasajeroAuth guardarPasajero(@RequestBody PasajeroAuth pasajeroAuth){
return iPasajeroAuthService.save(pasajeroAuth);
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.entity.Pasajero;
import com.example.aeropuertoback.service.pasajero.IPasajeroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping(value = "/pasajeros")
public class PasajeroController {
@Autowired
private IPasajeroService pasajeroService;
@GetMapping(value = "/listar")
public List<Pasajero> listar(){
return pasajeroService.findAll();
}
@PostMapping(value = "/agregar", consumes = MediaType.APPLICATION_JSON_VALUE)
public Pasajero guardarPasajero(@RequestBody Pasajero pasajero){
return pasajeroService.save(pasajero);
}
@PutMapping(value = "/actualizar/{id}")
public Pasajero actualizarPasajero(@PathVariable Integer id, @RequestBody Pasajero pasajero){
Pasajero editarPasajero = pasajeroService.findOne(id);
pasajero.setId(editarPasajero.getId());
pasajero.setPasajeroAuth(editarPasajero.getPasajeroAuth());
return pasajeroService.save(pasajero);
}
@GetMapping(value = "/byId/{id}")
public Pasajero listarPorId(@PathVariable Integer id){
return pasajeroService.findOne(id);
}
@DeleteMapping(value="/eliminar/{id}")
public void eliminarPasajero(@PathVariable Integer id){
pasajeroService.delete(id);
}
}
package com.example.aeropuertoback.controller;
import com.example.aeropuertoback.entity.*;
import com.example.aeropuertoback.service.aeropuerto.IAeropuertoService;
import com.example.aeropuertoback.service.vuelo.IVueloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping(value = "/vuelos")
public class VueloController {
@Autowired
private IVueloService vueloService;
@Autowired
private IAeropuertoService aeropuertoService;
@GetMapping(value = "/listar")
public List<Vuelo> listar(){
return vueloService.findAll();
}
@PostMapping(value = "/agregar", consumes = MediaType.APPLICATION_JSON_VALUE)
public Vuelo guardarVuelo(@RequestBody Vuelo vuelo){
Aeropuerto aeropuertoOrigen = aeropuertoService.findOne(vuelo.getCodigoAeropuertoOrigen().getId());
Aeropuerto aeropuertoDestino = aeropuertoService.findOne(vuelo.getCodigoAeropuertoDestino().getId());
vuelo.setCodigoAeropuertoOrigen(aeropuertoOrigen);
vuelo.setCodigoAeropuertoDestino(aeropuertoDestino);
return vueloService.save(vuelo);
}
@PutMapping(value = "/actualizar/{id}")
public Vuelo actualizarVuelo(@PathVariable Integer id, @RequestBody Vuelo vuelo){
Vuelo editarVuelo = vueloService.findOne(id);
vuelo.setId(editarVuelo.getId());
return vueloService.save(vuelo);
}
@GetMapping(value = "/byId/{id}")
public Vuelo listarPorId(@PathVariable Integer id){
return vueloService.findOne(id);
}
@DeleteMapping(value="/eliminar/{id}")
public void eliminarVuelo(@PathVariable Integer id){
vueloService.delete(id);
}
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.Aeropuerto;
import org.springframework.data.repository.CrudRepository;
public interface IAeropuertoDAO extends CrudRepository<Aeropuerto, Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.AgentesAuth;
import org.springframework.data.repository.CrudRepository;
public interface IAgenteAuthDAO extends CrudRepository<AgentesAuth,Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.AgenteReserva;
import org.springframework.data.repository.CrudRepository;
public interface IAgenteDAO extends CrudRepository<AgenteReserva,Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.Escala;
import org.springframework.data.repository.CrudRepository;
public interface IEscalaDAO extends CrudRepository<Escala,Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.AgenteReserva;
import com.example.aeropuertoback.entity.ItinerarioReserva;
import org.springframework.data.repository.CrudRepository;
public interface IItinerarioReservaDAO extends CrudRepository<ItinerarioReserva,Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.Pago;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface IPagoDAO extends JpaRepository<Pago,Integer> {
List<Pago> findPagosByItinerarioReserva(Integer id);
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.PasajeroAuth;
import org.springframework.data.repository.CrudRepository;
public interface IPasajeroAuthDAO extends CrudRepository<PasajeroAuth,Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.Pasajero;
import org.springframework.data.repository.CrudRepository;
public interface IPasajeroDAO extends CrudRepository<Pasajero,Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.Pasajero;
import com.example.aeropuertoback.entity.Vuelo;
import org.springframework.data.repository.CrudRepository;
public interface IVueloDAO extends CrudRepository<Vuelo,Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.ItinerarioReserva;
import com.example.aeropuertoback.entity.Pago;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ItinerarioRepository extends JpaRepository<ItinerarioReserva,Integer> {
}
package com.example.aeropuertoback.dao;
import com.example.aeropuertoback.entity.Pago;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface PagoRepository extends JpaRepository<Pago,Integer> {
List<Pago> findPagosByItinerarioReservaId(Integer id);
}
package com.example.aeropuertoback.entity;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name="airports")
public class Aeropuerto {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name="airport_code")
private String codigo;
@Column(name="airport_name")
private String nombre;
@Column(name="airport_location")
private String localizacion;
@Column(name="other_details")
private String detalles;
@OneToMany(mappedBy = "codigoAeropuertoOrigen", cascade = CascadeType.ALL)
private List<Vuelo> vuelos;
@OneToMany(mappedBy = "codigoAeropuertoDestino", cascade = CascadeType.ALL)
private List<Vuelo> vuelosDes;
@OneToMany(mappedBy = "codigoAeropuertoOrigen", cascade = CascadeType.ALL)
private List<Escala> escalas;
@OneToMany(mappedBy = "codigoAeropuertoDestino", cascade = CascadeType.ALL)
private List<Escala> escalasDes;
public Aeropuerto() {
vuelos = new ArrayList<Vuelo>();
vuelosDes = new ArrayList<Vuelo>();
escalas = new ArrayList<Escala>();
escalasDes = new ArrayList<Escala>();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getLocalizacion() {
return localizacion;
}
public void setLocalizacion(String localizacion) {
this.localizacion = localizacion;
}
public String getDetalles() {
return detalles;
}
public void setDetalles(String detalles) {
this.detalles = detalles;
}
public List<Vuelo> getVuelos() {
return vuelos;
}
public void setVuelos(List<Vuelo> vuelos) {
this.vuelos = vuelos;
}
public List<Vuelo> getVuelosDes() {
return vuelosDes;
}
public void setVuelosDes(List<Vuelo> vuelosDes) {
this.vuelosDes = vuelosDes;
}
public List<Escala> getEscalas() {
return escalas;
}
public void setEscalas(List<Escala> escalas) {
this.escalas = escalas;
}
public List<Escala> getEscalasDes() {
return escalasDes;
}
public void setEscalasDes(List<Escala> escalasDes) {
this.escalasDes = escalasDes;
}
}
package com.example.aeropuertoback.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name="booking_agents")
public class AgenteReserva {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name="agent_name")
private String nombre;
@Column(name="agent_details")
private String detalles;
@OneToMany(mappedBy = "agente",fetch = FetchType.LAZY, cascade=CascadeType.ALL) //Tenemos un pasajero para muchas reservas
private List<ItinerarioReserva> itinerarioReservas;
@ManyToOne(fetch = FetchType.LAZY, optional = false) //Tenemos muchos itinerarios un cliente //Many clase donde estamos
@JoinColumn(name = "agente_auth_id")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private AgentesAuth agenteAuth;
public AgenteReserva(){
itinerarioReservas = new ArrayList<ItinerarioReserva>();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getDetalles() {
return detalles;
}
public void setDetalles(String detalles) {
this.detalles = detalles;
}
public List<ItinerarioReserva> getItinerarioReservas() {
return itinerarioReservas;
}
public void setItinerarioReserva(List<ItinerarioReserva> itinerarioReserva) {
this.itinerarioReservas = itinerarioReserva;
}
public void addReserva(ItinerarioReserva itinerarioReserva){
this.itinerarioReservas.add(itinerarioReserva);
}
public Integer getUserId(){
return agenteAuth.getId();
}
public void setItinerarioReservas(List<ItinerarioReserva> itinerarioReservas) {
this.itinerarioReservas = itinerarioReservas;
}
public AgentesAuth getAgenteAuth() {
return agenteAuth;
}
public void setAgenteAuth(AgentesAuth agenteAuth) {
this.agenteAuth = agenteAuth;
}
}
package com.example.aeropuertoback.entity;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name="agente_auth")
public class AgentesAuth {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name="username")
private String usuario;
@Column(name="password")
private String password;
@Column(name="role")
private String rol;
@OneToMany(mappedBy = "agenteAuth", cascade = CascadeType.ALL)
private List<AgenteReserva> agenteReservas;
public AgentesAuth(){
agenteReservas = new ArrayList<>();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsuario() {
return usuario;
}
public void setUsuario(String usuario) {
this.usuario = usuario;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRol() {
return rol;
}
public void setRol(String rol) {
this.rol = rol;
}
public List<AgenteReserva> getAgenteReservas() {
return agenteReservas;
}
public void setAgenteReservas(List<AgenteReserva> agenteReservas) {
this.agenteReservas = agenteReservas;
}
}
package com.example.aeropuertoback.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Table(name="legs")
public class Escala {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name="actual_departure_time")
@Temporal(TemporalType.TIMESTAMP)
private Date fechaSalida;
@Column(name="actual_arrival_time")
@Temporal(TemporalType.TIMESTAMP)
private Date fechaLlegada;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "origin_airport_code")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Aeropuerto codigoAeropuertoOrigen;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "destination_airport_code")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Aeropuerto codigoAeropuertoDestino;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "flight_number")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Vuelo codigoVuelo;
@ManyToMany(fetch = FetchType.LAZY,
cascade = {
CascadeType.PERSIST,
CascadeType.MERGE,
CascadeType.ALL
},
mappedBy = "escalas")
@JsonIgnore
private List<ItinerarioReserva> itinerarioReserva;
public Escala(){
itinerarioReserva = new ArrayList<>();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Aeropuerto getCodigoAeropuertoOrigen() {
return codigoAeropuertoOrigen;
}
public void setCodigoAeropuertoOrigen(Aeropuerto codigoAeropuertoOrigen) {
this.codigoAeropuertoOrigen = codigoAeropuertoOrigen;
}
public Aeropuerto getCodigoAeropuertoDestino() {
return codigoAeropuertoDestino;
}
public void setCodigoAeropuertoDestino(Aeropuerto codigoAeropuertoDestino) {
this.codigoAeropuertoDestino = codigoAeropuertoDestino;
}
public Vuelo getCodigoVuelo() {
return codigoVuelo;
}
public void setCodigoVuelo(Vuelo codigoVuelo) {
this.codigoVuelo = codigoVuelo;
}
public String getAeropuertoOrigen(){
return this.getCodigoAeropuertoOrigen().getCodigo();
}
public String getAeropuertoDestino(){
return this.getCodigoAeropuertoDestino().getCodigo();
}
public Date getFechaSalida() {
return fechaSalida;
}
public void setFechaSalida(Date fechaSalida) {
this.fechaSalida = fechaSalida;
}
public Date getFechaLlegada() {
return fechaLlegada;
}
public void setFechaLlegada(Date fechaLlegada) {
this.fechaLlegada = fechaLlegada;
}
public List<ItinerarioReserva> getItinerarioReserva() {
return itinerarioReserva;
}
public void setItinerarioReserva(List<ItinerarioReserva> itinerarioReserva) {
this.itinerarioReserva = itinerarioReserva;
}
public double getCosto(){
return codigoVuelo.getCosto();
}
}
package com.example.aeropuertoback.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Table(name="itinerary_reservations")
public class ItinerarioReserva {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "reservation_id", nullable = false)
private Integer id;
@Column(name="date_reservation_made")
@Temporal(TemporalType.DATE)
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date diaReservacion;
@Column(name="reservation_status_code")
private String estado;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "pasajero_id")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Pasajero pasajero;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "agente_id")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private AgenteReserva agente;
@ManyToMany(fetch = FetchType.LAZY,
cascade = {
CascadeType.PERSIST,
CascadeType.MERGE
})
@JoinTable(name = "reservation_payments",
joinColumns = { @JoinColumn(name = "reservation_id") },
inverseJoinColumns = { @JoinColumn(name = "payment_id") })
private List<Pago> pagos;
@ManyToMany(fetch = FetchType.LAZY,
cascade = {
CascadeType.PERSIST,
CascadeType.MERGE,
CascadeType.ALL
})
@JoinTable(name = "itinerary_legs",
joinColumns = { @JoinColumn(name = "reservation_id") },
inverseJoinColumns = { @JoinColumn(name = "leg_id") })
private List<Escala> escalas;
public ItinerarioReserva(){
pagos = new ArrayList<>();
escalas = new ArrayList<>();
}
@PrePersist
public void prePersist(){
diaReservacion = new Date();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Date getDiaReservacion() {
return diaReservacion;
}
public void setDiaReservacion(Date diaReservacion) {
this.diaReservacion = diaReservacion;
}
public Pasajero getPasajero() {
return pasajero;
}
public void setPasajero(Pasajero pasajero) {
this.pasajero = pasajero;
}
public AgenteReserva getAgente() {
return agente;
}
public void setAgente(AgenteReserva agente) {
this.agente = agente;
}
public List<Pago> getPagos() {
return pagos;
}
public void setPagos(List<Pago> pagos) {
this.pagos = pagos;
}
public void addPago(Pago pago) {
this.pagos.add(pago);
pago.getItinerarioReserva().add(this);
}
public String getEstado() {
return estado;
}
public void setEstado(String estado) {
this.estado = estado;
}
public List<Escala> getEscalas() {
return escalas;
}
public void setEscalas(List<Escala> escalas) {
this.escalas = escalas;
}
public void addEscala(Escala escala) {
this.escalas.add(escala);
escala.getItinerarioReserva().add(this);
}
public Integer getPasajeroId(){
return pasajero.getId();
}
public Integer getAgenteId(){
return agente.getId();
}
public String getAgenteNombre(){
return agente.getNombre();
}
public String getPasajeroNombre(){
return pasajero.getPrimerNombre();
}
}
package com.example.aeropuertoback.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Table(name="payments")
public class Pago {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "payment_id")
private Integer id;
@Column(name="payment_date")
@Temporal(TemporalType.TIMESTAMP)
private Date fecha;
@Column(name="payment_amount")
private double pago;
@Column(name="payment_status_code")
private String estado;
@ManyToMany(fetch = FetchType.LAZY,
cascade = {
CascadeType.PERSIST,
CascadeType.MERGE,
CascadeType.ALL
},
mappedBy = "pagos")
@JsonIgnore
private List<ItinerarioReserva> itinerarioReserva;
@PrePersist
public void prePersist(){
fecha = new java.util.Date();
}
public Pago(){
itinerarioReserva = new ArrayList<ItinerarioReserva>();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public double getPago() {
return pago;
}
public void setPago(double pago) {
this.pago = pago;
}
public List<ItinerarioReserva> getItinerarioReserva() {
return itinerarioReserva;
}
public void setItinerarioReserva(List<ItinerarioReserva> itinerarioReserva) {
this.itinerarioReserva = itinerarioReserva;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public String getEstado() {
return estado;
}
public void setEstado(String estado) {
this.estado = estado;
}
}
package com.example.aeropuertoback.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name="passengers")
public class Pasajero implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name="first_name")
private String primerNombre;
@Column(name="second_name")
private String segundoNombre;
@Column(name="last_name")
private String apellido;
@Column(name="phone_number")
private String telefono;
@Column(name="email_address")
private String correo;
@Column(name="address_lines")
private String direccion;
@Column(name="city")
private String ciudad;
@Column(name="state_province_country")
private String provincia;
@Column(name="country")
private String pais;
@Column(name="other_passenger_details")
private String detalles;
@OneToMany(mappedBy = "pasajero", cascade = CascadeType.ALL)
private List<ItinerarioReserva> itinerarioReservas;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "pasajero_auth_id")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private PasajeroAuth pasajeroAuth;
private static final long serialVersionUID = 1L;
public Pasajero() {
itinerarioReservas = new ArrayList<ItinerarioReserva>();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getPrimerNombre() {
return primerNombre;
}
public void setPrimerNombre(String primerNombre) {
this.primerNombre = primerNombre;
}
public String getSegundoNombre() {
return segundoNombre;
}
public void setSegundoNombre(String segundoNombre) {
this.segundoNombre = segundoNombre;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public String getTelefono() {
return telefono;
}
public void setTelefono(String telefono) {
this.telefono = telefono;
}
public String getCorreo() {
return correo;
}
public void setCorreo(String correo) {
this.correo = correo;
}
public String getDireccion() {
return direccion;
}
public void setDireccion(String direccion) {
this.direccion = direccion;
}
public String getCiudad() {
return ciudad;
}
public void setCiudad(String ciudad) {
this.ciudad = ciudad;
}
public String getProvincia() {
return provincia;
}
public void setProvincia(String provincia) {
this.provincia = provincia;
}
public String getPais() {
return pais;
}
public void setPais(String pais) {
this.pais = pais;
}
public String getDetalles() {
return detalles;
}
public void setDetalles(String detalles) {
this.detalles = detalles;
}
public List<ItinerarioReserva> getItinerarioReservas() {
return itinerarioReservas;
}
public void setItinerarioReserva(List<ItinerarioReserva> itinerarioReserva) {
this.itinerarioReservas = itinerarioReserva;
}
public void addReserva(ItinerarioReserva itinerarioReserva){
this.itinerarioReservas.add(itinerarioReserva);
}
public void setItinerarioReservas(List<ItinerarioReserva> itinerarioReservas) {
this.itinerarioReservas = itinerarioReservas;
}
public PasajeroAuth getPasajeroAuth() {
return pasajeroAuth;
}
public void setPasajeroAuth(PasajeroAuth pasajeroAuth) {
this.pasajeroAuth = pasajeroAuth;
}
public Integer getUserId(){
return pasajeroAuth.getId();
}
}
package com.example.aeropuertoback.entity;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name="pasajero_auth")
public class PasajeroAuth {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name="email")
private String correo;
@Column(name="code")
private String codigo;
@Column(name="role")
private String rol;
@OneToMany(mappedBy = "pasajeroAuth", cascade = CascadeType.ALL)
private List<Pasajero> pasajeros;
public PasajeroAuth(){
pasajeros = new ArrayList<>();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCorreo() {
return correo;
}
public void setCorreo(String correo) {
this.correo = correo;
}
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getRol() {
return rol;
}
public void setRol(String rol) {
this.rol = rol;
}
public List<Pasajero> getPasajeros() {
return pasajeros;
}
public void setPasajeros(List<Pasajero> pasajeros) {
this.pasajeros = pasajeros;
}
}
package com.example.aeropuertoback.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Table(name="flight_schedules")
public class Vuelo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name="flight_cost")
private double costo;
@Column(name="airline_code")
private String codigoAerolinea;
@Column(name="usual_aircraft_type_code")
private String codigoTipoAeronave;
@Column(name="departure_date_time")
@Temporal(TemporalType.TIMESTAMP)
private Date fechaSalida;
@Column(name="arrival_date_time")
@Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date fechaLlegada;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "origin_airport_code")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Aeropuerto codigoAeropuertoOrigen;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "destination_airport_code")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Aeropuerto codigoAeropuertoDestino;
@OneToMany(mappedBy = "codigoVuelo", cascade = CascadeType.ALL)
private List<Escala> escalas;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Vuelo(){
escalas = new ArrayList<Escala>();
}
public Aeropuerto getCodigoAeropuertoOrigen() {
return codigoAeropuertoOrigen;
}
public void setCodigoAeropuertoOrigen(Aeropuerto codigoAeropuertoOrigen) {
this.codigoAeropuertoOrigen = codigoAeropuertoOrigen;
}
public Aeropuerto getCodigoAeropuertoDestino() {
return codigoAeropuertoDestino;
}
public void setCodigoAeropuertoDestino(Aeropuerto codigoAeropuertoDestino) {
this.codigoAeropuertoDestino = codigoAeropuertoDestino;
}
public List<Escala> getEscalas() {
return escalas;
}
public void setEscalas(List<Escala> escalas) {
this.escalas = escalas;
}
public Date getFechaSalida() {
return fechaSalida;
}
public void setFechaSalida(Date fechaSalida) {
this.fechaSalida = fechaSalida;
}
public Date getFechaLlegada() {
return fechaLlegada;
}
public void setFechaLlegada(Date fechaLlegada) {
this.fechaLlegada = fechaLlegada;
}
public String getAeropuertoOrigen(){
return this.codigoAeropuertoOrigen.getCodigo();
}
public String getAeropuertoDestino(){
return this.codigoAeropuertoDestino.getCodigo();
}
public double getCosto() {
return costo;
}
public void setCosto(double costo) {
this.costo = costo;
}
public String getCodigoAerolinea() {
return codigoAerolinea;
}
public void setCodigoAerolinea(String codigoAerolinea) {
this.codigoAerolinea = codigoAerolinea;
}
public String getCodigoTipoAeronave() {
return codigoTipoAeronave;
}
public void setCodigoTipoAeronave(String codigoTipoAeronave) {
this.codigoTipoAeronave = codigoTipoAeronave;
}
public Integer getCodigoOrigen(){
return this.codigoAeropuertoOrigen.getId();
}
public Integer getCodigoDestino(){
return this.codigoAeropuertoDestino.getId();
}
}
package com.example.aeropuertoback.service.aeropuerto;
import com.example.aeropuertoback.dao.IAeropuertoDAO;
import com.example.aeropuertoback.entity.Aeropuerto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AeropuertoServiceImpl implements IAeropuertoService {
@Autowired
private IAeropuertoDAO aeropuertoDAO;
@Override
public List<Aeropuerto> findAll() {
return (List<Aeropuerto>)aeropuertoDAO.findAll();
}
@Override
public Aeropuerto save(Aeropuerto aeropuerto) {
return aeropuertoDAO.save(aeropuerto);
}
@Override
public Aeropuerto findOne(Integer id) {
return aeropuertoDAO.findById(id).orElse(null);
}
@Override
public void delete(Integer id) {
aeropuertoDAO.deleteById(id);
}
}
package com.example.aeropuertoback.service.aeropuerto;
import com.example.aeropuertoback.entity.Aeropuerto;
import java.util.List;
public interface IAeropuertoService {
public List<Aeropuerto> findAll();
public Aeropuerto save(Aeropuerto aeropuerto);
public Aeropuerto findOne(Integer id);
public void delete(Integer id);
}
package com.example.aeropuertoback.service.agente;
import com.example.aeropuertoback.dao.IAgenteDAO;
import com.example.aeropuertoback.entity.AgenteReserva;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AgenteServiceImpl implements IAgenteService{
@Autowired
private IAgenteDAO agenteDAO;
@Override
public List<AgenteReserva> findAll() {
return (List<AgenteReserva>)agenteDAO.findAll();
}
@Override
public AgenteReserva save(AgenteReserva agenteReserva) {
return agenteDAO.save(agenteReserva);
}
@Override
public AgenteReserva findOne(Integer id) {
return agenteDAO.findById(id).orElse(null);
}
@Override
public void delete(Integer id) {
agenteDAO.deleteById(id);
}
}
package com.example.aeropuertoback.service.agente;
import com.example.aeropuertoback.entity.AgenteReserva;
import java.util.List;
public interface IAgenteService {
public List<AgenteReserva> findAll();
public AgenteReserva save(AgenteReserva agenteReserva);
public AgenteReserva findOne(Integer id);
public void delete(Integer id);
}
package com.example.aeropuertoback.service.agenteAuth;
import com.example.aeropuertoback.dao.IAgenteAuthDAO;
import com.example.aeropuertoback.dao.IPasajeroAuthDAO;
import com.example.aeropuertoback.entity.AgentesAuth;
import com.example.aeropuertoback.entity.PasajeroAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class AgenteAuthServiceImpl implements IAgenteAuthService{
@Autowired
private IAgenteAuthDAO agenteAuthDAO;
@Override
@Transactional(readOnly=true)
public List<AgentesAuth> findAll() {
return (List<AgentesAuth>)agenteAuthDAO.findAll();
}
@Override
public AgentesAuth save(AgentesAuth agentesAuth) {
return agenteAuthDAO.save(agentesAuth);
}
}
package com.example.aeropuertoback.service.agenteAuth;
import com.example.aeropuertoback.entity.AgentesAuth;
import com.example.aeropuertoback.entity.PasajeroAuth;
import java.util.List;
public interface IAgenteAuthService {
public List<AgentesAuth> findAll();
public AgentesAuth save(AgentesAuth agentesAuth);
}
package com.example.aeropuertoback.service.escala;
import com.example.aeropuertoback.dao.IEscalaDAO;
import com.example.aeropuertoback.dao.IVueloDAO;
import com.example.aeropuertoback.entity.Escala;
import com.example.aeropuertoback.entity.Vuelo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class EscalaServiceImpl implements IEscalaService{
@Autowired
private IEscalaDAO escalaDAO;
@Override
@Transactional(readOnly=true)
public List<Escala> findAll() {
return (List<Escala>)escalaDAO.findAll();
}
@Transactional(readOnly=true)
@Override
public Escala findOne(Integer id) {
return escalaDAO.findById(id).orElse(null);
}
@Override
public Escala save(Escala escala) {
return escalaDAO.save(escala);
}
@Override
public void delete(Integer id) {
escalaDAO.deleteById(id);
}
}
package com.example.aeropuertoback.service.escala;
import com.example.aeropuertoback.entity.Escala;
import com.example.aeropuertoback.entity.Vuelo;
import java.util.List;
public interface IEscalaService {
public List<Escala> findAll();
public Escala findOne(Integer id);
public Escala save(Escala escala);
public void delete(Integer id);
}
package com.example.aeropuertoback.service.itinerario;
import com.example.aeropuertoback.entity.ItinerarioReserva;
import com.example.aeropuertoback.entity.Pasajero;
import java.util.List;
public interface IItinerarioService {
public List<ItinerarioReserva> findAll();
public ItinerarioReserva findOne(Integer id);
public ItinerarioReserva save(ItinerarioReserva itinerarioReserva);
public void delete(Integer id);
}
package com.example.aeropuertoback.service.itinerario;
import com.example.aeropuertoback.dao.IItinerarioReservaDAO;
import com.example.aeropuertoback.dao.IPasajeroDAO;
import com.example.aeropuertoback.entity.ItinerarioReserva;
import com.example.aeropuertoback.entity.Pasajero;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ItinerarioServiceImpl implements IItinerarioService{
@Autowired
private IItinerarioReservaDAO itinerarioReservaDAO;
@Override
public List<ItinerarioReserva> findAll() {
return (List<ItinerarioReserva>)itinerarioReservaDAO.findAll();
}
@Override
public ItinerarioReserva findOne(Integer id) {
return itinerarioReservaDAO.findById(id).orElse(null);
}
@Override
public ItinerarioReserva save(ItinerarioReserva itinerarioReserva) {
return itinerarioReservaDAO.save(itinerarioReserva);
}
@Override
public void delete(Integer id) {
itinerarioReservaDAO.deleteById(id);
}
}
package com.example.aeropuertoback.service.pago;
import com.example.aeropuertoback.entity.Pago;
import java.util.List;
public interface IPagoService {
public List<Pago> findAll();
public Pago findOne(Integer id);
public Pago save(Pago pago);
public void delete(Integer id);
public List<Pago> findPagosByItinerarioReserva(Integer id);
}
package com.example.aeropuertoback.service.pago;
import com.example.aeropuertoback.dao.IPagoDAO;
import com.example.aeropuertoback.dao.IVueloDAO;
import com.example.aeropuertoback.entity.Pago;
import com.example.aeropuertoback.entity.Vuelo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class PagoServiceImpl implements IPagoService {
@Autowired
private IPagoDAO pagoDAO;
@Override
@Transactional(readOnly=true)
public List<Pago> findAll() {
return (List<Pago>)pagoDAO.findAll();
}
@Transactional(readOnly=true)
@Override
public Pago findOne(Integer id) {
return pagoDAO.findById(id).orElse(null);
}
@Override
public Pago save(Pago pago) {
return pagoDAO.save(pago);
}
@Override
public void delete(Integer id) {
pagoDAO.deleteById(id);
}
@Override
public List<Pago> findPagosByItinerarioReserva(Integer id) {
return pagoDAO.findPagosByItinerarioReserva(id);
}
}
package com.example.aeropuertoback.service.pasajero;
import com.example.aeropuertoback.entity.Pasajero;
import java.util.List;
public interface IPasajeroService {
public List<Pasajero> findAll();
public Pasajero findOne(Integer id);
public Pasajero save(Pasajero pasajero);
public void delete(Integer id);
}
package com.example.aeropuertoback.service.pasajero;
import com.example.aeropuertoback.dao.IPasajeroDAO;
import com.example.aeropuertoback.entity.Pasajero;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service //Patron de dise;o facade
public class PasajeroServiceImpl implements IPasajeroService{
@Autowired
private IPasajeroDAO pasajeroDAO;
@Override
@Transactional(readOnly=true) //Marcamos como transaccional y de solo lectura
//Si fuera un insert(un persist) obmitimos el transactional
//Transactional es una notacion que toma el contenido del metodo lo envuelve dentro de una transaccion
public List<Pasajero> findAll() {
return (List<Pasajero>)pasajeroDAO.findAll();
}
@Transactional(readOnly=true)
@Override
public Pasajero findOne(Integer id) {
return pasajeroDAO.findById(id).orElse(null);
}
@Override
public Pasajero save(Pasajero pasajero) {
return pasajeroDAO.save(pasajero);
}
@Override
public void delete(Integer id) {
pasajeroDAO.deleteById(id);
}
}
package com.example.aeropuertoback.service.pasajeroAuth;
import com.example.aeropuertoback.entity.PasajeroAuth;
import com.example.aeropuertoback.entity.Vuelo;
import java.util.List;
public interface IPasajeroAuthService {
public List<PasajeroAuth> findAll();
public PasajeroAuth save(PasajeroAuth pasajeroAuth);
}
package com.example.aeropuertoback.service.pasajeroAuth;
import com.example.aeropuertoback.dao.IPasajeroAuthDAO;
import com.example.aeropuertoback.entity.PasajeroAuth;
import com.example.aeropuertoback.entity.Vuelo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class PasajeroAuthAuthServiceImpl implements IPasajeroAuthService {
@Autowired
private IPasajeroAuthDAO pasajeroAuthDAO;
@Override
@Transactional(readOnly=true)
public List<PasajeroAuth> findAll() {
return (List<PasajeroAuth>)pasajeroAuthDAO.findAll();
}
@Override
public PasajeroAuth save(PasajeroAuth pasajeroAuth) {
return pasajeroAuthDAO.save(pasajeroAuth);
}
}
package com.example.aeropuertoback.service.vuelo;
import com.example.aeropuertoback.entity.Pasajero;
import com.example.aeropuertoback.entity.Vuelo;
import java.util.List;
public interface IVueloService {
public List<Vuelo> findAll();
public Vuelo findOne(Integer id);
public Vuelo save(Vuelo vuelo);
public void delete(Integer id);
}
package com.example.aeropuertoback.service.vuelo;
import com.example.aeropuertoback.dao.IVueloDAO;
import com.example.aeropuertoback.entity.Vuelo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class VueloServiceImpl implements IVueloService{
@Autowired
private IVueloDAO vueloDAO;
@Override
@Transactional(readOnly=true)
public List<Vuelo> findAll() {
return (List<Vuelo>)vueloDAO.findAll();
}
@Transactional(readOnly=true)
@Override
public Vuelo findOne(Integer id) {
return vueloDAO.findById(id).orElse(null);
}
@Override
public Vuelo save(Vuelo vuelo) {
return vueloDAO.save(vuelo);
}
@Override
public void delete(Integer id) {
vueloDAO.deleteById(id);
}
}
spring.datasource.url=jdbc:mysql://localhost/db_aeropuerto
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.ddl-auto=create
logging.level.org.hibernate.SQL=debug
\ No newline at end of file
INSERT INTO pasajero_auth (id,code,email,role) VALUES (1,'1234','charles53681@gmail.com','pasajero');
INSERT INTO passengers (id,first_name,second_name,last_name,phone_number,email_address,address_lines,city,state_province_country,country,other_passenger_details,pasajero_auth_id) VALUES (1,'Charles','Anderson','Torres','957242941','charles53681@gmail.com','Calle los agricolas','Lima','Lima','Lima','dasdsaddw',1);
INSERT INTO agente_auth (id,username,password,role) VALUES (1,'agente1','1234','agente');
INSERT INTO agente_auth (id,username,password,role) VALUES (2,'agente2','1234','supervisor');
INSERT INTO booking_agents (id,agent_name,agent_details,agente_auth_id) VALUES (2,'Miguel','encargado de reservas',1);
INSERT INTO airports (id,airport_code, airport_name, airport_location, other_details) VALUES (1,'LIM','Jorge Chavez','Callao omoadw','aeropuerto del peru');
INSERT INTO airports (id,airport_code, airport_name, airport_location, other_details) VALUES (2,'YUL','Pierre Elliott Trudeau','Montreal','aeropuerto del pierre');
INSERT INTO airports (id,airport_code, airport_name, airport_location, other_details) VALUES (3,'YYZ','Lester B. Pearson','Toronto','aeropuerto del Lester');
INSERT INTO airports (id,airport_code, airport_name, airport_location, other_details) VALUES (4,'HND','Tokyo Haneda','Tokio','aeropuerto del Tokio');
INSERT INTO itinerary_reservations(reservation_id,date_reservation_made,agente_id,pasajero_id, reservation_status_code) VALUES (1,NOW(),2,1,'pendiente');
/*Va de lima a tokio*/
INSERT INTO flight_schedules (id,origin_airport_code,destination_airport_code, departure_date_time, arrival_date_time, flight_cost,airline_code,usual_aircraft_type_code ) VALUES (1,1,4,'2023-09-14 23:18:17','2023-10-14 23:18:17',800,'LA458','BP234');
/*Escalas de vuelo*/
INSERT INTO legs (id,origin_airport_code,destination_airport_code,flight_number,actual_departure_time,actual_arrival_time) VALUES (1,1,2,1,'2023-09-14 23:18:17','2023-09-15 23:18:17');
INSERT INTO legs (id,origin_airport_code,destination_airport_code,flight_number,actual_departure_time,actual_arrival_time) VALUES (2,2,3,1,'2023-09-16 23:18:17','2023-09-18 23:18:17');
INSERT INTO legs (id,origin_airport_code,destination_airport_code,flight_number,actual_departure_time,actual_arrival_time) VALUES (3,3,4,1,'2023-10-12 23:18:17','2023-10-14 23:18:17');
/*Pagos*/
INSERT INTO payments(payment_id,payment_amount,payment_date,payment_status_code) VALUES (1,500,NOW(),'pagado');
INSERT INTO payments(payment_id,payment_amount,payment_date,payment_status_code) VALUES (2,200,NOW(), 'pagado');
/*Itinerario Pagos*/
INSERT INTO reservation_payments (reservation_id,payment_id) VALUES (1,1);
INSERT INTO reservation_payments (reservation_id,payment_id) VALUES (1,2);
/**/
INSERT INTO itinerary_legs (reservation_id, leg_id) VALUES (1,1);
INSERT INTO itinerary_legs (reservation_id, leg_id) VALUES (1,2);
INSERT INTO itinerary_legs (reservation_id, leg_id) VALUES (1,3);
/*INSERT INTO flight_schedules(id,)*/
\ No newline at end of file
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>Hola mundo x3dsadsaasddas</h1>
<div th:text="${objeto}" > </div>
<div> </div>
</body>
</html>
\ No newline at end of file
package com.example.aeropuertoback;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class AeropuertoBackApplicationTests {
@Test
void contextLoads() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment