Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
student-tournament-hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Schneider Stefan
student-tournament-hub
Commits
90d12c1e
Commit
90d12c1e
authored
1 year ago
by
Jonas
Browse files
Options
Downloads
Patches
Plain Diff
18.12.2023 - create controller class and endpoints
#22
parent
40414997
No related branches found
Branches containing commit
No related tags found
1 merge request
!7
Dev in Main Merge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sth-backend/src/main/java/hdm/mi/sthbackend/controller/TournamentController.java
+65
-0
65 additions, 0 deletions
...va/hdm/mi/sthbackend/controller/TournamentController.java
with
65 additions
and
0 deletions
sth-backend/src/main/java/hdm/mi/sthbackend/controller/TournamentController.java
0 → 100644
+
65
−
0
View file @
90d12c1e
package
hdm.mi.sthbackend.controller
;
import
hdm.mi.sthbackend.exeptions.PlayerIdNotFoundException
;
import
hdm.mi.sthbackend.exeptions.TournamentIdNotFoundException
;
import
hdm.mi.sthbackend.model.Player
;
import
hdm.mi.sthbackend.model.Team
;
import
hdm.mi.sthbackend.model.Tournament
;
import
hdm.mi.sthbackend.service.TournamentService
;
import
lombok.AllArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.UUID
;
@RestController
@RequestMapping
(
"/api/v1/tournaments"
)
@AllArgsConstructor
public
class
TournamentController
{
private
final
TournamentService
service
;
/**
* Player Endpoints
**/
@PatchMapping
(
"/{tournamentId}/teams/{teamId}/players/{playerId}"
)
public
UUID
updatePlayerName
(
@PathVariable
UUID
tournamentId
,
@PathVariable
UUID
teamId
,
@PathVariable
UUID
playerId
,
@RequestBody
String
newPlayerName
)
throws
Exception
{
return
service
.
updatePlayerName
(
tournamentId
,
teamId
,
playerId
,
newPlayerName
);
}
/**
* Team Endpoints
**/
@PostMapping
(
"/{tournamentId}/teams"
)
public
Team
createTeam
(
@PathVariable
UUID
tournamentId
,
@RequestBody
String
teamName
)
throws
TournamentIdNotFoundException
{
return
service
.
createTeam
(
tournamentId
,
teamName
);
}
@PostMapping
(
"/{tournamentId}/teams/{teamId}/addPlayer"
)
public
Player
addPlayerToTeam
(
@PathVariable
UUID
tournamentId
,
@PathVariable
UUID
teamId
,
@RequestBody
String
playerName
)
throws
Exception
{
return
service
.
addPlayerToTeam
(
tournamentId
,
teamId
,
playerName
);
}
@DeleteMapping
(
"/{tournamentId}/teams/{teamId}/players/{playerId}"
)
public
Player
removePlayerFromTeam
(
@PathVariable
UUID
tournamentId
,
@PathVariable
UUID
teamId
,
@PathVariable
UUID
playerId
)
throws
PlayerIdNotFoundException
,
TournamentIdNotFoundException
{
return
service
.
removePlayerFromTeam
(
tournamentId
,
teamId
,
playerId
);
}
/**
* Tournament Endpoints
*/
@PostMapping
public
Tournament
createTournament
(
@RequestBody
String
tournamentName
)
{
return
service
.
createTournament
(
tournamentName
);
}
}
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