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
e5296ae9
Commit
e5296ae9
authored
Sep 04, 2023
by
Mauro Paolo Josue Zuñiga Mallqui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIXED] SE REPARO ERRORES QUE ASIGNAR, FILTRAR Y MENSAJES
parent
bf41be21
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
49 additions
and
25 deletions
+49
-25
.gitignore
.gitignore
+2
-2
ProyectoDAO.java
...n/java/com/mycompany/moduloseguridad/dao/ProyectoDAO.java
+1
-1
ProyectoMYSQLDAO.java
.../mycompany/moduloseguridad/mysqldao/ProyectoMYSQLDAO.java
+17
-3
UsuarioMYSQLDAO.java
...m/mycompany/moduloseguridad/mysqldao/UsuarioMYSQLDAO.java
+3
-2
ProyectoService.java
...m/mycompany/moduloseguridad/services/ProyectoService.java
+2
-2
ProyectoServlet.java
...m/mycompany/moduloseguridad/servlets/ProyectoServlet.java
+3
-2
UsuarioServlet.java
...om/mycompany/moduloseguridad/servlets/UsuarioServlet.java
+2
-2
proyecto.js
src/main/webapp/js/pages/proyecto.js
+8
-6
sidebar.js
src/main/webapp/js/pages/sidebar.js
+9
-2
usuario.js
src/main/webapp/js/pages/usuario.js
+2
-3
No files found.
.gitignore
View file @
e5296ae9
...
@@ -2,4 +2,5 @@
...
@@ -2,4 +2,5 @@
/build/
/build/
/nbproject/private/
/nbproject/private/
/nbproject/
/nbproject/
/.idea/
/.idea/
\ No newline at end of file
/target/
src/main/java/com/mycompany/moduloseguridad/dao/ProyectoDAO.java
View file @
e5296ae9
...
@@ -24,7 +24,7 @@ public interface ProyectoDAO {
...
@@ -24,7 +24,7 @@ public interface ProyectoDAO {
public
int
desactivarProyecto
(
int
codigo
)
throws
Exception
;
public
int
desactivarProyecto
(
int
codigo
)
throws
Exception
;
public
JSONObject
asignarDetalle
(
int
proyecto
,
int
tipoUsuario
)
throws
Exception
;
public
JSONObject
asignarDetalle
(
int
proyecto
,
String
codTIpoUsuario
,
int
tipoUsuario
)
throws
Exception
;
public
JSONObject
listarDetalle
(
String
filtro
,
int
vstart
,
int
vlength
,
String
draw
)
throws
Exception
;
public
JSONObject
listarDetalle
(
String
filtro
,
int
vstart
,
int
vlength
,
String
draw
)
throws
Exception
;
...
...
src/main/java/com/mycompany/moduloseguridad/mysqldao/ProyectoMYSQLDAO.java
View file @
e5296ae9
...
@@ -9,6 +9,8 @@ import java.sql.Connection;
...
@@ -9,6 +9,8 @@ import java.sql.Connection;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.stream.Stream
;
import
com.mycompany.moduloseguridad.utilities.ResponseHelper
;
import
com.mycompany.moduloseguridad.utilities.ResponseHelper
;
import
com.mycompany.moduloseguridad.dao.ProyectoDAO
;
import
com.mycompany.moduloseguridad.dao.ProyectoDAO
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
...
@@ -158,7 +160,7 @@ public class ProyectoMYSQLDAO implements ProyectoDAO {
...
@@ -158,7 +160,7 @@ public class ProyectoMYSQLDAO implements ProyectoDAO {
}
}
@Override
@Override
public
JSONObject
asignarDetalle
(
int
proyecto
,
int
ti
poUsuario
)
throws
Exception
{
public
JSONObject
asignarDetalle
(
int
proyecto
,
String
tIpoUsuario
,
int
codTI
poUsuario
)
throws
Exception
{
JSONObject
jsonReturn
;
JSONObject
jsonReturn
;
ResponseHelper
response
=
new
ResponseHelper
();
ResponseHelper
response
=
new
ResponseHelper
();
String
base
=
"security"
;
String
base
=
"security"
;
...
@@ -170,8 +172,16 @@ public class ProyectoMYSQLDAO implements ProyectoDAO {
...
@@ -170,8 +172,16 @@ public class ProyectoMYSQLDAO implements ProyectoDAO {
try
{
try
{
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
con
.
setAutoCommit
(
false
);
con
.
setAutoCommit
(
false
);
query
=
" insert into proyecto_detalle (cod_proyecto, cod_tipo_usuario, est) "
if
(
codTIpoUsuario
==
0
)
{
+
" values ("
+
proyecto
+
", "
+
tipoUsuario
+
", 1) "
;
query
=
"insert into seguridad.tipo_usuario(nom,est) values ('"
+
tIpoUsuario
+
"',1)"
;
pst
=
con
.
prepareStatement
(
query
,
Statement
.
RETURN_GENERATED_KEYS
);
pst
.
executeUpdate
();
query
=
" insert into seguridad.proyecto_detalle (cod_proyecto, cod_tipo_usuario, est) "
+
" values ("
+
proyecto
+
", (select cod_tipo_usuario from seguridad.tipo_usuario where nom = '"
+
tIpoUsuario
+
"'), 1) "
;
}
else
{
query
=
" insert into seguridad.proyecto_detalle (cod_proyecto, cod_tipo_usuario, est) "
+
" values ("
+
proyecto
+
", "
+
codTIpoUsuario
+
", 1) "
;
}
pst
=
con
.
prepareStatement
(
query
,
Statement
.
RETURN_GENERATED_KEYS
);
pst
=
con
.
prepareStatement
(
query
,
Statement
.
RETURN_GENERATED_KEYS
);
rs
=
pst
.
executeUpdate
();
rs
=
pst
.
executeUpdate
();
if
(
rs
>=
1
)
{
if
(
rs
>=
1
)
{
...
@@ -617,4 +627,7 @@ public class ProyectoMYSQLDAO implements ProyectoDAO {
...
@@ -617,4 +627,7 @@ public class ProyectoMYSQLDAO implements ProyectoDAO {
return
resultado
;
return
resultado
;
}
}
public
static
void
main
(
String
[]
args
)
{
Stream
.
iterate
(
1
,
i
->
i
+
1
).
limit
(
10
).
forEach
(
System
.
out
::
println
);
}
}
}
\ No newline at end of file
src/main/java/com/mycompany/moduloseguridad/mysqldao/UsuarioMYSQLDAO.java
View file @
e5296ae9
...
@@ -45,7 +45,7 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
...
@@ -45,7 +45,7 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
" left join seguridad.tipo_usuario as tu on pd.cod_tipo_usuario = tu.cod_tipo_usuario\n"
+
" 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.personal as p on a.cod_trabajador = p.tmp_id\n"
+
" left join nuevo.cargo as c on p.codcargo = c.codcargo\n"
+
" left join nuevo.cargo as c on p.codcargo = c.codcargo\n"
+
" WHERE 1 = 1\n"
+
" WHERE 1 = 1
and ud.est = 1
\n"
+
" and if("
+
proyecto
+
" = 0, true, pd.cod_proyecto = "
+
proyecto
+
")\n"
+
" and if("
+
proyecto
+
" = 0, true, pd.cod_proyecto = "
+
proyecto
+
")\n"
+
" and if("
+
tipoUsuario
+
" = 0, true, pd.cod_proyecto_detalle = "
+
tipoUsuario
+
")\n"
+
" and if("
+
tipoUsuario
+
" = 0, true, pd.cod_proyecto_detalle = "
+
tipoUsuario
+
")\n"
+
" "
+
estado
+
"\n"
+
" "
+
estado
+
"\n"
+
...
@@ -57,7 +57,7 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
...
@@ -57,7 +57,7 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
"from tablaOrdenada\n"
+
"from tablaOrdenada\n"
+
"ORDER BY usu limit "
+
vlength
+
" offset "
+
vstart
+
";"
;
"ORDER BY usu limit "
+
vlength
+
" offset "
+
vstart
+
";"
;
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
System
.
out
.
println
(
query
);
pst
=
con
.
prepareStatement
(
query
);
pst
=
con
.
prepareStatement
(
query
);
rs
=
pst
.
executeQuery
();
rs
=
pst
.
executeQuery
();
int
conta
=
vstart
+
1
;
int
conta
=
vstart
+
1
;
...
@@ -298,6 +298,7 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
...
@@ -298,6 +298,7 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
+
" on tu.cod_tipo_usuario = pd.cod_tipo_usuario "
+
" on tu.cod_tipo_usuario = pd.cod_tipo_usuario "
+
" where ud.cod_usuario = "
+
filtro
+
";"
;
+
" where ud.cod_usuario = "
+
filtro
+
";"
;
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
System
.
out
.
println
(
query
);
pst
=
con
.
prepareStatement
(
query
);
pst
=
con
.
prepareStatement
(
query
);
rs
=
pst
.
executeQuery
();
rs
=
pst
.
executeQuery
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
...
...
src/main/java/com/mycompany/moduloseguridad/services/ProyectoService.java
View file @
e5296ae9
...
@@ -59,10 +59,10 @@ public class ProyectoService {
...
@@ -59,10 +59,10 @@ public class ProyectoService {
return
rs
;
return
rs
;
}
}
public
JSONObject
asignarDetalle
(
int
proyecto
,
int
ti
poUsuario
)
{
public
JSONObject
asignarDetalle
(
int
proyecto
,
String
tipoUsuario
,
int
codTI
poUsuario
)
{
JSONObject
rs
=
null
;
JSONObject
rs
=
null
;
try
{
try
{
rs
=
dao
.
asignarDetalle
(
proyecto
,
ti
poUsuario
);
rs
=
dao
.
asignarDetalle
(
proyecto
,
tipoUsuario
,
codTI
poUsuario
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/main/java/com/mycompany/moduloseguridad/servlets/ProyectoServlet.java
View file @
e5296ae9
...
@@ -132,8 +132,9 @@ public class ProyectoServlet extends HttpServlet {
...
@@ -132,8 +132,9 @@ public class ProyectoServlet extends HttpServlet {
PrintWriter
out
=
response
.
getWriter
();
PrintWriter
out
=
response
.
getWriter
();
ProyectoService
service
=
new
ProyectoService
();
ProyectoService
service
=
new
ProyectoService
();
int
proyecto
=
Integer
.
parseInt
(
request
.
getParameter
(
"proyecto"
));
int
proyecto
=
Integer
.
parseInt
(
request
.
getParameter
(
"proyecto"
));
int
tipoUsuario
=
Integer
.
parseInt
(
request
.
getParameter
(
"tipoUsuario"
));
int
codTIpoUsuario
=
Integer
.
parseInt
(
request
.
getParameter
(
"codTIpoUsuario"
));
JSONObject
rs
=
service
.
asignarDetalle
(
proyecto
,
tipoUsuario
);
String
tipoUsuario
=
request
.
getParameter
(
"tipoUsuario"
);
JSONObject
rs
=
service
.
asignarDetalle
(
proyecto
,
tipoUsuario
,
codTIpoUsuario
);
out
.
println
(
rs
);
out
.
println
(
rs
);
}
}
...
...
src/main/java/com/mycompany/moduloseguridad/servlets/UsuarioServlet.java
View file @
e5296ae9
...
@@ -255,8 +255,8 @@ public class UsuarioServlet extends HttpServlet {
...
@@ -255,8 +255,8 @@ public class UsuarioServlet extends HttpServlet {
String
json
=
request
.
getParameter
(
"json"
);
String
json
=
request
.
getParameter
(
"json"
);
JSONObject
obj
=
new
JSONObject
(
json
);
JSONObject
obj
=
new
JSONObject
(
json
);
String
draw
=
request
.
getParameter
(
"draw"
);
String
draw
=
request
.
getParameter
(
"draw"
);
int
vstart
=
Integer
.
parseInt
(
request
.
getParameter
(
"start"
));
int
vstart
=
Integer
.
parseInt
(
request
.
getParameter
(
"start"
)
==
null
?
"0"
:
request
.
getParameter
(
"start"
)
);
int
vlength
=
Integer
.
parseInt
(
request
.
getParameter
(
"length"
));
int
vlength
=
Integer
.
parseInt
(
request
.
getParameter
(
"length"
)
==
null
?
"0"
:
request
.
getParameter
(
"length"
)
);
JSONObject
resp
=
srv
.
listarUsuarioDetalle
(
obj
,
vstart
,
vlength
,
draw
);
JSONObject
resp
=
srv
.
listarUsuarioDetalle
(
obj
,
vstart
,
vlength
,
draw
);
out
.
println
(
resp
);
out
.
println
(
resp
);
}
}
...
...
src/main/webapp/js/pages/proyecto.js
View file @
e5296ae9
...
@@ -932,12 +932,13 @@
...
@@ -932,12 +932,13 @@
label
:
"<i class='fa fa-check bigger-110'></i> Aceptar"
,
label
:
"<i class='fa fa-check bigger-110'></i> Aceptar"
,
className
:
"btn bg-primary border-primary-600 btn-xs buttonOk"
,
className
:
"btn bg-primary border-primary-600 btn-xs buttonOk"
,
callback
:
function
()
{
callback
:
function
()
{
var
tipoUsuario
=
$
(
'#cboTipoUsuario'
).
val
()
const
json
=
{
var
json
=
{
"proyecto"
:
proyecto
,
"proyecto"
:
proyecto
,
"tipoUsuario"
:
tipoUsuario
"codTIpoUsuario"
:
$
(
'#cboTipoUsuario'
).
siblings
(
"ul"
).
children
(
"li"
).
get
().
find
(
x
=>
$
(
x
).
html
().
trim
()
===
$
(
'#cboTipoUsuario'
).
val
().
trim
())?.
value
||
0
,
}
"tipoUsuario"
:
$
(
'#cboTipoUsuario'
).
val
().
trim
()
var
validar
=
$
(
"#formAsignarTipoUsuario"
).
validate
({
};
console
.
log
(
json
)
const
validar
=
$
(
"#formAsignarTipoUsuario"
).
validate
({
rules
:
{
rules
:
{
cboTipoUsuario
:
{
required
:
true
}
cboTipoUsuario
:
{
required
:
true
}
},
},
...
@@ -1007,9 +1008,10 @@
...
@@ -1007,9 +1008,10 @@
success
:
function
(
result
)
{
success
:
function
(
result
)
{
var
print
=
" <option value=''>SELECCIONE TIPO DE USUARIO</option> "
;
var
print
=
" <option value=''>SELECCIONE TIPO DE USUARIO</option> "
;
for
(
var
i
in
result
)
{
for
(
var
i
in
result
)
{
print
+=
" <option value ="
+
result
[
i
].
codigoTipoUsuario
+
">"
+
result
[
i
].
nombreTipoUsuario
+
"</option> "
;
print
+=
" <option
data-value="
+
result
[
i
].
codigoTipoUsuario
+
"
value ="
+
result
[
i
].
codigoTipoUsuario
+
">"
+
result
[
i
].
nombreTipoUsuario
+
"</option> "
;
}
}
$
(
"#cboTipoUsuario"
).
html
(
print
)
$
(
"#cboTipoUsuario"
).
html
(
print
)
$
(
"#cboTipoUsuario"
).
editableSelect
();
}
}
})
})
}
}
...
...
src/main/webapp/js/pages/sidebar.js
View file @
e5296ae9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
const
httpRequestt
=
{
const
httpRequestt
=
{
getproyectos
()
{
getproyectos
()
{
return
ajaxRequestSendBody
({
return
ajaxRequestSendBody
({
url
:
CONSTANTES
.
PATH_SERVICIO_REST
+
'proyecto/listarProyectoUsuario'
,
url
:
'http://pruebaintranet.sacooliveros.pe:8081/security-rest/api/'
+
'proyecto/listarProyectoUsuario'
,
type
:
'POST'
,
type
:
'POST'
,
headers
:
{
headers
:
{
"Content-type"
:
'application/json'
,
"Content-type"
:
'application/json'
,
...
@@ -21,6 +21,12 @@
...
@@ -21,6 +21,12 @@
}
}
}
}
const
prueba
=
{
"text"
:
"Hola Mundo"
,
"status"
:
true
,
"data"
:
[]
};
let
redirectPost
=
(
url
,
data
)
=>
{
let
redirectPost
=
(
url
,
data
)
=>
{
var
form
=
document
.
createElement
(
'form'
);
var
form
=
document
.
createElement
(
'form'
);
form
.
setAttribute
(
"target"
,
"_blank"
);
form
.
setAttribute
(
"target"
,
"_blank"
);
...
@@ -218,4 +224,4 @@
...
@@ -218,4 +224,4 @@
setMenu
();
setMenu
();
DOMNav
.
init
();
DOMNav
.
init
();
EventosClick
.
init
();
EventosClick
.
init
();
\ No newline at end of file
src/main/webapp/js/pages/usuario.js
View file @
e5296ae9
...
@@ -1153,7 +1153,6 @@ function verDetalleUsuario() {
...
@@ -1153,7 +1153,6 @@ function verDetalleUsuario() {
{
{
"data"
:
"estadoUsuarioDetalle"
,
"render"
:
function
(
data
,
type
,
row
)
{
"data"
:
"estadoUsuarioDetalle"
,
"render"
:
function
(
data
,
type
,
row
)
{
conta
++
;
conta
++
;
console
.
log
(
row
);
if
(
data
===
1
)
{
if
(
data
===
1
)
{
return
`
${
!
row
[
"nombreProyecto"
].
toString
().
includes
(
"TRISMEGISTO ASISTENCIA"
)
?
""
:
"<span data-toggle=
\"
tooltip
\"
title=
\"
Entrar al Proyecto
\"
style=
\"
cursor: pointer
\"
> <i class='entrar glyphicon glyphicon-new-window text-blue-400'></i> </span>"
}
return
`
${
!
row
[
"nombreProyecto"
].
toString
().
includes
(
"TRISMEGISTO ASISTENCIA"
)
?
""
:
"<span data-toggle=
\"
tooltip
\"
title=
\"
Entrar al Proyecto
\"
style=
\"
cursor: pointer
\"
> <i class='entrar glyphicon glyphicon-new-window text-blue-400'></i> </span>"
}
<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer"> <i class='desactivar glyphicon glyphicon-trash text-danger-800'></i> </span>`
;
<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer"> <i class='desactivar glyphicon glyphicon-trash text-danger-800'></i> </span>`
;
...
@@ -1196,7 +1195,7 @@ function activarDetalle(filtro) {
...
@@ -1196,7 +1195,7 @@ function activarDetalle(filtro) {
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
data
===
1
)
{
if
(
data
===
1
)
{
$
(
'.mantenimientoDetalle'
).
addClass
(
'hide'
);
$
(
'.mantenimientoDetalle'
).
addClass
(
'hide'
);
msnSuccess
(
'
Asignación correctamente eliminada
'
,
()
=>
{
msnSuccess
(
'
Se ha activado el usuario correctamente
'
,
()
=>
{
$
(
'.mantenimientoDetalle'
).
removeClass
(
'hide'
);
$
(
'.mantenimientoDetalle'
).
removeClass
(
'hide'
);
recargarDetalle
(
filtro
);
recargarDetalle
(
filtro
);
})
})
...
@@ -1240,7 +1239,7 @@ function desactivarDetalle(filtro) {
...
@@ -1240,7 +1239,7 @@ function desactivarDetalle(filtro) {
data
:
json
,
data
:
json
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
data
===
1
)
{
if
(
data
===
1
)
{
msnSuccess
(
'
Asignación correctamente eliminada
'
,
()
=>
{
msnSuccess
(
'
Se ha deshabilitado al usuario correctamente.
'
,
()
=>
{
$
(
'.mantenimientoDetalle'
).
removeClass
(
'hide'
);
$
(
'.mantenimientoDetalle'
).
removeClass
(
'hide'
);
recargarDetalle
(
filtro
);
recargarDetalle
(
filtro
);
})
})
...
...
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