Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oucéquecé
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRICHE Louis
oucéquecé
Commits
63e5295b
Commit
63e5295b
authored
1 month ago
by
BRICHE Louis
Browse files
Options
Downloads
Patches
Plain Diff
resource pour commencer le quiz
parent
050e665a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/fr/louis/projetprogreseau/api/ConnexionResource.java
+38
-0
38 additions, 0 deletions
...java/fr/louis/projetprogreseau/api/ConnexionResource.java
with
38 additions
and
0 deletions
src/main/java/fr/louis/projetprogreseau/api/ConnexionResource.java
0 → 100644
+
38
−
0
View file @
63e5295b
package
fr.louis.projetprogreseau.api
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
fr.louis.projetprogreseau.user.User
;
import
fr.louis.projetprogreseau.user.Users
;
import
jakarta.ws.rs.Consumes
;
import
jakarta.ws.rs.POST
;
import
jakarta.ws.rs.Path
;
import
jakarta.ws.rs.Produces
;
import
jakarta.ws.rs.core.MediaType
;
import
jakarta.ws.rs.core.Response
;
import
java.util.UUID
;
/**
* classe qui gère le commencement du quiz. On récupère l'username du joueur et on créé un {@link User} en lien avec le joueur.
*/
@Path
(
"/start"
)
public
class
ConnexionResource
{
@POST
@Consumes
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Response
getUserName
(
JsonObject
inputJson
)
{
String
username
=
inputJson
.
get
(
"username"
).
getAsString
();
System
.
out
.
println
(
"nouveau joueur! "
+
username
);
User
user
=
new
User
(
username
,
UUID
.
randomUUID
());
Users
.
put
(
user
);
JsonObject
jsonObject
=
new
JsonObject
();
jsonObject
.
addProperty
(
"uuid"
,
user
.
getUuid
().
toString
());
jsonObject
.
addProperty
(
"question"
,
new
Gson
().
toJson
(
user
.
getActualQuizz
()));
return
Response
.
ok
(
jsonObject
.
toString
(),
MediaType
.
APPLICATION_JSON
).
build
();
}
}
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