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
0
Merge Requests
0
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
Amparo Oliver
th-app-java
Commits
758f8e18
Commit
758f8e18
authored
Nov 05, 2021
by
Joel Florentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form para crear listar convocatorias y cargos
parent
a2013f11
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
241 additions
and
9 deletions
+241
-9
curriculumsearch/src/main/java/com/roshka/controller/CargoController.java
+64
-0
curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java
+33
-1
curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java
+9
-0
curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java
+11
-0
curriculumsearch/src/main/webapp/jsp/cargo-form.jsp
+29
-0
curriculumsearch/src/main/webapp/jsp/cargo.jsp
+49
-8
curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp
+46
-0
No files found.
curriculumsearch/src/main/java/com/roshka/controller/CargoController.java
0 → 100644
View file @
758f8e18
package
com
.
roshka
.
controller
;
import
com.roshka.modelo.Cargo
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
com.roshka.repositorio.CargoRepository
;
import
com.roshka.repositorio.ConvocatoriaRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
@Controller
public
class
CargoController
{
CargoRepository
cargoRepo
;
ConvocatoriaRepository
convoRepo
;
@Autowired
public
CargoController
(
CargoRepository
cargoRepo
,
ConvocatoriaRepository
convoRepo
)
{
this
.
cargoRepo
=
cargoRepo
;
this
.
convoRepo
=
convoRepo
;
}
@RequestMapping
(
"/cargos"
)
public
String
menuCargos
(
Model
model
,
@RequestParam
(
required
=
false
)
Long
cargoId
)
{
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
model
.
addAttribute
(
"convocatorias"
,
cargoId
==
null
?
convoRepo
.
findAll
()
:
convoRepo
.
findByCargoId
(
cargoId
));
return
"cargo"
;
}
@RequestMapping
(
"/cargo"
)
public
String
formCargo
(
Model
model
)
{
model
.
addAttribute
(
"cargo"
,
new
Cargo
());
return
"cargo-form"
;
}
@PostMapping
(
"/cargo"
)
public
String
guardarCargo
(
@ModelAttribute
Cargo
cargo
,
BindingResult
result
)
{
if
(
result
.
hasErrors
());
cargoRepo
.
save
(
cargo
);
System
.
out
.
println
(
cargo
.
getNombre
());
return
"redirect:/cargos"
;
}
@RequestMapping
(
"/convocatoria"
)
public
String
formConvocatoria
(
Model
model
)
{
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
model
.
addAttribute
(
"convocatoria"
,
new
ConvocatoriaCargo
());
return
"convocatoria-form"
;
}
@PostMapping
(
"/convocatoria"
)
public
String
guardarConvocatoria
(
@ModelAttribute
ConvocatoriaCargo
convocatoria
,
BindingResult
result
)
{
if
(
result
.
hasErrors
());
convoRepo
.
save
(
convocatoria
);
System
.
out
.
println
(
convocatoria
.
getFechaInicio
());
return
"redirect:/cargos"
;
}
}
curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java
View file @
758f8e18
...
@@ -12,6 +12,7 @@ import javax.persistence.JoinColumn;
...
@@ -12,6 +12,7 @@ import javax.persistence.JoinColumn;
import
javax.persistence.ManyToMany
;
import
javax.persistence.ManyToMany
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
import
com.roshka.utils.Helper
;
import
com.roshka.utils.Helper
;
...
@@ -24,10 +25,13 @@ public class ConvocatoriaCargo {
...
@@ -24,10 +25,13 @@ public class ConvocatoriaCargo {
private
long
id
;
private
long
id
;
@ManyToOne
()
@ManyToOne
()
@JoinColumn
@JoinColumn
(
name
=
"cargo_id"
,
insertable
=
false
,
updatable
=
false
)
@JsonBackReference
@JsonBackReference
private
Cargo
cargo
;
private
Cargo
cargo
;
@Column
(
name
=
"cargo_id"
)
private
Long
cargoId
;
@Column
(
name
=
"fecha_inicio"
)
@Column
(
name
=
"fecha_inicio"
)
private
Date
fechaInicio
;
private
Date
fechaInicio
;
...
@@ -37,6 +41,14 @@ public class ConvocatoriaCargo {
...
@@ -37,6 +41,14 @@ public class ConvocatoriaCargo {
@Column
(
name
=
"cupos"
)
@Column
(
name
=
"cupos"
)
private
int
cupos
;
private
int
cupos
;
//para serializar en el form como string
@Transient
private
String
fechaFinS
;
//para serializar en el form como string
@Transient
private
String
fechaInicioS
;
@ManyToMany
(
mappedBy
=
"postulaciones"
)
@ManyToMany
(
mappedBy
=
"postulaciones"
)
private
List
<
Postulante
>
postulantes
;
private
List
<
Postulante
>
postulantes
;
...
@@ -82,5 +94,25 @@ public class ConvocatoriaCargo {
...
@@ -82,5 +94,25 @@ public class ConvocatoriaCargo {
public
void
setPostulantes
(
List
<
Postulante
>
postulantes
)
{
public
void
setPostulantes
(
List
<
Postulante
>
postulantes
)
{
this
.
postulantes
=
postulantes
;
this
.
postulantes
=
postulantes
;
}
}
public
Long
getCargoId
()
{
return
cargoId
;
}
public
void
setCargoId
(
Long
cargoId
)
{
this
.
cargoId
=
cargoId
;
}
public
String
getFechaFinS
()
{
return
fechaFinS
;
}
public
String
getFechaInicioS
()
{
return
fechaInicioS
;
}
public
void
setFechaFinS
(
String
fechaFinS
)
{
this
.
fechaFinS
=
fechaFinS
;
setFechaFin
(
fechaFinS
);
}
public
void
setFechaInicioS
(
String
fechaInicioS
)
{
this
.
fechaInicioS
=
fechaInicioS
;
setFechaInicio
(
fechaInicioS
);
}
}
}
curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java
0 → 100644
View file @
758f8e18
package
com
.
roshka
.
repositorio
;
import
com.roshka.modelo.Cargo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
CargoRepository
extends
JpaRepository
<
Cargo
,
Long
>{
}
curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java
0 → 100644
View file @
758f8e18
package
com
.
roshka
.
repositorio
;
import
java.util.List
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
ConvocatoriaRepository
extends
JpaRepository
<
ConvocatoriaCargo
,
Long
>
{
public
List
<
ConvocatoriaCargo
>
findByCargoId
(
Long
cargoId
);
}
curriculumsearch/src/main/webapp/jsp/cargo-form.jsp
0 → 100644
View file @
758f8e18
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"form"
uri=
"http://www.springframework.org/tags/form"
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Cargo
</title>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin=
"anonymous"
>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin=
"anonymous"
></script>
</head>
<body>
<div
class=
"container"
>
<form:form
action=
"/cargo"
method=
"post"
modelAttribute=
"cargo"
class=
"row row-cols-lg-auto g-3 align-items-center"
>
<div
class=
"col-12"
>
<form:label
class=
"form-label visually-hidden"
path=
"nombre"
>
Nombre del cargo
</form:label>
<form:input
type=
"text"
path=
"nombre"
class=
"form-control"
placeholder=
"Nombre del cargo"
/>
</div>
<div
class=
"col-12"
>
<input
type=
"submit"
value=
"Guardar"
class=
"btn btn-primary"
/>
</div>
</form:form>
</div>
</body>
</html>
\ No newline at end of file
curriculumsearch/src/main/webapp/jsp/cargo.jsp
View file @
758f8e18
...
@@ -8,14 +8,54 @@
...
@@ -8,14 +8,54 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Cargo
</title>
<title>
Cargo
</title>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin=
"anonymous"
>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin=
"anonymous"
></script>
</head>
</head>
<body>
<body
class=
"container"
>
<h1>
Hola
</h1>
<div>
<c:forEach
var=
"i"
items=
"${postu}"
>
Cargos:
<tr>
<select
class=
"form-select"
name=
"cargos"
id=
"cargos"
>
<td>
- ${i.getPostulante().getNombre()}
</td>
<option
value=
"-1"
>
Todos los cargos
</option>
</tr>
<c:forEach
items=
"${cargos}"
var=
"cargo"
>
<br/>
<option
value=
"${cargo.id}"
${
param
.
cargoId =
=
cargo
.
id
?
"
selected
"
:
""}
>
${cargo.nombre}
</option>
</c:forEach>
</c:forEach>
</select>
<a
href=
"/cargo"
>
Agregar Nuevo Cargo
</a>
</div>
<div>
<a
href=
"/convocatoria"
>
Agregar Nueva Convocatoria
</a>
<table
class=
"table"
>
<thead>
<tr>
<th
scope=
"col"
>
#
</th>
<th
scope=
"col"
>
Fecha Desde
</th>
<th
scope=
"col"
>
Fecha Hasta
</th>
<th
scope=
"col"
>
Vacantes
</th>
</tr>
</thead>
<tbody>
<c:forEach
items=
"${convocatorias}"
var=
"convocatoria"
varStatus=
"sta"
>
<tr>
<th
scope=
"row"
>
${sta.index+1}
</th>
<td>
${convocatoria.getFechaInicio().toString().split(" ")[0]}
</td>
<td>
${convocatoria.getFechaFin().toString().split(" ")[0]}
</td>
<td>
${convocatoria.getCupos()}
</td>
<td>
Ver Postulantes
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<script>
document
.
querySelector
(
"#cargos"
).
addEventListener
(
"change"
,
evt
=>
{
const
cargoId
=
evt
.
target
.
value
;
if
(
cargoId
==
-
1
)
location
.
assign
(
"/cargos"
);
else
location
.
assign
(
"/cargos?cargoId="
+
cargoId
)
})
</script>
</body>
</body>
</html>
</html>
\ No newline at end of file
curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp
0 → 100644
View file @
758f8e18
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"form"
uri=
"http://www.springframework.org/tags/form"
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Cargo
</title>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin=
"anonymous"
>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin=
"anonymous"
></script>
</head>
<body>
<div
class=
"container"
>
<form:form
action=
"/convocatoria"
method=
"post"
modelAttribute=
"convocatoria"
>
<div
class=
"mb-3"
>
<form:label
path=
"fechaInicioS"
class=
"form-label"
>
Fecha inicial
</form:label>
<form:input
type=
"date"
class=
"form-control"
path=
"fechaInicioS"
/>
</div>
<div
class=
"mb-3"
>
<form:label
path=
"fechaFinS"
class=
"form-label"
>
Fecha Fin
</form:label>
<form:input
type=
"date"
class=
"form-control"
path=
"fechaFinS"
/>
</div>
<div
class=
"mb-3"
>
<form:label
path=
"cupos"
class=
"form-label"
>
Cupos:
</form:label>
<form:input
type=
"number"
class=
"form-control"
path=
"cupos"
/>
</div>
<div
class=
"mb-3 form-check"
>
<form:label
path=
"cargoId"
class=
"form-label"
>
Cargo
</form:label>
<form:select
class=
"form-select"
path=
"cargoId"
>
<c:forEach
items=
"${cargos}"
var=
"cargo"
>
<form:option
value=
"${cargo.id}"
>
${cargo.nombre}
</form:option>
</c:forEach>
</form:select>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
Guardar
</button>
</form:form>
</div>
</body>
</html>
\ No newline at end of file
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