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