Commit 20f93b5f by Joel Florentin

Merge branch 'giuli_001' of https://phoebe.roshka.com/gitlab/hshah/TalentoHumano into joel-001

parents a5c78d23 b17b12ec
......@@ -47,6 +47,16 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>
</dependencies>
<build>
......
package com.roshka.controller;
import javax.validation.ConstraintViolationException;
import com.roshka.modelo.Postulante;
import com.roshka.repositorio.PostulanteRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
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.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.*;
@Controller
@Controller
public class PostulanteController {
@Autowired
PostulanteRepository post;
......@@ -32,4 +37,20 @@ public class PostulanteController {
return "redirect:/";
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler({MethodArgumentNotValidException.class})
public ResponseEntity<String> handleValidationExceptions(
MethodArgumentNotValidException ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(ex.getMessage());
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler({ConstraintViolationException.class})
public ResponseEntity<String> handleValidationExceptions2(
ConstraintViolationException ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(ex.getMessage());
}
}
......@@ -12,6 +12,9 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
......@@ -22,17 +25,28 @@ public class Estudio {
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private long id;
@Column(name="tipo_de_studio")
@NotBlank
private String tipoDeEstudio;
@Column(name="institucion")
@NotBlank
private String institucion;
@Column(name="fecha_desde")
@NotNull
@Past
private Date fechaDesde;
@Column(name="fecha_hasta")
private Date fechaHasta;
@Column(name="referencias")
private String referencias;
@Column(name="titulo")
@NotBlank
private String titulo;
@ManyToOne
......
......@@ -9,6 +9,7 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonBackReference;
......@@ -19,10 +20,15 @@ public class EstudioReconocimiento {
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private Long id;
@Column(name="nombre")
@NotBlank
private String nombre;
@Column(name="certificado")
@NotBlank
private String certificado;
@JsonBackReference
@ManyToOne
@JoinColumn
......
......@@ -14,6 +14,9 @@ import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
@Entity
@Table(name = "experiencia")
......@@ -21,10 +24,16 @@ public class Experiencia {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "institucion")
@NotBlank
private String institucion;
@Column(name = "fecha_desde")
@Past
@NotNull
private Date fechaDesde;
@Column(name = "fecha_hasta")
private Date fechaHasta;
@Column(name = "nombre_referencia")
......@@ -32,9 +41,12 @@ public class Experiencia {
@Column(name = "telefono_referencia")
private String telefonoReferencia;
@Column(name = "cargo")
@NotBlank
private String cargo;
@Column(name = "descripcion")
private String descripcion;
@JsonBackReference
@ManyToOne(optional = false)
@JoinColumn
......
package com.roshka.modelo;
import javax.persistence.*;
import javax.validation.constraints.*;
import com.fasterxml.jackson.annotation.JsonManagedReference;
......@@ -20,36 +21,52 @@ public class Postulante {
private long id;
@Column(name="nombre")
@NotBlank
@Size(max = 255)
private String nombre;
@Column(name = "apellido")
@NotBlank
@Size(max = 255)
private String apellido;
@Column(name = "ci")
@NotBlank
@Size(max = 120)
private String ci;
@Column(name = "correo")
@NotBlank
@Email(message = "Formato incorrecto de correo")
private String correo;
@Column(name = "ciudad")
@NotBlank
@Size(max = 120)
private String ciudad;
@Column(name = "telefono")
@NotBlank
private String telefono;
@Column(name = "fecha_nacimiento")
@NotNull
@Past
private Date fechaNacimiento;
@Column(name = "resumen")
private String resumen;
@Column(name = "nivel_ingles")
@Min(value = 1)
@Max(value = 5)
private long nivelIngles;
@Column(name = "curriculum")
private String curriculum;
@Column(name = "modalidad")
@NotNull
private String modalidad;
@Column(name = "disponibilidad")
......
......@@ -8,6 +8,9 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonBackReference;
@Entity
......@@ -18,15 +21,20 @@ public class PostulanteTecnologia {
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
private long id ;
@Column(name="nivel")
@Min(value = 1)
@Max(value = 5)
private Long nivel;
@ManyToOne()
@JoinColumn
private Tecnologia tecnologia;
@ManyToOne()
@ManyToOne()
@JoinColumn
@JsonBackReference
private Postulante postulante;
private Postulante postulante;
public long getId() {
return id;
}
......
......@@ -6,6 +6,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
@Entity
@Table(name="tecnologia")
......@@ -16,6 +17,7 @@ public class Tecnologia {
private long id;
@Column(name="nombre")
@NotBlank
private String nombre;
......
......@@ -96,7 +96,9 @@ form.addEventListener("submit",(evt)=>{
postData('postulante', serializeJSON(form))
.then(response => {
location.replace(response.url);
if(response.status==200 || response.status==302){
location.replace(response.url);
}
});
evt.preventDefault();
} );
\ No newline at end of file
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