Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TFG
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
josborg
TFG
Commits
6abfd6a0
Commit
6abfd6a0
authored
Apr 11, 2022
by
josborg
Browse files
Options
Downloads
Patches
Plain Diff
Back end debug
parent
9a52150b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
encuestas/src/main/java/com/uva/surveys/controller/EncuestaController.java
+34
-9
34 additions, 9 deletions
...n/java/com/uva/surveys/controller/EncuestaController.java
with
34 additions
and
9 deletions
encuestas/src/main/java/com/uva/surveys/controller/EncuestaController.java
+
34
−
9
View file @
6abfd6a0
...
...
@@ -528,9 +528,9 @@ public class EncuestaController {
System
.
out
.
println
(
"link: "
+
link
.
getCode
());
if
(!
codes
.
contains
(
link
.
getCode
())){
Encuesta
e
=
getEncuestaByIdFull
(
Integer
.
valueOf
(
getIdByCode
(
link
.
getCode
())));
//
if(!e.getStatus().equals(Estado.FINALIZADA)){
//
e = getEncuestaById(Integer.valueOf(getIdByCode(link.getCode())));
//
}
if
(!
e
.
getStatus
().
equals
(
Estado
.
FINALIZADA
)){
e
=
getEncuestaById
(
Integer
.
valueOf
(
getIdByCode
(
link
.
getCode
())));
}
encuestas
.
add
(
e
);
codes
.
add
(
link
.
getCode
());
}
...
...
@@ -549,8 +549,35 @@ public class EncuestaController {
*/
@GetMapping
(
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
value
=
"/profesores/{id}"
)
public
List
<
Encuesta
>
getEncuestasByIdProfesor
(
@PathVariable
Long
id
)
{
String
resultAsJsonStr
=
new
RestTemplate
().
postForObject
(
"http://api-discord:8081/api/bot/"
,
"{\"user\":"
+
id
+
"}"
,
String
.
class
);
System
.
out
.
println
(
resultAsJsonStr
);
JsonParser
parser
=
new
JsonParser
();
JsonElement
guildsUsersElement
=
parser
.
parse
(
resultAsJsonStr
);
JsonArray
guildUserJsonArray
=
guildsUsersElement
.
getAsJsonArray
();
System
.
out
.
println
(
"guildUserJsonArray: "
+
guildUserJsonArray
.
toString
());
ArrayList
<
String
>
codes
=
new
ArrayList
<>();
List
<
Encuesta
>
encuestasProfesor
=
new
ArrayList
<>();
for
(
JsonElement
jsonElement
:
guildUserJsonArray
)
{
System
.
out
.
println
(
"jsonElement: "
+
jsonElement
);
List
<
Link
>
links
=
linkRepository
.
findByGuild
(
jsonElement
.
getAsLong
());
for
(
Link
link
:
links
){
System
.
out
.
println
(
"link: "
+
link
.
getCode
());
if
(!
codes
.
contains
(
link
.
getCode
())){
Encuesta
e
=
getEncuestaByIdFull
(
Integer
.
valueOf
(
getIdByCode
(
link
.
getCode
())));
encuestasProfesor
.
add
(
e
);
codes
.
add
(
link
.
getCode
());
}
}
}
List
<
Encuesta
>
encuestasCreador
=
encuestaRepository
.
findByCreator
(
id
);
List
<
Encuesta
>
encuestasProfesor
=
getEncuestasByIdUsuario
(
id
);
//elimina duplicados.
List
<
Encuesta
>
listFinal
=
Stream
.
concat
(
encuestasCreador
.
stream
(),
encuestasProfesor
.
stream
())
.
distinct
()
...
...
@@ -565,7 +592,7 @@ public class EncuestaController {
return soluciones;
}*/
@DeleteMapping
(
"/soluciones
/{id}
"
)
@DeleteMapping
(
"/
{id}/
soluciones"
)
public
String
deleteSolucion
(
@PathVariable
Integer
id
)
{
try
{
if
(
encuestaRepository
.
existsById
(
id
))
{
...
...
@@ -577,10 +604,10 @@ public class EncuestaController {
solucionRepository
.
delete
(
solucion
);
}
return
"
Pedido
eliminado: "
+
id
;
return
"
soluciones
eliminado: "
+
id
;
}
else
{
return
"
Pedido
con id: "
+
id
+
" no existe"
;
return
"
soluciones
con id: "
+
id
+
" no existe"
;
}
}
catch
(
Exception
e
)
{
throw
new
EncuestaException
(
"Error al elimiar el registro."
);
...
...
@@ -591,7 +618,6 @@ public class EncuestaController {
@PostMapping
(
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
value
=
"/link"
)
public
String
newLink
(
@RequestBody
Link
link
)
{
try
{
//Gurdar que la encuesta con codigo code a sido pulicada en el servidor guild
linkRepository
.
saveAndFlush
(
link
);
return
"guild: "
+
link
.
getCode
()
+
" "
+
link
.
getGuild
();
...
...
@@ -611,7 +637,6 @@ public class EncuestaController {
@PostMapping
(
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
value
=
"/user"
)
public
String
newUser
(
@RequestBody
Usuario
user
)
{
try
{
//Gurdar que la encuesta con codigo code a sido pulicada en el servidor guild
userRepository
.
saveAndFlush
(
user
);
return
"Name: "
+
user
.
getName
()
+
"UserId: "
+
user
.
getUserId
()+
", Guild: "
+
user
.
getGuild
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment