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
60ef6108
Commit
60ef6108
authored
Aug 16, 2023
by
Mauro Paolo Josue Zuñiga Mallqui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EDIT] CAMBIOS PARA LA EDICION DE MENU Y PERMISOS POR VISTA
parent
662341da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
76 deletions
+84
-76
MenuMYSQLDAO.java
.../com/mycompany/moduloseguridad/mysqldao/MenuMYSQLDAO.java
+30
-28
MantenimientoMenuServlet.java
...ny/moduloseguridad/servlets/MantenimientoMenuServlet.java
+54
-48
No files found.
src/main/java/com/mycompany/moduloseguridad/mysqldao/MenuMYSQLDAO.java
View file @
60ef6108
...
...
@@ -7,6 +7,7 @@ package com.mycompany.moduloseguridad.mysqldao;
import
java.sql.*
;
import
com.mycompany.moduloseguridad.utilities.DAOHelper
;
import
com.mycompany.moduloseguridad.utilities.ResponseHelper
;
import
com.mycompany.moduloseguridad.dao.MenuDAO
;
import
org.json.JSONArray
;
...
...
@@ -2816,7 +2817,7 @@ public class MenuMYSQLDAO implements MenuDAO {
"from seguridad.modulo_acciones\n"
+
" left join seguridad.modulo on modulo_acciones.cod_modulo = modulo.cod_modulo\n"
+
" left join seguridad.accion on modulo_acciones.cod_accion = accion.cod_accion\n"
+
"where modulo.cod_modulo = ? and modulo_acciones.cod_
tipo_usuario
= ?;\n"
;
"where modulo.cod_modulo = ? and modulo_acciones.cod_
proyecto_detalle
= ?;\n"
;
}
else
if
(
jerarquia
==
3
)
{
sql
=
"select\n"
+
" categoria.cod_categoria as codigo,\n"
+
...
...
@@ -2826,7 +2827,7 @@ public class MenuMYSQLDAO implements MenuDAO {
"from seguridad.categoria_acciones\n"
+
" left join seguridad.categoria on categoria_acciones.cod_categoria = categoria.cod_categoria\n"
+
" left join seguridad.accion on categoria_acciones.cod_accion = accion.cod_accion\n"
+
"where categoria.cod_categoria = ? and categoria_acciones.cod_
tipo_usuario
= ?;\n"
;
"where categoria.cod_categoria = ? and categoria_acciones.cod_
proyecto_detalle
= ?;\n"
;
}
else
if
(
jerarquia
==
4
)
{
sql
=
"select\n"
+
" subcategoria.cod_subcategoria as codigo,\n"
+
...
...
@@ -2836,7 +2837,7 @@ public class MenuMYSQLDAO implements MenuDAO {
"from seguridad.subcategoria_acciones\n"
+
" left join seguridad.subcategoria on subcategoria_acciones.cod_subcategoria = subcategoria.cod_subcategoria\n"
+
" left join seguridad.accion on subcategoria_acciones.cod_accion = accion.cod_accion\n"
+
"where subcategoria.cod_subcategoria = ? and subcategoria_acciones.cod_
tipo_usuario
= ?;"
;
"where subcategoria.cod_subcategoria = ? and subcategoria_acciones.cod_
proyecto_detalle
= ?;"
;
}
pst
=
con
.
prepareStatement
(
sql
);
pst
.
setInt
(
1
,
codigo
);
...
...
@@ -2883,8 +2884,8 @@ public class MenuMYSQLDAO implements MenuDAO {
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.modulo_acciones\n"
+
"
left
join seguridad.modulo on modulo_acciones.cod_modulo = modulo.cod_modulo\n"
+
"
left
join seguridad.accion on modulo_acciones.cod_accion = accion.cod_accion\n"
+
"
inner
join seguridad.modulo on modulo_acciones.cod_modulo = modulo.cod_modulo\n"
+
"
inner
join seguridad.accion on modulo_acciones.cod_accion = accion.cod_accion\n"
+
"where modulo.cod_modulo = ?;"
;
}
else
if
(
datos
.
getInt
(
"jerarquia"
)
==
3
){
sql
=
"select\n"
+
...
...
@@ -2894,8 +2895,8 @@ public class MenuMYSQLDAO implements MenuDAO {
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.categoria_acciones\n"
+
"
left
join seguridad.categoria on categoria_acciones.cod_categoria = categoria.cod_categoria\n"
+
"
left
join seguridad.accion on categoria_acciones.cod_accion = accion.cod_accion\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 = ?;"
;
}
else
if
(
datos
.
getInt
(
"jerarquia"
)
==
4
){
sql
=
"select\n"
+
...
...
@@ -2905,8 +2906,8 @@ public class MenuMYSQLDAO implements MenuDAO {
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.subcategoria_acciones\n"
+
"
left
join seguridad.subcategoria on subcategoria_acciones.cod_subcategoria = subcategoria.cod_subcategoria\n"
+
"
left
join seguridad.accion on subcategoria_acciones.cod_accion = accion.cod_accion\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 = ?;"
;
}
...
...
@@ -3047,24 +3048,20 @@ public class MenuMYSQLDAO implements MenuDAO {
con
=
MySQLDAOFactory
.
getConnectionSQL
(
"SECURITY"
);
con
.
setAutoCommit
(
false
);
String
sql
=
"{CALL SP_TA_ACCIONES_POR_VISTA(?,?,?,?,?,?,?,?)}"
;
pst
=
con
.
prepareStatement
(
sql
);
pst
.
setInt
(
1
,
json
.
getInt
(
"tipo_accion"
));
pst
.
setInt
(
2
,
json
.
getInt
(
"v_cod_accion"
));
pst
.
setString
(
3
,
json
.
getString
(
"v_nom_accion"
));
pst
.
setInt
(
4
,
json
.
getInt
(
"v_jerarquia"
));
pst
.
setInt
(
5
,
json
.
getInt
(
"v_cod_proyecto"
));
pst
.
setInt
(
6
,
json
.
getInt
(
"v_cod_vista"
));
pst
.
setInt
(
7
,
json
.
getInt
(
"v_cod_vista_acc"
));
pst
.
setInt
(
8
,
json
.
getInt
(
"v_tipo_usuario"
));
rSet
=
pst
.
executeQuery
();
if
(
json
.
getInt
(
"tipo_accion"
)
==
3
)
{
while
(
rSet
.
next
())
{
jsonReturn
.
put
(
"status"
,
rSet
.
getInt
(
"result"
));
jsonReturn
.
put
(
"message"
,
"todo bien"
);
}
}
else
{
jsonReturn
.
put
(
"status"
,
true
);
jsonReturn
.
put
(
"message"
,
"todo bien"
);
JSONArray
params
=
new
JSONArray
()
.
put
(
json
.
getInt
(
"tipo_accion"
))
.
put
(
json
.
getInt
(
"v_cod_accion"
))
.
put
(
json
.
getString
(
"v_nom_accion"
))
.
put
(
json
.
getInt
(
"v_jerarquia"
))
.
put
(
json
.
getInt
(
"v_cod_proyecto"
))
.
put
(
json
.
getInt
(
"v_cod_vista"
))
.
put
(
json
.
getInt
(
"v_cod_vista_acc"
))
.
put
(
json
.
getInt
(
"v_tipo_usuario"
));
JSONArray
arrayjson
=
DAOHelper
.
queryProcedure
(
con
,
sql
,
params
);
if
(!
arrayjson
.
isEmpty
())
{
JSONObject
item
=
arrayjson
.
getJSONObject
(
0
);
jsonReturn
.
put
(
"status"
,
item
.
getString
(
"status"
)
);
jsonReturn
.
put
(
"message"
,
!
item
.
isNull
(
"message"
)
?
item
.
getString
(
"message"
)
:
"Se realizo la accion"
);
}
con
.
commit
();
}
catch
(
SQLException
e
)
{
...
...
@@ -3072,7 +3069,12 @@ public class MenuMYSQLDAO implements MenuDAO {
jsonReturn
.
put
(
"status"
,
false
);
jsonReturn
.
put
(
"message"
,
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
assert
con
!=
null
;
con
.
close
();
}
return
jsonReturn
;
}
...
...
src/main/java/com/mycompany/moduloseguridad/servlets/MantenimientoMenuServlet.java
View file @
60ef6108
...
...
@@ -97,13 +97,14 @@ public class MantenimientoMenuServlet extends HttpServlet {
}
private
void
listarMenu
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
"application/json"
);
response
.
setContentType
(
"application/json"
);
PrintWriter
out
=
response
.
getWriter
();
MenuService
srv
=
new
MenuService
();
int
proyecto_detalle
=
Integer
.
parseInt
(
request
.
getParameter
(
"codigo"
));
int
tipo
=
Integer
.
parseInt
(
request
.
getParameter
(
"tipo"
));
int
proyecto
=
Integer
.
parseInt
(
request
.
getParameter
(
"proyecto"
));
String
draw
=
request
.
getParameter
(
"draw"
);
int
listarPermisos
=
Integer
.
parseInt
(
request
.
getParameter
(
"listarPermisos"
));
JSONObject
rs
=
new
JSONObject
();
JSONArray
lista
=
new
JSONArray
();
JSONArray
listaTitulo
=
srv
.
listarTituloCompleto
(
proyecto_detalle
,
proyecto
,
tipo
);
...
...
@@ -113,7 +114,6 @@ public class MantenimientoMenuServlet extends HttpServlet {
int
iModulo
=
0
;
JSONObject
obj1
=
new
JSONObject
();
JSONObject
objTitulo
=
(
JSONObject
)
listaTitulo
.
get
(
i
);
System
.
out
.
println
(
"objTitulo "
+
i
+
" : "
+
objTitulo
);
String
nombreTitulo
=
objTitulo
.
getString
(
"nombreTitulo"
);
int
codigoTitulo
=
objTitulo
.
getInt
(
"codigoTitulo"
);
int
configuracionTitulo
=
objTitulo
.
getInt
(
"configuracionTitulo"
);
...
...
@@ -158,22 +158,24 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj2
.
put
(
"orden"
,
ordenModulo
);
obj2
.
put
(
"esVisible"
,
esVisible1
);
lista
.
put
(
obj2
);
JSONArray
listarModuloAcc
=
srv
.
obtenerAcciones
(
codigoModulo
,
2
,
proyecto_detalle
);
for
(
int
modacc
=
0
;
modacc
<
listarModuloAcc
.
length
();
modacc
++)
{
JSONObject
objModuloAcc
=
(
JSONObject
)
listarModuloAcc
.
get
(
modacc
);
JSONObject
objModuloAcc2
=
new
JSONObject
();
objModuloAcc2
.
put
(
"conta"
,
modacc
+
1
);
objModuloAcc2
.
put
(
"jerarquia"
,
5
);
objModuloAcc2
.
put
(
"nombre"
,
objModuloAcc
.
getString
(
"nom_accion"
));
objModuloAcc2
.
put
(
"codigo"
,
objModuloAcc
.
getInt
(
"cod_accion"
));
objModuloAcc2
.
put
(
"icono"
,
""
);
objModuloAcc2
.
put
(
"url"
,
""
);
objModuloAcc2
.
put
(
"tipo"
,
3
);
objModuloAcc2
.
put
(
"configuracion"
,
0
);
objModuloAcc2
.
put
(
"padre"
,
codigoModulo
);
objModuloAcc2
.
put
(
"orden"
,
0
);
// objModuloAcc2.put("esVisible", true);
lista
.
put
(
objModuloAcc2
);
if
(
listarPermisos
!=
0
)
{
JSONArray
listarModuloAcc
=
srv
.
obtenerAcciones
(
codigoModulo
,
2
,
proyecto_detalle
);
for
(
int
modacc
=
0
;
modacc
<
listarModuloAcc
.
length
();
modacc
++)
{
JSONObject
objModuloAcc
=
(
JSONObject
)
listarModuloAcc
.
get
(
modacc
);
JSONObject
objModuloAcc2
=
new
JSONObject
();
objModuloAcc2
.
put
(
"conta"
,
modacc
+
1
);
objModuloAcc2
.
put
(
"jerarquia"
,
5
);
objModuloAcc2
.
put
(
"nombre"
,
objModuloAcc
.
isNull
(
"nom_accion"
)
?
""
:
objModuloAcc
.
getString
(
"nom_accion"
));
objModuloAcc2
.
put
(
"codigo"
,
objModuloAcc
.
isNull
(
"cod_accion"
)
?
""
:
objModuloAcc
.
getInt
(
"cod_accion"
));
objModuloAcc2
.
put
(
"icono"
,
""
);
objModuloAcc2
.
put
(
"url"
,
""
);
objModuloAcc2
.
put
(
"tipo"
,
3
);
objModuloAcc2
.
put
(
"configuracion"
,
0
);
objModuloAcc2
.
put
(
"padre"
,
codigoModulo
);
objModuloAcc2
.
put
(
"orden"
,
0
);
// objModuloAcc2.put("esVisible", true);
lista
.
put
(
objModuloAcc2
);
}
}
JSONArray
listaCategoria
=
srv
.
listarCategoriaCompleto
(
codigoModulo
,
proyecto_detalle
,
proyecto
,
tipo
);
for
(
int
k
=
0
;
k
<
listaCategoria
.
length
();
k
++)
{
...
...
@@ -201,21 +203,23 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj3
.
put
(
"orden"
,
ordenCategoria
);
obj3
.
put
(
"esVisible"
,
esVisible2
);
lista
.
put
(
obj3
);
JSONArray
listarCategoriaAcc
=
srv
.
obtenerAcciones
(
codigoCategoria
,
3
,
proyecto_detalle
);
for
(
int
catacc
=
0
;
catacc
<
listarCategoriaAcc
.
length
();
catacc
++)
{
JSONObject
objCategoriaAcc
=
(
JSONObject
)
listarCategoriaAcc
.
get
(
catacc
);
JSONObject
objCategoriaAcc2
=
new
JSONObject
();
objCategoriaAcc2
.
put
(
"conta"
,
catacc
+
1
);
objCategoriaAcc2
.
put
(
"jerarquia"
,
6
);
objCategoriaAcc2
.
put
(
"nombre"
,
objCategoriaAcc
.
getString
(
"nom_accion"
));
objCategoriaAcc2
.
put
(
"codigo"
,
objCategoriaAcc
.
getInt
(
"cod_accion"
));
objCategoriaAcc2
.
put
(
"icono"
,
""
);
objCategoriaAcc2
.
put
(
"url"
,
""
);
objCategoriaAcc2
.
put
(
"tipo"
,
3
);
objCategoriaAcc2
.
put
(
"configuracion"
,
0
);
objCategoriaAcc2
.
put
(
"padre"
,
codigoCategoria
);
objCategoriaAcc2
.
put
(
"orden"
,
0
);
lista
.
put
(
objCategoriaAcc2
);
if
(
listarPermisos
!=
0
)
{
JSONArray
listarCategoriaAcc
=
srv
.
obtenerAcciones
(
codigoCategoria
,
3
,
proyecto_detalle
);
for
(
int
catacc
=
0
;
catacc
<
listarCategoriaAcc
.
length
();
catacc
++)
{
JSONObject
objCategoriaAcc
=
(
JSONObject
)
listarCategoriaAcc
.
get
(
catacc
);
JSONObject
objCategoriaAcc2
=
new
JSONObject
();
objCategoriaAcc2
.
put
(
"conta"
,
catacc
+
1
);
objCategoriaAcc2
.
put
(
"jerarquia"
,
6
);
objCategoriaAcc2
.
put
(
"nombre"
,
objCategoriaAcc
.
isNull
(
"nom_accion"
)
?
""
:
objCategoriaAcc
.
getString
(
"nom_accion"
));
objCategoriaAcc2
.
put
(
"codigo"
,
objCategoriaAcc
.
isNull
(
"cod_accion"
)
?
""
:
objCategoriaAcc
.
getInt
(
"cod_accion"
));
objCategoriaAcc2
.
put
(
"icono"
,
""
);
objCategoriaAcc2
.
put
(
"url"
,
""
);
objCategoriaAcc2
.
put
(
"tipo"
,
3
);
objCategoriaAcc2
.
put
(
"configuracion"
,
0
);
objCategoriaAcc2
.
put
(
"padre"
,
codigoCategoria
);
objCategoriaAcc2
.
put
(
"orden"
,
0
);
lista
.
put
(
objCategoriaAcc2
);
}
}
JSONArray
listaSubCategoria
=
srv
.
listarSubCategoriaCompleto
(
codigoCategoria
,
proyecto_detalle
,
proyecto
,
tipo
);
for
(
int
l
=
0
;
l
<
listaSubCategoria
.
length
();
l
++)
{
...
...
@@ -241,21 +245,23 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj4
.
put
(
"orden"
,
ordenSubCategoria
);
obj4
.
put
(
"esVisible"
,
esVisible3
);
lista
.
put
(
obj4
);
JSONArray
listarSubAcc
=
srv
.
obtenerAcciones
(
codigoSubCategoria
,
4
,
proyecto_detalle
);
for
(
int
subacc
=
0
;
subacc
<
listarSubAcc
.
length
();
subacc
++)
{
JSONObject
objSubAcc
=
(
JSONObject
)
listarSubAcc
.
get
(
subacc
);
JSONObject
objSubAcc2
=
new
JSONObject
();
objSubAcc2
.
put
(
"conta"
,
subacc
+
1
);
objSubAcc2
.
put
(
"jerarquia"
,
7
);
objSubAcc2
.
put
(
"nombre"
,
objSubAcc
.
getString
(
"nom_accion"
));
objSubAcc2
.
put
(
"codigo"
,
objSubAcc
.
getInt
(
"cod_accion"
));
objSubAcc2
.
put
(
"icono"
,
""
);
objSubAcc2
.
put
(
"url"
,
""
);
objSubAcc2
.
put
(
"tipo"
,
3
);
objSubAcc2
.
put
(
"configuracion"
,
0
);
objSubAcc2
.
put
(
"padre"
,
codigoSubCategoria
);
objSubAcc2
.
put
(
"orden"
,
0
);
lista
.
put
(
objSubAcc2
);
if
(
listarPermisos
!=
0
)
{
JSONArray
listarSubAcc
=
srv
.
obtenerAcciones
(
codigoSubCategoria
,
4
,
proyecto_detalle
);
for
(
int
subacc
=
0
;
subacc
<
listarSubAcc
.
length
();
subacc
++)
{
JSONObject
objSubAcc
=
(
JSONObject
)
listarSubAcc
.
get
(
subacc
);
JSONObject
objSubAcc2
=
new
JSONObject
();
objSubAcc2
.
put
(
"conta"
,
subacc
+
1
);
objSubAcc2
.
put
(
"jerarquia"
,
7
);
objSubAcc2
.
put
(
"nombre"
,
objSubAcc
.
isNull
(
"nom_accion"
)
?
""
:
objSubAcc
.
getString
(
"nom_accion"
));
objSubAcc2
.
put
(
"codigo"
,
objSubAcc
.
isNull
(
"cod_accion"
)
?
""
:
objSubAcc
.
getInt
(
"cod_accion"
));
objSubAcc2
.
put
(
"icono"
,
""
);
objSubAcc2
.
put
(
"url"
,
""
);
objSubAcc2
.
put
(
"tipo"
,
3
);
objSubAcc2
.
put
(
"configuracion"
,
0
);
objSubAcc2
.
put
(
"padre"
,
codigoSubCategoria
);
objSubAcc2
.
put
(
"orden"
,
0
);
lista
.
put
(
objSubAcc2
);
}
}
}
}
...
...
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