Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ Join the Spring Boot community to connect with other developers and get support:
- [Stack Overflow](https://stackoverflow.com/questions/tagged/spring-boot)
- [GitHub Issues](https://github.com/spring-projects/spring-boot/issues)

## Base de datos

Hemos utilizado una base de datos H2 en memoria para facilitar el desarrollo y las pruebas. Puedes cambiar la configuración de la base de datos en el archivo `application.properties` o `application.yml` según tus necesidades.

Para acceder a la consola de H2 lo hacemos disponible en la siguiente URL cuando la aplicación está en ejecución:

http://localhost:8080/h2-console

Configuración:

-JDBC URL: jdbc:h2:mem:atmdb
-Username: sa
-Password: (deja en blanco)


## License

This Spring Boot template is provided under the [Apache 2.0 license](https://github.com/spring-projects/spring-boot/blob/main/LICENSE.txt).
Expand Down
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version> <!-- Compatible con JDK 17 y 21 -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package es.nextdigital.demo.api.v1.controller;

import es.nextdigital.demo.dto.MovimientoDTO;
import es.nextdigital.demo.dto.OperacionIngresoDTO;
import es.nextdigital.demo.dto.OperacionRetiroDTO;
import es.nextdigital.demo.dto.TransferenciaDTO;
import es.nextdigital.demo.service.OperacionService;
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.RestController;

import java.util.List;

/**
* The type Operacion controller.
*/
@RestController
@RequestMapping("/operaciones")
public class OperacionController {

@Autowired
private OperacionService operacionService;

/**
* Movimientos list.
*
* @param cuentaId the cuenta id
* @return the list
*/
@GetMapping("/movimientos/{cuentaId}")
public List<MovimientoDTO> movimientos(@PathVariable Long cuentaId) {
return operacionService.consultarMovimientos(cuentaId);
}

/**
* Retirar response entity.
*
* @param dto the dto
* @return the response entity
*/
@PostMapping("/retiro")
public ResponseEntity<Void> retirar(@RequestBody OperacionRetiroDTO dto) {
operacionService.retirar(dto);
return ResponseEntity.ok().build();
}

/**
* Ingresar response entity.
*
* @param dto the dto
* @return the response entity
*/
@PostMapping("/ingreso")
public ResponseEntity<Void> ingresar(@RequestBody OperacionIngresoDTO dto) {
operacionService.ingresar(dto);
return ResponseEntity.ok().build();
}

/**
* Transferir response entity.
*
* @param dto the dto
* @return the response entity
*/
@PostMapping("/transferencia")
public ResponseEntity<Void> transferir(@RequestBody TransferenciaDTO dto) {
operacionService.transferir(dto);
return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package es.nextdigital.demo.api.v1.controller;

import es.nextdigital.demo.dto.ActivacionTarjetaDTO;
import es.nextdigital.demo.dto.CambioPinDTO;
import es.nextdigital.demo.service.TarjetaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
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.RestController;

/**
* The type Tarjeta controller.
*/
@RestController
@RequestMapping("/tarjetas")
public class TarjetaController {

@Autowired
private TarjetaService tarjetaService;

/**
* Activar response entity.
*
* @param id the id
* @param dto the dto
* @return the response entity
*/
@PostMapping("/{id}/activar")
public ResponseEntity<Void> activar(@PathVariable Long id, @RequestBody ActivacionTarjetaDTO dto) {
tarjetaService.activarTarjeta(id, dto.nuevoPin);
return ResponseEntity.ok().build();
}

/**
* Cambiar pin response entity.
*
* @param id the id
* @param dto the dto
* @return the response entity
*/
@PostMapping("/{id}/cambiar-pin")
public ResponseEntity<Void> cambiarPin(@PathVariable Long id, @RequestBody CambioPinDTO dto) {
tarjetaService.cambiarPin(id, dto.nuevoPin);
return ResponseEntity.ok().build();
}
}

21 changes: 21 additions & 0 deletions src/main/java/es/nextdigital/demo/dto/ActivacionTarjetaDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package es.nextdigital.demo.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* The type Activacion tarjeta DTO.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ActivacionTarjetaDTO {

/**
* The Nuevo pin.
*/
public String nuevoPin;
}
22 changes: 22 additions & 0 deletions src/main/java/es/nextdigital/demo/dto/CambioPinDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package es.nextdigital.demo.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* The type Cambio pin dto.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CambioPinDTO {

/**
* The Nuevo pin.
*/
public String nuevoPin;
}

42 changes: 42 additions & 0 deletions src/main/java/es/nextdigital/demo/dto/MovimientoDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package es.nextdigital.demo.dto;

import es.nextdigital.demo.enums.TipoMovimiento;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
* The type Movimiento dto.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class MovimientoDTO {

/**
* The fecha.
*/
private LocalDateTime fecha;

/**
* The cantidad.
*/
private BigDecimal cantidad;

/**
* The tipo.
*/
private TipoMovimiento tipo;

/**
* The descripcion.
*/
private String descripcion;

}

31 changes: 31 additions & 0 deletions src/main/java/es/nextdigital/demo/dto/OperacionIngresoDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package es.nextdigital.demo.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;

/**
* The type Operacion ingreso dto.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class OperacionIngresoDTO {

/**
* The Tarjeta id.
*/
public Long tarjetaId;
/**
* The Cantidad.
*/
public BigDecimal cantidad;
/**
* The Cajero propio.
*/
public boolean cajeroPropio;
}
34 changes: 34 additions & 0 deletions src/main/java/es/nextdigital/demo/dto/OperacionRetiroDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package es.nextdigital.demo.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;

/**
* The type Operacion retiro dto.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class OperacionRetiroDTO {

/**
* The Tarjeta id.
*/
public Long tarjetaId;

/**
* The Cantidad.
*/
public BigDecimal cantidad;

/**
* The Cajero propio.
*/
public boolean cajeroPropio;
}

32 changes: 32 additions & 0 deletions src/main/java/es/nextdigital/demo/dto/TransferenciaDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package es.nextdigital.demo.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;

/**
* The type Transferencia dto.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class TransferenciaDTO {

/**
* The Tarjeta id.
*/
public Long tarjetaId;
/**
* The Iban destino.
*/
public String ibanDestino;
/**
* The Cantidad.
*/
public BigDecimal cantidad;
}

30 changes: 30 additions & 0 deletions src/main/java/es/nextdigital/demo/entity/Cliente.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package es.nextdigital.demo.entity;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;

import java.util.List;

/**
* The type Cliente.
*/
@Entity
public class Cliente {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String nombre;

@OneToMany(mappedBy = "cliente", cascade = CascadeType.ALL)
private List<Cuenta> cuentas;

@OneToMany(mappedBy = "cliente", cascade = CascadeType.ALL)
private List<Tarjeta> tarjetas;
}

Loading