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
86dda698
Commit
86dda698
authored
Nov 08, 2021
by
Joel Florentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filtros en listado de convocatorias
parent
758f8e18
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
14 deletions
+37
-14
curriculumsearch/src/main/java/com/roshka/controller/CargoController.java
+12
-2
curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java
+2
-2
curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java
+6
-0
curriculumsearch/src/main/webapp/jsp/cargo.jsp
+17
-10
No files found.
curriculumsearch/src/main/java/com/roshka/controller/CargoController.java
View file @
86dda698
package
com
.
roshka
.
controller
;
package
com
.
roshka
.
controller
;
import
java.util.Date
;
import
com.roshka.modelo.Cargo
;
import
com.roshka.modelo.Cargo
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
com.roshka.repositorio.CargoRepository
;
import
com.roshka.repositorio.CargoRepository
;
import
com.roshka.repositorio.ConvocatoriaRepository
;
import
com.roshka.repositorio.ConvocatoriaRepository
;
import
org.hibernate.jpa.TypedParameterValue
;
import
org.hibernate.type.IntegerType
;
import
org.hibernate.type.LongType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
...
@@ -27,10 +32,15 @@ public class CargoController {
...
@@ -27,10 +32,15 @@ public class CargoController {
}
}
@RequestMapping
(
"/cargos"
)
@RequestMapping
(
"/cargos"
)
public
String
menuCargos
(
Model
model
,
@RequestParam
(
required
=
false
)
Long
cargoId
)
{
public
String
menuCargos
(
Model
model
,
@RequestParam
(
required
=
false
)
Long
cargoId
,
@RequestParam
(
required
=
false
)
Integer
isOpen
//1: true, 0: false
)
{
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
model
.
addAttribute
(
"convocatorias"
,
cargoId
==
null
?
convoRepo
.
findAll
()
:
convoRepo
.
findByCargoId
(
cargoId
));
model
.
addAttribute
(
"convocatorias"
,
convoRepo
.
f1ndByCargoAndEstado
(
new
TypedParameterValue
(
LongType
.
INSTANCE
,
cargoId
),
new
Date
(),
new
TypedParameterValue
(
IntegerType
.
INSTANCE
,
isOpen
)));
//model.addAttribute("convocatorias",cargoId==null? convoRepo.findAll() : convoRepo.findByCargoId(cargoId));
return
"cargo"
;
return
"cargo"
;
}
}
...
...
curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java
View file @
86dda698
...
@@ -41,11 +41,11 @@ public class ConvocatoriaCargo {
...
@@ -41,11 +41,11 @@ public class ConvocatoriaCargo {
@Column
(
name
=
"cupos"
)
@Column
(
name
=
"cupos"
)
private
int
cupos
;
private
int
cupos
;
//para
serializar en
el form como string
//para
deserializar desde
el form como string
@Transient
@Transient
private
String
fechaFinS
;
private
String
fechaFinS
;
//para
serializar en
el form como string
//para
deserializar desde
el form como string
@Transient
@Transient
private
String
fechaInicioS
;
private
String
fechaInicioS
;
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java
View file @
86dda698
package
com
.
roshka
.
repositorio
;
package
com
.
roshka
.
repositorio
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
org.hibernate.jpa.TypedParameterValue
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
public
interface
ConvocatoriaRepository
extends
JpaRepository
<
ConvocatoriaCargo
,
Long
>
{
public
interface
ConvocatoriaRepository
extends
JpaRepository
<
ConvocatoriaCargo
,
Long
>
{
public
List
<
ConvocatoriaCargo
>
findByCargoId
(
Long
cargoId
);
public
List
<
ConvocatoriaCargo
>
findByCargoId
(
Long
cargoId
);
@Query
(
"select c from ConvocatoriaCargo c where ( ?1 is null and ?3 is null) or ( ( ( (c.fechaFin > ?2 and ?3 = 1) or (c.fechaFin < ?2 and ?3 = 0)) or ?3 is null ) and (c.cargoId = ?1 or ?1 is null) )"
)
public
List
<
ConvocatoriaCargo
>
f1ndByCargoAndEstado
(
TypedParameterValue
cargoId
,
Date
fecha
,
TypedParameterValue
isOpen
);
}
}
curriculumsearch/src/main/webapp/jsp/cargo.jsp
View file @
86dda698
...
@@ -13,13 +13,23 @@
...
@@ -13,13 +13,23 @@
</head>
</head>
<body
class=
"container"
>
<body
class=
"container"
>
<div>
<div>
Cargos:
<form>
<select
class=
"form-select"
name=
"cargos"
id=
"cargos"
>
<label
for=
"cargos"
>
Cargos:
</label>
<option
value=
"-1"
>
Todos los cargos
</option>
<select
class=
"form-select"
name=
"cargoId"
id=
"cargos"
>
<option
value=
""
>
Todos los cargos
</option>
<c:forEach
items=
"${cargos}"
var=
"cargo"
>
<c:forEach
items=
"${cargos}"
var=
"cargo"
>
<option
value=
"${cargo.id}"
${
param
.
cargoId =
=
cargo
.
id
?
"
selected
"
:
""}
>
${cargo.nombre}
</option>
<option
value=
"${cargo.id}"
${
param
.
cargoId =
=
cargo
.
id
?
"
selected
"
:
""}
>
${cargo.nombre}
</option>
</c:forEach>
</c:forEach>
</select>
</select>
Estado:
<input
type=
"radio"
id=
"cualquiera"
name=
"isOpen"
checked
value=
""
>
<label
for=
"abierto"
>
Cualquiera
</label><br>
<input
type=
"radio"
id=
"abierto"
name=
"isOpen"
value=
"1"
>
<label
for=
"abierto"
>
Abierto
</label><br>
<input
type=
"radio"
id=
"cerrado"
name=
"isOpen"
value=
"0"
>
<label
for=
"cerrado"
>
Cerrado
</label><br>
<input
type=
"submit"
value=
"Buscar"
>
</form>
<a
href=
"/cargo"
>
Agregar Nuevo Cargo
</a>
<a
href=
"/cargo"
>
Agregar Nuevo Cargo
</a>
</div>
</div>
<div>
<div>
...
@@ -28,6 +38,7 @@
...
@@ -28,6 +38,7 @@
<thead>
<thead>
<tr>
<tr>
<th
scope=
"col"
>
#
</th>
<th
scope=
"col"
>
#
</th>
<th
scope=
"col"
>
Cargo
</th>
<th
scope=
"col"
>
Fecha Desde
</th>
<th
scope=
"col"
>
Fecha Desde
</th>
<th
scope=
"col"
>
Fecha Hasta
</th>
<th
scope=
"col"
>
Fecha Hasta
</th>
<th
scope=
"col"
>
Vacantes
</th>
<th
scope=
"col"
>
Vacantes
</th>
...
@@ -38,6 +49,7 @@
...
@@ -38,6 +49,7 @@
<c:forEach
items=
"${convocatorias}"
var=
"convocatoria"
varStatus=
"sta"
>
<c:forEach
items=
"${convocatorias}"
var=
"convocatoria"
varStatus=
"sta"
>
<tr>
<tr>
<th
scope=
"row"
>
${sta.index+1}
</th>
<th
scope=
"row"
>
${sta.index+1}
</th>
<td>
${convocatoria.getCargo().getNombre()}
</td>
<td>
${convocatoria.getFechaInicio().toString().split(" ")[0]}
</td>
<td>
${convocatoria.getFechaInicio().toString().split(" ")[0]}
</td>
<td>
${convocatoria.getFechaFin().toString().split(" ")[0]}
</td>
<td>
${convocatoria.getFechaFin().toString().split(" ")[0]}
</td>
<td>
${convocatoria.getCupos()}
</td>
<td>
${convocatoria.getCupos()}
</td>
...
@@ -50,12 +62,6 @@
...
@@ -50,12 +62,6 @@
</tbody>
</tbody>
</table>
</table>
</div>
</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
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