From 2d519b301b5b9a01b42db011c5082e767772d4af Mon Sep 17 00:00:00 2001 From: Nelson Date: Mon, 1 Nov 2021 09:49:55 -0300 Subject: [PATCH] Se hizo post de postulantes --- .vscode/launch.json | 14 ++++++++++++++ curriculumsearch/pom.xml | 6 ++++++ curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java | 24 +++++++++++++++++++++--- curriculumsearch/src/main/resources/application.properties | 4 +--- curriculumsearch/src/main/webapp/jsp/home.jsp | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 185 insertions(+), 6 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java create mode 100644 curriculumsearch/src/main/webapp/jsp/home.jsp diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..dada7c0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + "configurations": [ + { + "type": "java", + "name": "Spring Boot-CurriculumsearchApplication", + "request": "launch", + "cwd": "${workspaceFolder}", + "console": "internalConsole", + "mainClass": "com.roshka.CurriculumsearchApplication", + "projectName": "curriculumsearch", + "args": "" + } + ] +} \ No newline at end of file diff --git a/curriculumsearch/pom.xml b/curriculumsearch/pom.xml index 9f21fc5..6d8230f 100644 --- a/curriculumsearch/pom.xml +++ b/curriculumsearch/pom.xml @@ -41,6 +41,12 @@ tomcat-jasper 9.0.54 + + + org.springframework.boot + spring-boot-devtools + true + diff --git a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java new file mode 100644 index 0000000..6704d99 --- /dev/null +++ b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java @@ -0,0 +1,58 @@ +package com.roshka.controller; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.servlet.http.HttpServletRequest; + +import com.roshka.modelo.Postulante; +import com.roshka.repositorio.PostulanteRepository; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpRequest; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@Controller + +public class PostulanteController { + @Autowired + PostulanteRepository post; + @RequestMapping("/") + public String index(){ + + return "home"; + } + + @PostMapping("/") + public String guardarPostulante( @RequestParam String nombre,@RequestParam String apellido, @RequestParam + String ci,@RequestParam String correo,@RequestParam String ciudad,@RequestParam String telefono, + @RequestParam String fechaNacimiento,@RequestParam String resumen,@RequestParam long nivelIngles, + @RequestParam String curriculum, @RequestParam String modalidad,@RequestParam String disponibilidad ){ + + try { + Date date1=new SimpleDateFormat("yyyy-mm-dd").parse(fechaNacimiento); + Postulante postulante= new Postulante(nombre, apellido, ci, correo, ciudad, + telefono,date1, resumen, + nivelIngles, curriculum, modalidad, disponibilidad); + post.save(postulante); + + } catch (Exception e) { + //TODO: handle exception + System.out.println(e); + } + + + + + + + System.out.println( fechaNacimiento); + + return "dfg"; + } + +} diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java index cc4c33c..3614020 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java @@ -8,6 +8,24 @@ import java.util.List; @Entity @Table(name="postulante") public class Postulante { + + + public Postulante(String nombre, String apellido, String ci, String correo, String ciudad, String telefono, + Date fechaNacimiento, String resumen, long nivelIngles, String curriculum, String modalidad, + String disponibilidad) { + this.nombre = nombre; + this.apellido = apellido; + this.ci = ci; + this.correo = correo; + this.ciudad = ciudad; + this.telefono = telefono; + this.fechaNacimiento = fechaNacimiento; + this.resumen = resumen; + this.nivelIngles = nivelIngles; + this.curriculum = curriculum; + this.modalidad = modalidad; + this.disponibilidad = disponibilidad; + } @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") @@ -49,13 +67,13 @@ public class Postulante { @Column(name = "disponibilidad") private String disponibilidad; - @OneToMany(mappedBy = "postulante") + @OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL) private List tecnologias; - @OneToMany(mappedBy = "postulante") + @OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL) private List experiencias; - @OneToMany(mappedBy = "postulante") + @OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL) private List estudios; public long getId() { diff --git a/curriculumsearch/src/main/resources/application.properties b/curriculumsearch/src/main/resources/application.properties index f8df400..d6c6325 100644 --- a/curriculumsearch/src/main/resources/application.properties +++ b/curriculumsearch/src/main/resources/application.properties @@ -11,7 +11,5 @@ spring.sql.init.platform=postgres spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true #server.port=8888 -spring.mvc.view.prefix=/WEB-INF/views/ +spring.mvc.view.prefix=/jsp/ spring.mvc.view.suffix=.jsp - - diff --git a/curriculumsearch/src/main/webapp/jsp/home.jsp b/curriculumsearch/src/main/webapp/jsp/home.jsp new file mode 100644 index 0000000..83d4b1c --- /dev/null +++ b/curriculumsearch/src/main/webapp/jsp/home.jsp @@ -0,0 +1,85 @@ + + + + + + + + + + + Hello, world! + + +

Hello, world!

+ +
+
+ + +
We'll never share your email with anyone else.
+
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+ + + + + + + + + + \ No newline at end of file -- libgit2 0.26.0