Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
th-app-java
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oscar Enrique Gonzalez Escurra
th-app-java
Commits
d4d963a8
Commit
d4d963a8
authored
Nov 02, 2021
by
Cesar Giulano Gonzalez Maqueda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Algunas validaciones
parent
37797605
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
4 deletions
+50
-4
curriculumsearch/pom.xml
+10
-0
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
+23
-4
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
+17
-0
No files found.
curriculumsearch/pom.xml
View file @
d4d963a8
...
@@ -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>
...
...
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
View file @
d4d963a8
...
@@ -4,19 +4,22 @@ import java.text.SimpleDateFormat;
...
@@ -4,19 +4,22 @@ import java.text.SimpleDateFormat;
import
java.util.Date
;
import
java.util.Date
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.ConstraintViolationException
;
import
com.roshka.modelo.Experiencia
;
import
com.roshka.modelo.Experiencia
;
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.validation.FieldError
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.servlet.ModelAndView
;
@Controller
@Controller
public
class
PostulanteController
{
public
class
PostulanteController
{
@Autowired
@Autowired
PostulanteRepository
post
;
PostulanteRepository
post
;
...
@@ -42,4 +45,20 @@ public class PostulanteController {
...
@@ -42,4 +45,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
());
}
}
}
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
View file @
d4d963a8
package
com
.
roshka
.
modelo
;
package
com
.
roshka
.
modelo
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
javax.validation.constraints.*
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -17,36 +18,52 @@ public class Postulante {
...
@@ -17,36 +18,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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment