Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
securityRemake
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Juan Guevara Mayta
securityRemake
Commits
5f846704
Commit
5f846704
authored
Oct 02, 2023
by
Mauro Paolo Josue Zuñiga Mallqui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] CAMBIOS
parent
e5296ae9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
93 deletions
+97
-93
MenuMYSQLDAO.java
.../com/mycompany/moduloseguridad/mysqldao/MenuMYSQLDAO.java
+57
-88
UsuarioMYSQLDAO.java
...m/mycompany/moduloseguridad/mysqldao/UsuarioMYSQLDAO.java
+7
-2
usuario.js
src/main/webapp/js/pages/usuario.js
+16
-2
mantenimientoProyecto.jsp
src/main/webapp/vistas/mantenimientoProyecto.jsp
+4
-1
mantenimientoUsuario.jsp
src/main/webapp/vistas/mantenimientoUsuario.jsp
+13
-0
No files found.
src/main/java/com/mycompany/moduloseguridad/mysqldao/MenuMYSQLDAO.java
View file @
5f846704
...
...
@@ -19,38 +19,41 @@ import org.json.JSONObject;
*/
public
class
MenuMYSQLDAO
implements
MenuDAO
{
public
static
void
main
(
String
[]
args
)
{
MenuMYSQLDAO
menuMYSQLDAO
=
new
MenuMYSQLDAO
();
try
{
JSONArray
lista
=
menuMYSQLDAO
.
listarProyecto
(
1
);
System
.
out
.
println
(
"lista: "
+
lista
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Error: "
+
e
.
getMessage
());
}
}
@Override
public
JSONArray
listarProyecto
(
int
estado
)
throws
Exception
{
String
base
=
"security"
;
Connection
con
=
null
;
PreparedStatement
pst
=
null
;
ResultSet
rs
=
null
;
String
query
=
""
;
boolean
estadoFinal
=
estado
!=
1
;
String
sql
=
""
;
JSONArray
lista
=
new
JSONArray
();
try
{
query
=
"select pd.cod_proyecto, p.nom from proyecto_detalle as pd "
+
"inner join proyecto as p "
+
"on p.cod_proyecto = pd.cod_proyecto "
+
"where p.est = "
+
estadoFinal
+
" group by pd.cod_proyecto, p.nom "
;
System
.
out
.
println
(
query
);
sql
=
"{ CALL seguridad.SP_MENU( ?,?,?,?,?,?,?,?,?) }"
;
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
pst
=
con
.
prepareStatement
(
query
);
rs
=
pst
.
executeQuery
();
while
(
rs
.
next
())
{
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"codigoProyecto"
,
rs
.
getInt
(
1
));
obj
.
put
(
"nombreProyecto"
,
rs
.
getString
(
2
));
lista
.
put
(
obj
);
}
JSONArray
params
=
new
JSONArray
();
params
.
put
(
"listarProyecto"
);
params
.
put
(
estado
);
params
.
put
(
0
);
params
.
put
(
0
);
params
.
put
(
0
);
params
.
put
(
""
);
params
.
put
(
""
);
params
.
put
(
""
);
params
.
put
(
""
);
lista
=
DAOHelper
.
queryProcedure
(
con
,
sql
,
params
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Error en listarProyecto: "
+
e
.
getMessage
());
}
finally
{
assert
con
!=
null
;
con
.
close
();
assert
pst
!=
null
;
pst
.
close
();
}
return
lista
;
}
...
...
@@ -59,31 +62,27 @@ public class MenuMYSQLDAO implements MenuDAO {
public
JSONArray
listarTipoDeUsuario
(
int
proyecto
)
throws
Exception
{
String
base
=
"security"
;
Connection
con
=
null
;
PreparedStatement
pst
=
null
;
ResultSet
rs
=
null
;
String
query
=
""
;
String
sql
=
""
;
JSONArray
lista
=
new
JSONArray
();
try
{
query
=
" select pd.cod_proyecto_detalle, tu.nom from proyecto_detalle as pd "
+
"inner join tipo_usuario as tu "
+
"on pd.cod_tipo_usuario = tu.cod_tipo_usuario "
+
"where cod_proyecto = "
+
proyecto
+
""
;
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
pst
=
con
.
prepareStatement
(
query
);
rs
=
pst
.
executeQuery
(
);
while
(
rs
.
next
())
{
JSONObject
obj
=
new
JSONObject
(
);
obj
.
put
(
"codigoDetalle"
,
rs
.
getInt
(
1
)
);
obj
.
put
(
"nombreTipoUsuario"
,
rs
.
getString
(
2
)
);
lista
.
put
(
obj
);
}
}
catch
(
Exception
e
)
{
try
{
sql
=
"{ CALL seguridad.SP_MENU( ?,?,?,?,?,?,?,?,?) }"
;
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
JSONArray
params
=
new
JSONArray
();
params
.
put
(
"listarTipoDeUsuario"
)
;
params
.
put
(
proyecto
);
params
.
put
(
0
);
params
.
put
(
0
);
params
.
put
(
0
);
params
.
put
(
""
);
params
.
put
(
""
);
params
.
put
(
""
);
params
.
put
(
""
);
lista
=
DAOHelper
.
queryProcedure
(
con
,
sql
,
params
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Error en listarTipoDeUsuario: "
+
e
.
getMessage
());
}
finally
{
assert
con
!=
null
;
con
.
close
();
assert
pst
!=
null
;
pst
.
close
();
}
return
lista
;
}
...
...
@@ -92,57 +91,27 @@ public class MenuMYSQLDAO implements MenuDAO {
public
JSONArray
listarTituloCompleto
(
int
proyecto_detalle
,
int
proyecto
,
int
tipo
)
throws
Exception
{
String
base
=
"security"
;
Connection
con
=
null
;
PreparedStatement
pst
=
null
;
ResultSet
rs
=
null
;
String
query
=
""
;
String
extra
=
""
;
String
sql
=
""
;
JSONArray
lista
=
new
JSONArray
();
try
{
if
(
proyecto_detalle
==
0
)
{
if
(
tipo
==
1
)
{
extra
=
" -1 "
;
}
query
=
"select t.cod_titulo, t.nom, t.ico, t.est, 0, 0, count(*) as cant "
+
"from titulo_configuracion tc "
+
"left join proyecto_detalle as pd "
+
"on tc.cod_proyecto_detalle = pd.cod_proyecto_detalle "
+
"inner join titulo as t "
+
"on t.cod_titulo = tc.cod_titulo "
+
"where pd.cod_proyecto = "
+
proyecto
+
" "
+
"group by t.cod_titulo, t.nom, t.ico, t.est "
+
"HAVING COUNT(*) = "
+
"( "
+
"select COUNT(*) "
+
extra
+
" "
+
"from proyecto_detalle "
+
"where cod_proyecto = "
+
proyecto
+
" "
+
") "
;
}
else
{
query
=
" select t.cod_titulo, t.nom, t.ico, t.est, tc.cod_titulo_configuracion, tc.ord from titulo as t "
+
" inner join titulo_configuracion as tc "
+
" on tc.cod_titulo = t.cod_titulo "
+
" where tc.cod_proyecto_detalle = "
+
proyecto_detalle
+
""
+
" order by ord "
;
}
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
pst
=
con
.
prepareStatement
(
query
);
rs
=
pst
.
executeQuery
();
while
(
rs
.
next
())
{
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"codigoTitulo"
,
rs
.
getInt
(
1
));
obj
.
put
(
"nombreTitulo"
,
rs
.
getString
(
2
));
obj
.
put
(
"iconoTitulo"
,
rs
.
getString
(
3
));
obj
.
put
(
"estadoTitulo"
,
rs
.
getString
(
4
));
obj
.
put
(
"configuracionTitulo"
,
rs
.
getString
(
5
));
obj
.
put
(
"ordenTitulo"
,
rs
.
getString
(
6
));
lista
.
put
(
obj
);
}
sql
=
"{ CALL seguridad.SP_MENU( ?,?,?,?,?,?,?,?,?) }"
;
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
JSONArray
params
=
new
JSONArray
();
params
.
put
(
"listarTipoDeUsuario"
);
params
.
put
(
proyecto_detalle
);
params
.
put
(
proyecto
);
params
.
put
(
tipo
);
params
.
put
(
0
);
params
.
put
(
""
);
params
.
put
(
""
);
params
.
put
(
""
);
params
.
put
(
""
);
lista
=
DAOHelper
.
queryProcedure
(
con
,
sql
,
params
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Error en listarTituloCompleto: "
+
e
.
getMessage
());
}
finally
{
assert
con
!=
null
;
con
.
close
();
assert
pst
!=
null
;
pst
.
close
();
assert
con
!=
null
;
con
.
close
();
}
return
lista
;
}
...
...
@@ -2897,7 +2866,7 @@ public class MenuMYSQLDAO implements MenuDAO {
"from seguridad.categoria_acciones\n"
+
" inner join seguridad.categoria on categoria_acciones.cod_categoria = categoria.cod_categoria\n"
+
" inner join seguridad.accion on categoria_acciones.cod_accion = accion.cod_accion\n"
+
"where categoria.cod_categoria = ? and
modulo
_acciones.cod_proyecto_detalle = ? ;"
;
"where categoria.cod_categoria = ? and
categoria
_acciones.cod_proyecto_detalle = ? ;"
;
}
else
if
(
datos
.
getInt
(
"jerarquia"
)
==
4
){
sql
=
"select\n"
+
" subcategoria_acciones.cod_sub_acc as codigo,\n"
+
...
...
@@ -2908,7 +2877,7 @@ public class MenuMYSQLDAO implements MenuDAO {
"from seguridad.subcategoria_acciones\n"
+
" inner join seguridad.subcategoria on subcategoria_acciones.cod_subcategoria = subcategoria.cod_subcategoria\n"
+
" inner join seguridad.accion on subcategoria_acciones.cod_accion = accion.cod_accion\n"
+
"where subcategoria.cod_subcategoria = ? and
modulo
_acciones.cod_proyecto_detalle = ? ;"
;
"where subcategoria.cod_subcategoria = ? and
subcategoria
_acciones.cod_proyecto_detalle = ? ;"
;
}
pst
=
con
.
prepareStatement
(
sql
);
...
...
src/main/java/com/mycompany/moduloseguridad/mysqldao/UsuarioMYSQLDAO.java
View file @
5f846704
...
...
@@ -26,11 +26,12 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
Connection
con
=
null
;
PreparedStatement
pst
=
null
;
ResultSet
rs
=
null
;
String
query
=
""
;
String
query
=
""
;
JSONArray
lista
=
new
JSONArray
();
try
{
String
estado
=
!
datos
.
getBoolean
(
"estado"
)
?
" and a.est = 1 "
:
" and a.est = 0 "
;
String
estadoTipoUsuario
=
datos
.
getInt
(
"estadoTipoUsuario"
)
==
2
?
""
:
" and ud.est = "
+
datos
.
getInt
(
"estadoTipoUsuario"
)+
" "
;
int
proyecto
=
datos
.
isNull
(
"proyecto"
)
?
0
:
datos
.
getInt
(
"proyecto"
);
int
tipoUsuario
=
datos
.
isNull
(
"tipoUsuario"
)
?
0
:
datos
.
getInt
(
"tipoUsuario"
);
int
estadoPersonal
=
datos
.
isNull
(
"estadoPersonal"
)
?
2
:
datos
.
getInt
(
"estadoPersonal"
)
==
0
?
2
:
datos
.
getInt
(
"estadoPersonal"
)
==
1
?
0
:
1
;
...
...
@@ -45,10 +46,12 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
" left join seguridad.tipo_usuario as tu on pd.cod_tipo_usuario = tu.cod_tipo_usuario\n"
+
" left join nuevo.personal as p on a.cod_trabajador = p.tmp_id\n"
+
" left join nuevo.cargo as c on p.codcargo = c.codcargo\n"
+
" WHERE 1 = 1
and ud.est = 1
\n"
+
" WHERE 1 = 1 \n"
+
" and if("
+
proyecto
+
" = 0, true, pd.cod_proyecto = "
+
proyecto
+
")\n"
+
" and if("
+
tipoUsuario
+
" = 0, true, pd.cod_proyecto_detalle = "
+
tipoUsuario
+
")\n"
+
" "
+
estado
+
"\n"
+
" "
+
estadoTipoUsuario
+
"\n"
+
" and if("
+
estadoPersonal
+
" = 2, true, p.retirado = "
+
estadoPersonal
+
")\n"
+
" and if("
+
estadoPersonal
+
" = 2, true, p.retirado = "
+
estadoPersonal
+
")\n"
+
(
isNumber
?
" and p.numero_documento = "
+
personal
+
" \n"
:
" and a.usu like '%"
+
personal
+
"%' \n"
)+
" and if('"
+
cargo
+
"' = '', true, c.descargo = '"
+
cargo
+
"')\n"
+
...
...
@@ -93,6 +96,7 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
String
busqueda
=
""
;
try
{
String
estado
=
!
datos
.
getBoolean
(
"estado"
)
?
" and a.est = 1 "
:
" and a.est = 0 "
;
String
estadoTipoUsuario
=
datos
.
getInt
(
"estadoTipoUsuario"
)
==
2
?
""
:
" and ud.est = "
+
datos
.
getInt
(
"estadoTipoUsuario"
)+
" "
;
int
proyecto
=
datos
.
isNull
(
"proyecto"
)
?
0
:
datos
.
getInt
(
"proyecto"
);
int
tipoUsuario
=
datos
.
isNull
(
"tipoUsuario"
)
?
0
:
datos
.
getInt
(
"tipoUsuario"
);
int
estadoPersonal
=
datos
.
isNull
(
"estadoPersonal"
)
?
2
:
datos
.
getInt
(
"estadoPersonal"
)
==
0
?
2
:
datos
.
getInt
(
"estadoPersonal"
)
==
1
?
0
:
1
;
...
...
@@ -109,6 +113,7 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
" and if("
+
proyecto
+
" = 0, true, pd.cod_proyecto = "
+
proyecto
+
")\n"
+
" and if("
+
tipoUsuario
+
" = 0, true, pd.cod_proyecto_detalle = "
+
tipoUsuario
+
")\n"
+
" "
+
estado
+
"\n"
+
" "
+
estadoTipoUsuario
+
"\n"
+
" and if("
+
estadoPersonal
+
" = 2, true, p.retirado = "
+
estadoPersonal
+
")\n"
+
" and if('"
+
cargo
+
"' = '', true, c.descargo = '"
+
cargo
+
"')\n"
+
(
isNumber
?
" and p.numero_documento = "
+
personal
+
" \n"
:
" and a.usu like '%"
+
personal
+
"%' \n"
)
...
...
src/main/webapp/js/pages/usuario.js
View file @
5f846704
...
...
@@ -14,6 +14,15 @@ function segundaCarga() {
listarProyectos
(
'cboProyecto'
);
listarTipoDeUsuario
(
-
1
,
'cboProyecto'
,
'cboTipoUsuario'
);
asignarEventosSelect
();
buscarConEnter
();
}
const
buscarConEnter
=
()
=>
{
$
(
'#txtTrabajador'
).
on
(
'keyup'
,
function
(
e
)
{
if
(
e
[
"keyCode"
]
===
13
)
{
$
(
'#btnBuscar'
).
trigger
(
'click'
);
}
});
}
const
asignarEventosSelect
=
()
=>
{
...
...
@@ -205,7 +214,8 @@ var datosUsuario = {
"proyecto"
:
$
(
'#cboProyecto'
).
val
(),
"tipoUsuario"
:
$
(
'#cboTipoUsuario'
).
val
(),
"cargo"
:
$
(
'#cboCargos'
).
val
(),
"estado"
:
isChecked
"estado"
:
isChecked
,
"estadoTipoUsuario"
:
Number
(
$
(
'#cboEstadoTipoUsuario'
).
val
())
||
2
};
let
conta
=
1
;
let
paramDataTable
=
{
...
...
@@ -1251,6 +1261,10 @@ function desactivarDetalle(filtro) {
}
}
});
}
else
{
setTimeout
(()
=>
{
$
(
'.mantenimientoDetalle'
).
removeClass
(
'hide'
);
},
500
)
}
})
});
...
...
@@ -1541,7 +1555,7 @@ refrescar = () => {
$
(
"#tblUsuario"
).
DataTable
().
ajax
.
reload
()
}
$
(
'
[type="checkbox"]'
).
click
(
function
(
e
)
{
$
(
'
#cbkEstado'
).
on
(
'click'
,
function
(
e
)
{
if
(
document
.
querySelector
(
'#cbkEstado'
).
checked
)
{
document
.
querySelector
(
'#txtEstado'
).
innerText
=
'MOSTRANDO INACTIVOS'
;
}
else
{
...
...
src/main/webapp/vistas/mantenimientoProyecto.jsp
View file @
5f846704
...
...
@@ -12,6 +12,7 @@
<!--template-core-->
<!--css-->
<link
href=
"../css/lib/jquery-editable-select.min.css"
rel=
"stylesheet"
type=
"text/css"
/>
<link
href=
"../css/general.css"
rel=
"stylesheet"
type=
"text/css"
/>
<!--css-->
</head>
...
...
@@ -94,7 +95,8 @@
<!-- / content -->
<
%@
include
file=
"templates/footer-body.jsp"
%
>
<!--js-->
<script
src=
"../js/lib/jquery-editable-select.min.js"
type=
"text/javascript"
></script>
<script
src=
"../js/pages/proyecto.js"
type=
"text/javascript"
></script>
<!--js-->
</body>
</html>
</html>
\ No newline at end of file
src/main/webapp/vistas/mantenimientoUsuario.jsp
View file @
5f846704
...
...
@@ -113,6 +113,19 @@
</select>
</div>
</div>
<div
class=
'col-md-4'
>
<div
class=
"form-group"
>
<label
style=
"font-size: small"
>
Estado de TIpo de Usuario :
</label>
<span
class=
"asterisk"
>
(*)
</span>
<select
id=
"cboEstadoTipoUsuario"
class=
"form-control"
name=
"cboTipoUsuario"
>
<option
value=
"2"
>
TODOS
</option>
<option
value=
"1"
>
ACTIVOS
</option>
<option
value=
"0"
>
INACTIVOS
</option>
</select>
</div>
</div>
</div>
<div
class=
"row"
style=
"display: flex; justify-content: center;"
>
<div
class=
"col-md-4"
>
...
...
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